From patchwork Sun Apr 28 22:14:30 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: 792920 Delivered-To: patch@linaro.org Received: by 2002:adf:cc13:0:b0:346:15ad:a2a with SMTP id x19csp1423461wrh; Sun, 28 Apr 2024 15:16:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVxU6Ly1cslmokbhG4u1QIJFUa5rISXRqJMq+x7hi4AFO7FEghuBr3BdDf9s7T35918g6kcc8aXsoIBrCXxaJme X-Google-Smtp-Source: AGHT+IFAoj+5w+MWGXwmLVp/ib6LMHWo2Bs8uP6cCg6zK58QDdnDK/EKBHFwHzgf16tgnOdnIQLn X-Received: by 2002:a05:6214:c67:b0:6a0:ca29:1954 with SMTP id t7-20020a0562140c6700b006a0ca291954mr2774220qvj.46.1714342561639; Sun, 28 Apr 2024 15:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714342561; cv=none; d=google.com; s=arc-20160816; b=wo3xMr9AT41G1HCVFXr8tH2Ap3JEM4P8axhkSPgcweyZa27MWSENMqqLDoyhYMVeYt Faqj8Xa1vez2TRZ4aVplMz/vhHYk8LrXwMnPBhBIXvjoaZoDL5Sz7f0O6356z4xRlv5s 4Pdt0OazcHSCSPJkBL/LlzpAXQgVZZijY8Lbv0tAXrBtGLi3xzfdD8Vkcp9ZnLJSCJDO FDKztQEO17Uo2VQO6s44weNar+1yuErZdIzfgAxmVkrE+GUOCUwjFuVf6H8qtfH87hkb PULdKSMuTG7/zmvqWJT3DxQ6CwRZJDvNT15POuaOkHiwljVgIrxzXpYsDGlEM5WyOED5 FSSQ== 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=X+LV9oUMRwRHrcXmsm53k8GPuSzrV4FPRLpNCNB4qFc=; fh=+kTJNlX4d/Ktp/5WO5d77IkVGYcQ7tiev+NqB54rN/Q=; b=LrAXtWbS2o0H0KjsNHPrPEre75M17YSCv0v8AsPQvJn9GfeB0oGWknVbHT0Q0aC6Xk XFR4OQmtfvMhZ2n2keaTb9Vo8qzZzkESpx509EtiX6hOUau+YqXG+T6BOkwjXtDwsmif UcrUUQMBmR0VfZG6lTLlZ3k1nStN0esj870LkYtbkGM2mgXu7h7Ye8PVSWzlaXMfksV+ YNj7DkdQL6JCqAB7oCXTw5gSBXpU9tJXDwLGrDOKS3s7FWOALDjrT9y0jPqOsoVwCTnC sAc6KcW0o1MH0fTcAWF5xRmQSZuTmFDW6L84YKG63ymsJhxgB0pjQiIHLFDI+Ljq2JVP KEGQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yW7nXVE9; 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 f14-20020a0562141d2e00b006a0cd99b70fsi1418402qvd.325.2024.04.28.15.16.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Apr 2024 15:16: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=yW7nXVE9; 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 1s1Cnq-0005w0-I3; Sun, 28 Apr 2024 18:15:22 -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 1s1Cnm-0005uj-TI for qemu-devel@nongnu.org; Sun, 28 Apr 2024 18:15:18 -0400 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1Cnl-0005V5-5N for qemu-devel@nongnu.org; Sun, 28 Apr 2024 18:15:18 -0400 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-51dc5c0ffdbso263357e87.2 for ; Sun, 28 Apr 2024 15:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714342515; x=1714947315; 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=X+LV9oUMRwRHrcXmsm53k8GPuSzrV4FPRLpNCNB4qFc=; b=yW7nXVE9UMSNgdIQVYPeILGvKoPj0qqrAemeG/1sGD3dGCVxwk67N82wuHNfZB4yoh euAdsB+ptQGSUeNv04Dft729nhIkch2IwAlTf6ZfJf1wZOGCerRP04ey2oEWNZpAVHK9 G+uepxaQ6qlfr84u1KM8dSrfmaU1Jl0UOxLlryZlqItkYDlP2GYSMUdqaDs7hOLKd4Qr 2pamaXiCP5QAAlymKeDHauXFneqAMjWt/2P4QjiVqWcOFGMRG/xrxXEzGPa5MGmW5ho6 +as35t2gDImrhAbjzI9aCuuRzvNztgKgxv4D9SaycyEze9qSf+0pFZQepLphuwzkY5RH jQkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714342515; x=1714947315; 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=X+LV9oUMRwRHrcXmsm53k8GPuSzrV4FPRLpNCNB4qFc=; b=rZJ2nPcPxeVjXDx1YuBe+exWghG4UjGiP3DiStrQiC7h4p5wToWRMRkjhczUjY1BI8 R+CWLPm5X87Oc8ya2UHv1SvrO3fpJ8dD7tTMCmgjRIPxx1fI4WzhZ4wVM6MZTINl3Bve wWFc3zupFcg1FsfuxjQMGrSD+d09XG1dFfr/t3HHBWtwOPpld5ZgLlCEjVohE6N2D96L qKWk5dE2o/QCR/+VG/JNvoNQiEc8tBez4ufzbNVjNQDukpmzVhRWfW7tpgyBetilRoIh 49uP2VGclF6nhgEAi4sQUfCz1Nz/+0KbNymfp9YHggvGEOMl8faCcEcvuipMVb51UF6+ J7aA== X-Gm-Message-State: AOJu0Yyu1TygjS7zICoFTjtYisumDvXL7A1TwRcyaxPJQoAS7Li5VX7g ItH1NiqP8vQhsTIPIGktYvJDJK7ScI2Bw+alFliZ8kEk0YxNicSJ6MKbkCgIBEi5VzVJIGmhy9v D X-Received: by 2002:a05:6512:130c:b0:51d:3fe4:c3cc with SMTP id x12-20020a056512130c00b0051d3fe4c3ccmr2919256lfu.0.1714342514869; Sun, 28 Apr 2024 15:15:14 -0700 (PDT) Received: from m1x-phil.lan ([176.176.142.130]) by smtp.gmail.com with ESMTPSA id eb16-20020a170907281000b00a58764e6c45sm7413730ejc.173.2024.04.28.15.15.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 28 Apr 2024 15:15:14 -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 04/24] accel/tcg: Duplicate cpu_exit() for user / system Date: Mon, 29 Apr 2024 00:14:30 +0200 Message-ID: <20240428221450.26460-5-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::131; envelope-from=philmd@linaro.org; helo=mail-lf1-x131.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 We will introduce a per-accelerator vCPU exit() handler for system emulation. Duplicate cpu_exit() because the handler won't be accessible from user emulation. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/tcg/user-exec.c | 8 ++++++++ hw/core/cpu-common.c | 8 -------- system/cpus.c | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index f49435df9d..404d8a145c 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -46,6 +46,14 @@ void cpu_interrupt(CPUState *cpu, int mask) qatomic_set(&cpu->neg.icount_decr.u16.high, -1); } +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); +} + /* * Adjust the pc to pass to cpu_restore_state; return the memop type. */ diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 9b3efba82f..cbafc79033 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -78,14 +78,6 @@ void cpu_reset_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); -} - static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { return 0; diff --git a/system/cpus.c b/system/cpus.c index 68d161d96b..e0530ad603 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -419,6 +419,14 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) do_run_on_cpu(cpu, func, data, &bql); } +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); +} + static void qemu_cpu_stop(CPUState *cpu, bool exit) { g_assert(qemu_cpu_is_self(cpu));