From patchwork Sun Jul 9 18:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700888 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4828902wrs; Sun, 9 Jul 2023 11:37:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlEqyl6AItf44F9zARs4QnAM35b7leRsfSY7/8+M3LjGDPQI2A82uqD3cLr63IwDYb1VTzk9 X-Received: by 2002:a05:622a:c7:b0:403:b103:248 with SMTP id p7-20020a05622a00c700b00403b1030248mr147137qtw.4.1688927875164; Sun, 09 Jul 2023 11:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927875; cv=none; d=google.com; s=arc-20160816; b=jrz9avqClpcNFMtltJNRJ+SEr8+e6duk/sdOJV61kSBivAZhI0TUXki4MngBjh7Fg5 1pqlbMbJRXZ8PPndjvQPpvLPdOy4yJyaxaAh6pxlK/+83VTT8Oyoga6BAgcdm2w1wjXs fRRs3bA4CjR/7tNN5Hr7epcGkfQ3M8gL3RvM0Ic6psBrBPYu9PT0zlW92dOTddbM38h0 fnqnefsoypgHjgqs5fZLEyv1hVDmb4V4jun9ypXFi2lTf26Oio4PFo26HuGwQBWYPiGI 6aJ1Fn2SbfyOZnwvNMzPOlMa285JE9pCu7sIz41bCJQZXhRyEt1vTRGhGamMVdz/2Ucy mWkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KPSt9c/ngpAMvKxksu2NUPKStpNSLJ8TjY6ZtwR8h/Q=; fh=YkX9nmtOxAK2KiyWqyEJEbBRSUY2CznCOBJSJSCtJjs=; b=HCmLSHs9ZRL4CNpjq17wOZNQwMxj68bKKucW3ReHH/1ZBcQbqQLpVYlXP/hUPwe6+P t1ttatsY5tdYp7S89jz3gBbfZI6W6p3CIVEGIHReEqaK8TZFHKd/AKyAIKGobZq1UsMv Bt9cU4eAu9ODbU+8WPVguqZFfJdyqiLP9KJvWy/Vn1ics//4BHfzJwqMT78fwnyHBraV UsBd3qRke1+XrXsWVdeoWbpHOwQJObmnbVLjgEUR10KRNvF+KmOZIgJA4743hf2/REdd LwoBpBSIa6OEwGU5JaNR07gBpXuvBciLkIwU8Wnh6yAWHqY+LafA3jhiTc1OjVBHxP/B AH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H80W49X/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d10-20020ac85d8a000000b00403aa8095aesi726392qtx.665.2023.07.09.11.37.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:37:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H80W49X/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAl-0008Tn-QV; Sun, 09 Jul 2023 14:30:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIZAf-0008Qk-Bs for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:09 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAd-0000uN-Nt for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:30:09 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbf7fbe722so43507045e9.3 for ; Sun, 09 Jul 2023 11:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927406; x=1691519406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KPSt9c/ngpAMvKxksu2NUPKStpNSLJ8TjY6ZtwR8h/Q=; b=H80W49X/1I3xQtKjgOvJJoRShUFaD5gTWN0M1aKZI9c1oRkqKWt+31VXZfFel7/nwK WSqYbHqe6TQBX8m3Nr1KDv885sY/ES2+RMD4rzJAXfBeaDN7nnSue6hNgsRQQUzTekb3 LHpId5tlj2N+hd2EfH8WrGbxuxBb1cWuOP90NjFQyxL+LsutqTaQ9fqPvTEP/RUG7pbI ZSqPJ1OX2widUV+XTGy2TBuHRbValKSqfZu3VU27pdHX8B27JF26BJ1YIfBPmkPYZD2r K7XrgkjAbgFNnOwjWtAVoSy9MxnaVjrjNsOKDIoK4SkZskx9wQumpnhYAk95lsubPkky 9ucA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927406; x=1691519406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KPSt9c/ngpAMvKxksu2NUPKStpNSLJ8TjY6ZtwR8h/Q=; b=jN5QqBuR+LYHQ9X4ku24VoRVjtVlwYhHcAgCLpNcKNVgI4xWQR/NV4cm2Ftolzju7L uJzPBohmJvYU5O7S4NW3aDqV8wfk/wYYrcNIYFDlNvR7DW/zTBBFGX9mZ7RSWTL2bsGA W0QSpi+imDt4KheFyF8rxzJ97iZaTfkC5IAwGh+FosNF1D55AdEV2m3amrxoB/5lDLTG WAtSAVwU1VeQg1APtdB/5Jgl+Bls5aPqj1dwRHOe/jco1y3SNzkgLgcKhqcvgLL+DExp PJHVd60zvjA5RjBUwtyMGWFInzDKqosd8ItODTex3npCoZnGgpGdkTOvYhpZlMnkOUPV gCBA== X-Gm-Message-State: ABy/qLYzjyhpPTva+eEHJg6S/TUDwYW3raPk3PcxiGCjXhR25nDvpCuQ JkK57Ujs591rzQacjHhaQQ4pbXE5cF1j4887L7Zmcg== X-Received: by 2002:a05:600c:207:b0:3fb:fef1:68b7 with SMTP id 7-20020a05600c020700b003fbfef168b7mr9610999wmi.27.1688927406441; Sun, 09 Jul 2023 11:30:06 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:30:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Richard W . M . Jones" Subject: [PATCH 18/45] accel/tcg: Split out cpu_exec_longjmp_cleanup Date: Sun, 9 Jul 2023 19:28:47 +0100 Message-Id: <20230709182934.309468-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Share the setjmp cleanup between cpu_exec_step_atomic and cpu_exec_setjmp. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard W.M. Jones Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index ba1890a373..31aa320513 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -526,6 +526,23 @@ static void cpu_exec_exit(CPUState *cpu) } } +static void cpu_exec_longjmp_cleanup(CPUState *cpu) +{ + /* Non-buggy compilers preserve this; assert the correct value. */ + g_assert(cpu == current_cpu); + +#ifdef CONFIG_USER_ONLY + clear_helper_retaddr(); + if (have_mmap_lock()) { + mmap_unlock(); + } +#endif + if (qemu_mutex_iothread_locked()) { + qemu_mutex_unlock_iothread(); + } + assert_no_pages_locked(); +} + void cpu_exec_step_atomic(CPUState *cpu) { CPUArchState *env = cpu->env_ptr; @@ -568,16 +585,7 @@ void cpu_exec_step_atomic(CPUState *cpu) cpu_tb_exec(cpu, tb, &tb_exit); cpu_exec_exit(cpu); } else { -#ifdef CONFIG_USER_ONLY - clear_helper_retaddr(); - if (have_mmap_lock()) { - mmap_unlock(); - } -#endif - if (qemu_mutex_iothread_locked()) { - qemu_mutex_unlock_iothread(); - } - assert_no_pages_locked(); + cpu_exec_longjmp_cleanup(cpu); } /* @@ -1023,20 +1031,7 @@ static int cpu_exec_setjmp(CPUState *cpu, SyncClocks *sc) { /* Prepare setjmp context for exception handling. */ if (unlikely(sigsetjmp(cpu->jmp_env, 0) != 0)) { - /* Non-buggy compilers preserve this; assert the correct value. */ - g_assert(cpu == current_cpu); - -#ifdef CONFIG_USER_ONLY - clear_helper_retaddr(); - if (have_mmap_lock()) { - mmap_unlock(); - } -#endif - if (qemu_mutex_iothread_locked()) { - qemu_mutex_unlock_iothread(); - } - - assert_no_pages_locked(); + cpu_exec_longjmp_cleanup(cpu); } return cpu_exec_loop(cpu, sc);