From patchwork Sun Apr 28 22:14:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 792927 Delivered-To: patch@linaro.org Received: by 2002:adf:cc13:0:b0:346:15ad:a2a with SMTP id x19csp1423603wrh; Sun, 28 Apr 2024 15:16:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW587NQQN+Rp7jqyDFdynNp6xyGItLsHPpR4qRD9crG8rBazK7NsYrSk2enK/Xf0ykWnAZN02nbx4Moby3EyylZ X-Google-Smtp-Source: AGHT+IFJcd/TUZUtLzAa9qpBP6h2m6CvxTSs9JP/1dF0pbT4olaAP3jc9svGKEGTbMZPbFp1GogI X-Received: by 2002:a05:6808:1a95:b0:3c8:4d1c:1a04 with SMTP id bm21-20020a0568081a9500b003c84d1c1a04mr10408964oib.23.1714342592312; Sun, 28 Apr 2024 15:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714342592; cv=none; d=google.com; s=arc-20160816; b=OpedI+2wkVjbYkO916mtTxNmXwnkL88BOLR+BJPFVhewN/H8FtO5KMVVzJANlBsGo5 tWUy6Jn1XqhK4+tKLdsXqSROvNsqZCKaTWl3VMr0m7YUXw/PSncs0nHHbzIREtxgM7b5 t6Gtfe15q5fWhTYZvhRlpizIdbAFfdUjlof43Alo0BseDu3+MUmTQQldcJPWkyZ0bZ1A dl00uSDhe1hF0nWmGQ0uE5T+T5Cg/0gh1BcyVSwaPPd7xpVUd1RUFG3oponJEGYH5Mc2 s4ABH6M3ZKbMrQJrdmZ7/sHRKn0D5A6EQ6PM5z3e8bvic0y5sM9tJQRYqFDcPSvAAkmv AtFA== 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=8v4uzifmPKK2kwYtF4RlyiCCqgElOLg1I89Ov9YYN+0=; fh=+kTJNlX4d/Ktp/5WO5d77IkVGYcQ7tiev+NqB54rN/Q=; b=nf2UM4+uZ32R7pohhRGRk0FMXO6nhnEw2m/feVFJfWMy5Hb1pvsVV2fvEtpXzrZKOi Vj/NF9oB47/zgB+YmKX8hICMXRmNYQycQeND+3ud9bEXjRvTfFvELuariZdrON2QcEnd c2nZ6bMZnpt7Rm5pA3GVNIkQkUnJdRiUMwIltSiwNMs4sFJ8EvR+mcOsK6OOVZmam36k amEb7gMaItBIFOhNOiUV4RvPUEfryfB/Xr+Hk+j7JTR8eRumYEO+345YiQjBNxe4DAg/ AuyTfHz7agXJj7n8n6Dk96aOWriT8nrRWAGZxhoTbHjKYCxdDWjIR5mfF2IJsbp07UxV eOMg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C2cmvPTu; 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 jf13-20020a0562142a4d00b0069b1cd7d957si24752395qvb.120.2024.04.28.15.16.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Apr 2024 15:16:32 -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=C2cmvPTu; 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 1s1Cnt-0005zT-7A; Sun, 28 Apr 2024 18:15:25 -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 1s1Cnr-0005wN-Gm for qemu-devel@nongnu.org; Sun, 28 Apr 2024 18:15:23 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1Cnp-0005WY-SB for qemu-devel@nongnu.org; Sun, 28 Apr 2024 18:15:23 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-572229f196cso3881194a12.2 for ; Sun, 28 Apr 2024 15:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714342520; x=1714947320; darn=nongnu.org; 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=8v4uzifmPKK2kwYtF4RlyiCCqgElOLg1I89Ov9YYN+0=; b=C2cmvPTuRfq81zmyBIQduUjo+HBntyMzxFZsmZGgd1qrfKayaLxLsJiG1H1WzO3twq QDpPewKItEjMzok8lKjhnuIt3o7yyCv5aYtSgDF2EC6WZ4+nS1ULIpLcSt32+uzwWZq3 jyR5vvfv+jie8Wwzghenws4FrZvQtmkPafxQFVPKOccwqUkEaH1FS6kdE5Nkg8tjYLi1 yPO2s9WW8dDDBN4VnLxITxL4zhOKhU+/39x4bzkpCZ7PyozgY50mcuhI6I/iCHGhb41g qneyNpVXRAH7bSHblwdBfStI16f3OGGUOEP7mdK1dYYf7FPzmOR98Y17tBCh0bs452eR lN2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714342520; x=1714947320; 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=8v4uzifmPKK2kwYtF4RlyiCCqgElOLg1I89Ov9YYN+0=; b=UdXJQ/g8Xxjo7NOVNKF6lnMpUPQ0BPW9jo6LB9Br8AMrOtLnpSy4p6eW6MphEonc56 0K6gwX6VhhRFLCpQ7bQQqPLeb2WbSP6nONaJl0G1a6DYHSj/7SqDWlZuyGgtB0lWi6TL SOaBFspPFaFrQGzZurUOZiWCWLGeOtEkNnp0f4doyMbvzXI/fOUhe0fjOpGesmmsQQP1 PvYbhsT2nBhqckmXyeHIfB/iISSc7OYqJqxyP396JeCNU38cOWMmGfjNrRF3+N5d/s6B 0UwBBTFQz3NiHienAeRJ086d9qbHOpX4wNxSLERSxh1Gas6RNU/OWHNxBMtcIFVpp0G6 UyuQ== X-Gm-Message-State: AOJu0Yws1rDAaVZLcx8P1vCbc+v69GgznIQWYSS9bxRHWsBG/PXMboGR dIlwKgxa8e0bcCXjG1xzF8sdHOTOIfU2f4J6pPMQmEj9N5dAebBScrZjc0jj8m0SNN/+RwoTepy A X-Received: by 2002:a50:f68f:0:b0:571:be31:500b with SMTP id d15-20020a50f68f000000b00571be31500bmr5553084edn.25.1714342520316; Sun, 28 Apr 2024 15:15:20 -0700 (PDT) Received: from m1x-phil.lan ([176.176.142.130]) by smtp.gmail.com with ESMTPSA id fg4-20020a056402548400b005727e798b5bsm759122edb.63.2024.04.28.15.15.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 28 Apr 2024 15:15:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Anton Johansson , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH 05/24] accel/tcg: Extract tcg_cpu_exit() from cpu_exit() Date: Mon, 29 Apr 2024 00:14:31 +0200 Message-ID: <20240428221450.26460-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240428221450.26460-1-philmd@linaro.org> References: <20240428221450.26460-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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 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 Extract tcg_cpu_exit() from the user cpu_exit() implementation. In few commits we will re-use it in the system one (via a per-accel handler). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/tcg/internal-common.h | 2 ++ accel/tcg/translate-all.c | 7 +++++++ accel/tcg/user-exec.c | 4 +--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h index ead53cb8a5..df317e7496 100644 --- a/accel/tcg/internal-common.h +++ b/accel/tcg/internal-common.h @@ -24,4 +24,6 @@ static inline bool cpu_in_serial_context(CPUState *cs) return !tcg_cflags_has(cs, CF_PARALLEL) || cpu_in_exclusive_context(cs); } +void tcg_cpu_exit(CPUState *cpu); + #endif diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index fdf6d8ac19..b67adce20e 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -663,3 +663,10 @@ void tcg_flush_jmp_cache(CPUState *cpu) qatomic_set(&jc->array[i].tb, NULL); } } + +void tcg_cpu_exit(CPUState *cpu) +{ + /* Ensure cpu_exec will see the exit request after TCG has exited. */ + smp_wmb(); + qatomic_set(&cpu->neg.icount_decr.u16.high, -1); +} diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 404d8a145c..d7e5f00c97 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -49,9 +49,7 @@ void cpu_interrupt(CPUState *cpu, int mask) void cpu_exit(CPUState *cpu) { qatomic_set(&cpu->exit_request, 1); - /* Ensure cpu_exec will see the exit request after TCG has exited. */ - smp_wmb(); - qatomic_set(&cpu->neg.icount_decr.u16.high, -1); + tcg_cpu_exit(cpu); } /*