From patchwork Sat Jul 15 13:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 703232 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp157710wrt; Sat, 15 Jul 2023 06:57:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlECtbIoMBhaGJm/ajG07r4O1DkInd1RNpO0UqgAj3uDj9tFqGf0qeNarPXHm0YoUKz93aDx X-Received: by 2002:ac8:5c92:0:b0:403:a808:2f50 with SMTP id r18-20020ac85c92000000b00403a8082f50mr8232629qta.31.1689429421587; Sat, 15 Jul 2023 06:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689429421; cv=none; d=google.com; s=arc-20160816; b=ThjlkhJ9xwxBPfNiv7R1PVENir8UtJWG4UwpRuoyahIKmKutqI8LVEvEiIFPNHzI1V /Tb1V3twVbbufJchjC4BeK14BbGMH6ODDudwdhr90g+firoFQ5fcKsUevMkPtDLLGNnE Tcm7Wn7uyHgC3pexl0syHvL14THrmNGXwzhNnLWln/FuqfmgHgfwBBI/FWBC2LTwCLTW F9rsBCmve//QkTPAnr2v35A/w2GsB90KXG/ptkSlCTnkBmCWsU4+E8Z/LksoVRfniSYl 6LlTH0VxxS6s5qpaCDRYOFzvpKrOTVo3maZWEc5KQwR58gEBXZmWbusikriZm5kOhwQa IIjA== 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=1Ld5JXWWMVhI493r8gVAwNahLwugINmk0SiqRP6Iy3A=; b=QMeUfK4KPk3f0Qsn/L2FqrCYRxqYFZVNSnx5EZWngzk9xfHPYBj+rj8dNxP9r/lGre DXnp85yZnbrZiB00nIcrK+FlpOs4l/FIQ6pYctzVGBeBx8mvk/gzJ8qA5fFnSHxksvws wq+EDfOUoWJT34DvaBr2meo8AakIN8/wEWUr2+CdrFLnsnsRzT47w2I0eGgN0AErx3+9 VYYRMLyYdxSg1ozZ972XoKRyYPppK1eD/T/r29oKM4L6vuz0f2qbzIfJ2lml/nFkCO5k AGN2QePT/ovvqRgGjw3NruT3QQowOGJfokPO37Z36lNEHp7+k1Yny08z5ZFkkxcTb0ii oyAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SXRp5ip1; 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 k5-20020ac85fc5000000b003ef3d74694esi5908043qta.34.2023.07.15.06.57.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jul 2023 06:57:01 -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=SXRp5ip1; 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 1qKfjd-0006Rz-V8; Sat, 15 Jul 2023 09:54:58 -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 1qKfiN-00045M-I6 for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:40 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKfiK-0001Gs-Pa for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:39 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3094910b150so3067963f8f.0 for ; Sat, 15 Jul 2023 06:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689429214; x=1692021214; 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=SXRp5ip1qgGnb2AYrM50ZLVsfXoYjtYlbeA+FLdZB1Ek9gWdhuvoxpDD4lqY5GOM7S jx8qVgun/qW1/hEIGWK45CtgUNymy8iOEypJFydySVeSyvlOv6gzgmp+pg1LtpyfZu0T 8hnX09zPnGMpcKvS9U5wua/VnhOX6nxRvH6CiYcbYXObxyLhifvnR+hNHFZ0MIUtav3/ k9HXxQRSVNflrTh3dVfGBmkbOB6xDQTqBNGMH7SXBc8m7BWBF1oLpU+P+bbmI/hc8adw LU18hEp5f4j/dPcw6lo+VE1NEXQVYs+xJQNoMDlVRJChEwkZ4xEBV6St/UxitPtUvu7t FvWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689429214; x=1692021214; 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=O9Bk8lw/piKM9pTL9iHW2NZgB9hv0PD5hFH9bDRSMBwvN0nrttwz/DYtsNtPjm+uCR i8gsF76st+bOr5Qd8mI5+tIiwhnRct26QOji0uVsDH0721EqLGiyfx3AxOBAbxbtYtav Y/MWbli7pbgmbw44ojusCZeX0JBaRAwmKIPq5gay66bJvFl13bBn+bVf5sVBeHWWC+g4 ZOBlSgktJ7el76D/x1TRbDtz320wHw/gQswdMYIDlpdZvj/eyO12GJIb11iMYq2kB00p Ul4qc/y+p7RK+5ixxyvnQDaPH+uHqU8vTN2NaITumRGhuyjJn3bbqgL1VZxi+5A6vSqm 7oSQ== X-Gm-Message-State: ABy/qLbV7gFYSEK935SC7qG+tQNWOtYcFx2hJnMZfsPDiQl5gdP8M8uj 0je2aAZ1da0MnR7rBvgOu9y7tFKrECxnlrh5rtlnOQ== X-Received: by 2002:a5d:4bd1:0:b0:315:a74c:f627 with SMTP id l17-20020a5d4bd1000000b00315a74cf627mr6938552wrt.16.1689429214383; Sat, 15 Jul 2023 06:53:34 -0700 (PDT) Received: from stoup.lan ([51.219.12.49]) by smtp.gmail.com with ESMTPSA id k10-20020a5d66ca000000b00313f9085119sm13838014wrw.113.2023.07.15.06.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 06:53:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , "Richard W . M . Jones" Subject: [PULL 18/47] accel/tcg: Split out cpu_exec_longjmp_cleanup Date: Sat, 15 Jul 2023 14:52:48 +0100 Message-Id: <20230715135317.7219-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715135317.7219-1-richard.henderson@linaro.org> References: <20230715135317.7219-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.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);