From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756567629; cv=none; d=zohomail.com; s=zohoarc; b=WTchSMxpyqveXOTkYzx+LVXfGWcpV2fiY00nC1RyNc25/K9bkT3hpLCbM0u0NzrwQYxWUV4FVgVCDyJjdxsh6jpAjzF5qCPoj2pOjUrmMbxnYp5v0OaF4BzbkpcZ2qq8fHZrVzdWokxtUxse4BqnkK5FECclINrLMXmA35j1zVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756567629; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WL2tlaGqHqkD6S6Lrl1Huap2Hah7Qy/PDV3OtD7Ozd0=; b=KQJsARtsjz81rd1+8qsWiuuPClzG7uxf1Hcm/bYMda9DSjW4MNs4O+DMylVpbiY7lN5iBdCNjgK3M6Aa3N1ZqoAJuLgT4pkcMZgb/NS7Rxr0H5EhcmcMDa3tkodkxHyMRzUAteQdt3oBCVDraYSin1abqoHlsnP+Xx/JOASMFJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756567629315531.8433121729383; Sat, 30 Aug 2025 08:27:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNNz-0002iW-32; Sat, 30 Aug 2025 11:21:01 -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 1us12b-00010U-Hj for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us12Z-0008Qy-Cn for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:25 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-FIbNW-z3PHi8XV3uqgFd5w-1; Fri, 29 Aug 2025 11:29:20 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3d1114879a4so332846f8f.0 for ; Fri, 29 Aug 2025 08:29:20 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf34493bbbsm3759778f8f.60.2025.08.29.08.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WL2tlaGqHqkD6S6Lrl1Huap2Hah7Qy/PDV3OtD7Ozd0=; b=WsrOd7bercMFepr4VkZOvxbBv9MqPSyMIJBi8yRtb3QLKEeA0ysaWRB03Vrjp4l+2PeGkg Bx3gZFxvwGjL8siRcv/bO3JcM0B0mDBT8jyzL6L+kuTV86PJSHwqxjRAnOEMDi6NUIjjvl u222EhUmhHwn57aJ9LKPVU44MD7rb88= X-MC-Unique: FIbNW-z3PHi8XV3uqgFd5w-1 X-Mimecast-MFC-AGG-ID: FIbNW-z3PHi8XV3uqgFd5w_1756481359 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481358; x=1757086158; 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=WL2tlaGqHqkD6S6Lrl1Huap2Hah7Qy/PDV3OtD7Ozd0=; b=nNO2jWl196g8tnpVUMgFC/X+5nCXQJSDNVovhd0QdNJwgD5HJsfxuaXerJ9yw8zJHV YjshfNtd/5FC9S24rOOEgdo3WQGzmcwsXL1jSrfnxLmCww9FmdC2czOTQMW2mDuTdLAv mY39JnBbngA7ReDX+j+j/kM5ALdmYCHTEbENV/QVpt3BSbNjOd7OskkhuklYdS+oCID5 u59DeJNfwROym/LHUJ/72OrYjgVX/PsGnkmLbv9BpQOtYeYR032e92cJVbCAQy8Bf4YB i+inzgVuhc+f/KST6yzC2L6c4pCUAm21sFJE6N6o+YtcKEH4MPzFe4DCyNxY8Qh16sgC ZovA== X-Gm-Message-State: AOJu0YycUGMrINYpXy1Th7mE3k89AinRoA+KbDvpUltUBgNAk00yVOQc CP07NDzEbov5bwbPWOf2pq54g+k76ROSvKZ0NzL+iuqgF3mi2efBZRqoscn+8KskDiKbwt/HjGF 3CByZbvpj80AkhlmV3T8VuNgGZpYsQTs3aaFX7+69hbmZtYYWc8bwkOaIFV7/QPAmMFrfVtBdYs pSh0Gkk/SRce3rPjKaMmTvfYMJVLTRVYKi8OPcZVpG X-Gm-Gg: ASbGncsebunatwK2Zj+MwRjO93OEZHiMdsqZoVjQX+5ICwowTSv3888s5Q2skm7RLxP jwjz2U/y7WVqLMGAkDKGRv0ikYP5cZRF8AI0uqOajCQzXcoXBdaSq/LFEeGFlkCBl/om1iVXhPv 3V14jBMv77SIkC2ZnPlsP0+fQaEgrQ4Q+vkagd3JmdGlN6S4uiX6qup9YlgnDkPaBrp+qgQILkD eITjWOftcyh+nCIQ3HkYCRyxuA4sbHFZuZNixdBuSkxGM2JLcV16SZgSF2oB2PVGrNdIzHjp+jC EV2dH8ZqGkuQepXPuPkU32IKdMPozm3/ud6V/sQAcKYBi5KYj597SDP0lJBx5vrtPSLDXqCaNfM tZuQbkQuKOCceQybdv6kv28VhOaQZ69tPX3H0yRDkJq0= X-Received: by 2002:a05:6000:1250:b0:3d0:bec0:6c38 with SMTP id ffacd0b85a97d-3d0bec06f6emr1724579f8f.46.1756481358038; Fri, 29 Aug 2025 08:29:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfR9ms83Q1p2WDefcpnExj5uUYceOM+YZGUoQOIO+f9yXDH8ZhdO2n0HppNIvPMJM5Avpkmg== X-Received: by 2002:a05:6000:1250:b0:3d0:bec0:6c38 with SMTP id ffacd0b85a97d-3d0bec06f6emr1724560f8f.46.1756481357617; Fri, 29 Aug 2025 08:29:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 01/18] target/ppc: limit cpu_interrupt_exittb to system emulation Date: Fri, 29 Aug 2025 17:28:52 +0200 Message-ID: <20250829152909.1589668-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756567631213116600 Content-Type: text/plain; charset="utf-8" It is not used by user-mode emulation and is the only caller of cpu_interrupt() in qemu-ppc* binaries. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- target/ppc/helper_regs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 7e5726871e5..5f217397490 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -274,6 +274,7 @@ TCGTBCPUState ppc_get_tb_cpu_state(CPUState *cs) return (TCGTBCPUState){ .pc =3D env->nip, .flags =3D hflags_current }; } =20 +#ifndef CONFIG_USER_ONLY void cpu_interrupt_exittb(CPUState *cs) { /* @@ -285,6 +286,7 @@ void cpu_interrupt_exittb(CPUState *cs) cpu_interrupt(cs, CPU_INTERRUPT_EXITTB); } } +#endif =20 int hreg_store_msr(CPUPPCState *env, target_ulong value, int alter_hv) { --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756571529; cv=none; d=zohomail.com; s=zohoarc; b=Bmap1mIEuSh3kelpI35gpmzCbjM93nsAtErlX89flTh+y+mUGlPGkL0SoL+4cbyFMInuIVSfsq3rMf3D1L25gNMY0UO8NiUG8X4kwOJLcuUBEoHblAa0U3SvxH+6XMN6dQdBa3VK5Wqlkdb1hIUIQtCPRBkyzF8QJ4Oxo3ugEHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756571529; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NNgAOjWCs/5x+du4tWhOWwrW1a6LaRDy8OpJh3GRStE=; b=eT8WyEqK+y4K3p1OMu4BfYXSqRA/mm4YTM/7ntom5GQB7U9s2DPhmEuP5UaYh/X/e1O3FeBvdTTrP8S6xQbcZ8UVHYprSw0VpkSeRkZbNNrHWiGwk98b72VAn37EXp9kQJ9v16eZzRcCIepqSw7adh/qMBT/h896nvxyE9elKC4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756571529247895.8373597074482; Sat, 30 Aug 2025 09:32:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOO-00034P-Kl; Sat, 30 Aug 2025 11:21: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 1us12i-00013K-UX for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us12g-0008Ru-FW for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:32 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-hN_7PpLwOaGt1mVKtQTrgw-1; Fri, 29 Aug 2025 11:29:26 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3c85ac51732so917708f8f.2 for ; Fri, 29 Aug 2025 08:29:26 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f3098c7sm123637345e9.15.2025.08.29.08.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNgAOjWCs/5x+du4tWhOWwrW1a6LaRDy8OpJh3GRStE=; b=Jn80kLwF5Zb7mocgauCAlqbG+J4zTR8ljujPbzR29Gv22zdSA7qq2DaVxoYh3wla3C0GXu LzuLXe/aF56PGL+QaAmlRptLp6m30qrTJ3sptZRSnxAvqS4tQEXs1s7lWM2CgBxCIQn52o hOh2XFL5xz2g1x0Z2SLNRbrqAozIY5k= X-MC-Unique: hN_7PpLwOaGt1mVKtQTrgw-1 X-Mimecast-MFC-AGG-ID: hN_7PpLwOaGt1mVKtQTrgw_1756481365 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481363; x=1757086163; 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=NNgAOjWCs/5x+du4tWhOWwrW1a6LaRDy8OpJh3GRStE=; b=qmwLIfqkvsYXMjgDhW92xWee/bUhyNPte3ot9ZDUVwNtVGTkM3s9ER5w8xBvPlhSnw WOlWzTK6fPOUhoGM53di/Waj8RZfQdUT6E4XuEL2Dg18YPp6SsLAAyKEQf+BmAWJm0nA dQNFmoW4UbUHTQgEQvurmtnyxE5BoWn08hOL8pbNjU1T9OEEgvsls8L3R9jvu1Qo3FDO ZKjgyLmyeMuWYCsWoGLo71V6vVi3+ySKpP4t+GsbaWx+FS9xd4LZN8vDpj6zg0L56xip Oz6I618sWuUB8Rv+LlcQ2UdavesXZ963hf87nRd6gEBM/EUW9D0I2HvT08VbJoPjnr2Q 2MdA== X-Gm-Message-State: AOJu0YymyHMiJbvGC/g8uF1ZVmH8JggVYGvA0XQXU2/3wHdQ6/z+Z1Hi 5ZsHGuVn0FAPgft+PzdPpNGglUPLecOu9ZtDJATILjvZQx1P1xybBqNbtI7nsXg7/tDfWW4etTo AUpyBVC7Q2Rax8cIIfJH9ffow57yS1Um7crA6BSRQAe2cQk4dftVtRHgWaCCr92Fgk8TgKVhycr ESdur27rt++maA4o7QMk/n8hGRj1PJwITuD2NDBAHp X-Gm-Gg: ASbGnctw0ok64aIKV+lYdQ2TRIBLPRj46+8rhkJSPai7j1Di0oLNaOI9ebIw7FUXtP+ PPzfaov46EB11GUfcYNmOmzZgZy4BSzT4xvB7Wscw5jxxPtbh7Y13h6MWg1Tb8p55M2qVHSyaP5 T2r8lToiGXrCAKTIO/xFI9OdCpzIgjYl7DeFmTVUncZ20SJqn3Hs/Fx1XEkdSwGmdjOUQXt6CTp odC3qG3EKcl6Jh5fZ63rOAfNKywDFyxZTxuHmJo8tMPowOpDoLjLBOFYxAc9RzwWHOasuLmzCu8 Zo9IxZruZuBuNg6xhHpNxGfS/kImj8HEXlLv9GSgu9KqdSsgULooUnBPykAlOo3vbhyhYCb+i9C TTtIaFkzd75S2ylvT6T9v2P7D3evbHQoApw5EupW4fD0= X-Received: by 2002:a05:6000:4011:b0:3d0:bec0:6c35 with SMTP id ffacd0b85a97d-3d0bec06f52mr1855122f8f.34.1756481363410; Fri, 29 Aug 2025 08:29:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsg7XggQRabDkBwXlftYGPaVsm/2wzNVNViFlNDAwMtSIvJZzTuK7JbJKqlaBcHW43n+jmJg== X-Received: by 2002:a05:6000:4011:b0:3d0:bec0:6c35 with SMTP id ffacd0b85a97d-3d0bec06f52mr1855103f8f.34.1756481362963; Fri, 29 Aug 2025 08:29:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 02/18] target/sparc: limit cpu_check_irqs to system emulation Date: Fri, 29 Aug 2025 17:28:53 +0200 Message-ID: <20250829152909.1589668-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756571529934116600 Content-Type: text/plain; charset="utf-8" It is not used by user-mode emulation and is the only caller of cpu_interrupt() in qemu-sparc* binaries. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/sparc/int32_helper.c | 2 ++ target/sparc/int64_helper.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 39db4ffa70a..fdcaa0a578b 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -65,6 +65,7 @@ static const char *excp_name_str(int32_t exception_index) return excp_names[exception_index]; } =20 +#if !defined(CONFIG_USER_ONLY) void cpu_check_irqs(CPUSPARCState *env) { CPUState *cs; @@ -96,6 +97,7 @@ void cpu_check_irqs(CPUSPARCState *env) cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } } +#endif =20 void sparc_cpu_do_interrupt(CPUState *cs) { diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 49e4e51c6dc..23adda4cad7 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -62,6 +62,7 @@ static const char * const excp_names[0x80] =3D { }; #endif =20 +#if !defined(CONFIG_USER_ONLY) void cpu_check_irqs(CPUSPARCState *env) { CPUState *cs; @@ -127,6 +128,7 @@ void cpu_check_irqs(CPUSPARCState *env) cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } } +#endif =20 void sparc_cpu_do_interrupt(CPUState *cs) { --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756568762; cv=none; d=zohomail.com; s=zohoarc; b=LwbkiNKBOCGM8OHaqjrBjX7ZZrW88lElPaYRrHEJbyArgkj1CJhzgRUHHWpvTN7/38ChJLgIWZyM9bUlgfWpwJdxBceh7u8M7QrBn6rG6q2MKbNN5MWGxGesZl8Mwcga81NWi39NAlMSl9B5ZPNxT5kPgYP/72vETYI2bBWd9B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756568762; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mlTIbJwiIwq0If++9g+C1KJj+kHFMOoHzQVRSslQuLU=; b=bbzWTeNXbYD3mwghhhk4ZjyX0H6Lat1RVRdUyyUk1r1FF4VWFz+0d0b4an+0eKjVnn7fNjU+TCXrlYb1SU6lT9/yPZQQXsW4L+ZTcu1iEICh4Rb0e3hgmsWdFMJZ4lW5CxK8hahyq4USmVWDg8HoHFKa1zQ31TY24etRopz+JqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756568762231407.371908510763; Sat, 30 Aug 2025 08:46:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOU-0003XT-Aa; Sat, 30 Aug 2025 11:21:30 -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 1us12o-00015N-J4 for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us12m-0008T8-S5 for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:38 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-gaoRWRLiNxmk-GknoSfO1w-1; Fri, 29 Aug 2025 11:29:34 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45a1b05d31cso11192395e9.1 for ; Fri, 29 Aug 2025 08:29:34 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf276c751esm3737041f8f.16.2025.08.29.08.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mlTIbJwiIwq0If++9g+C1KJj+kHFMOoHzQVRSslQuLU=; b=AGDPi8PrA+KeNH8RopmXKW0ltZs/yt7wywJ4PCa885Wa5cRBlAQMeZehT7cE+nl5LwP3E/ 2P3/QtwXxAj9KLN9ZISUuNZVNKyy7Kqo1I5CFgX+W1uY2DDzW+F4lK40dCjag9/GKmO9vl BIVXS8waKLOARfUzLq1rkorpKJNKQMQ= X-MC-Unique: gaoRWRLiNxmk-GknoSfO1w-1 X-Mimecast-MFC-AGG-ID: gaoRWRLiNxmk-GknoSfO1w_1756481373 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481368; x=1757086168; 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=mlTIbJwiIwq0If++9g+C1KJj+kHFMOoHzQVRSslQuLU=; b=v/S/QdX29DDZCXKHk3iMvGSqpeO238bMAy2FWS009EB5EXaehLO2ADYcpyk0Qn20LG sDWZvHWCS6ofLDeTEmJR6/fzfgf4CqNRKcJvMXCSs2Ikj+RVuJAGa5itvP5Jcn0AnHGP 1Ckw04ST0aq1cpZ5UHie8R+giNMZEqKoUlj4JYOymWQL7h7SeixsZI7ZllYto1u54uoA Rnp+VfsDkGVLJIAcf3yn1mgjt4vGV4yKBkrLpQkGfDimYfVMhFFcxLd3eV7kdsAZM9nr Ts6WCoaymRJctZRyhnrkcx3Z736HmX1Ml7p1iOZ1yN9pxBzthAwS3zLJxg7Y1Bc9LR4y UANQ== X-Gm-Message-State: AOJu0YyQQmnLtfb0i3lMRPNoLzHbzFqhH+jCx5NtuOGDvAHEr8NctyNf qP64jSy7Rovh7PdKW4DkfDkUy6BwRSWNMfpo/0wlzK/+n2s28DZRELcGcoUxmMO5yP9/uqm0TpE 1MWz0w8c2QJxRadq61AEz0hmzzt3cG86m5lq+d1hk+5A7TO07DgfS5vOljTJExCtdeCJ9wbICtg 2z323RC0Ht2FLIF/jt4/tfeKmAguL1ljQjN31LIexS X-Gm-Gg: ASbGncuoH1EHf8Ugnp5Yo/y52mFR1epOYM/mC4nQVewJcq6/CjMhandStzdRD6IQb4f Xz7LVkrRCISEg81i/2OIGX8COnqzj1RjCDJt+xhkdCc3AVVZg+TSgNgqh8Kn3maNnjgQeVjusyg 4jkIb3b3h1rOD9in98ylxWiHt2ABv6YXvcWjO9yyQs2Mkmfk7iqWCZK7Kds6bX+v9WZ71vLVgb4 nFZggNOvsVAYSZVjK3dfFFyrxwY8l/vjOtZ4RVMCl5z7A0ksjXQ2V9wWaSkjuAvPv1Ss5z0arC1 e+1nEhrtMjm72gwgXhbPSMTqnMAbAjZz3Wgms8yF6kN6hth3aCH2iZJWxsL070sEaiuaP1+Qioe L0Ikg5Fsw6tddSYJ/GOqvb0Svh35ZYZwOYZ+jnc2Kz0Y= X-Received: by 2002:a05:6000:438a:b0:3cd:6477:a3c8 with SMTP id ffacd0b85a97d-3cd6486e955mr7218515f8f.16.1756481368380; Fri, 29 Aug 2025 08:29:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvE3rr0qhc74dGJjFOFc3DbS+Y0GaA97+f6HIDKn8EXjlHA9UrLMyTEUyx0b+hgpmr2NwYKw== X-Received: by 2002:a05:6000:438a:b0:3cd:6477:a3c8 with SMTP id ffacd0b85a97d-3cd6486e955mr7218496f8f.16.1756481367910; Fri, 29 Aug 2025 08:29:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 03/18] target/i386: limit a20 to system emulation Date: Fri, 29 Aug 2025 17:28:54 +0200 Message-ID: <20250829152909.1589668-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756568763061116600 Content-Type: text/plain; charset="utf-8" It is not used by user-mode emulation and is the only caller of cpu_interrupt() in qemu-i386 and qemu-x86_64. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/i386/helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/helper.c b/target/i386/helper.c index e0aaed3c4c4..651041ccfa6 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -110,6 +110,7 @@ int cpu_x86_support_mca_broadcast(CPUX86State *env) /* x86 mmu */ /* XXX: add PGE support */ =20 +#ifndef CONFIG_USER_ONLY void x86_cpu_set_a20(X86CPU *cpu, int a20_state) { CPUX86State *env =3D &cpu->env; @@ -129,6 +130,7 @@ void x86_cpu_set_a20(X86CPU *cpu, int a20_state) env->a20_mask =3D ~(1 << 20) | (a20_state << 20); } } +#endif =20 void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0) { --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756568181; cv=none; d=zohomail.com; s=zohoarc; b=KiSEeEKgcn1pFkpeXeVe1R5z0pWqdli9YyHCgJjdzgOQliP7PxeR5hy09pfhQDnMiemuGRMP7SoRGaEoXkPjB7QBUHT5fGa7Dacppl9mUL17+R7BIpgDZt7612Nju/W3yAwfA6Fozl8EbLn8UWhpD8Lr2rsvRdhwX8bVCQZCvTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756568181; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7ya48H68YOtsPuxAtupFqEFRQ5HJ4BjSVrypRr48+aM=; b=VfFuCA26KjEbN5ZF8ACDxfie27iOYbpQCLgQpy8jskPH3PpNWzd0L0sygn98WGUpcq/Qw4aTpoBkmSBylIUtdTZEKe2+IEL3URTFH+s+V4G8B4+hFhSBn7g4/yNJlPf8v+eTaEqosSBMBu96cLGIsS/k+7eHDwwK8OvzmI5vjl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756568181539645.2532227297721; Sat, 30 Aug 2025 08:36:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOS-0003QO-Qe; Sat, 30 Aug 2025 11:21:28 -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 1us12v-00017m-0I for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us12r-0008Tt-EW for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:29:44 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-mrvrJg48Miu6qobd6bpOkw-1; Fri, 29 Aug 2025 11:29:37 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45b7bb85e90so13334235e9.0 for ; Fri, 29 Aug 2025 08:29:37 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf276ccc13sm3710448f8f.22.2025.08.29.08.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ya48H68YOtsPuxAtupFqEFRQ5HJ4BjSVrypRr48+aM=; b=WnS4RJGck1NJRmcTYtkigBM6AquuLlCgDtXCX6hQV4N+37qJgQVC0NNln3/wAPx8HiZU2z ZNH7uTfdafYvdRJRlA0E5djYVMwoExhJ59PNhlRoU5IEIQ08BbNVOSSE7ZSnOItXFsGOT+ RZ+7cGhh3ech9aNpfVb7JjayaZKOoYg= X-MC-Unique: mrvrJg48Miu6qobd6bpOkw-1 X-Mimecast-MFC-AGG-ID: mrvrJg48Miu6qobd6bpOkw_1756481376 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481376; x=1757086176; 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=7ya48H68YOtsPuxAtupFqEFRQ5HJ4BjSVrypRr48+aM=; b=o3v69JMJYEUj2thp1PY46mbtT+ai3YGUbI9Y2LHOhX8lMb2iHelHkf7zMitmMKdBIs UjMOPcvyazGDet897xuNBYQsZn/M0EXjm7SFfhioRp1qR2MGC6DdAlw/LpmfGMZziSlm fWzo2eIlMHtAZ5T0kylyTaYmQK6CU8uWaVV1Qjj2WNktWWMclghkMn4KsiQeOjunNSgf QKNHUFdWQSzNfGQszuSv/2Ij3f8fT7k5R1EMoJaDat2gAOIHVrTLtVistGfavmqvhh+G +yNgOK8lxKAopGr6tDW3I1eFhRpFI/28Ufs7k+eyK1GlLV3QEdXtzqVZ8J3HAFI9GnSC Yiug== X-Gm-Message-State: AOJu0YxUjl+RyS1qboGmq4uhQYELI21/B0ZuEi27pUQwOw6aHrN9K+SM l9mkLQ9wDWas6dwog0C7N+ZTziQCXuwRIg/nT9MawQJRYOP4mQZq5onWf7i6u6zBbyHdxso4g83 JbI0TpSpKTwyrkRk1ilGhqjIa7eREfASD2OqSx/u8nCVElZmxG92CSCopvy82yCiZituAWgV171 CAmjdPFz15oK9M9e6VrC+Lc+CFj852hN6vtRdvzzMG X-Gm-Gg: ASbGncs8/NBbTjiMFVACITb1uw99z5OAeWcXY9qHAMxqJBmMeT04DGdLQKVsGmGELnC HAqQqlpAbW5zKQMPDAtBaarwN5IG1JAfkDUmpeKmkV2qo7EpeyRph47DHQHkqYaHBtqvJMvSfbm pT7VRQ99C39dHjenCRz7+lTPMrSvvxdf6AWgRuqGzz+lnGYgwNR8XeM86/QkppGiWbpu8A8vxyf wyLcoX+cXc8JqNVzBsNCpBz9NwlvDf2vAzsKjW+rb1bx/5X7EG5UgVQJLAL1IKSPSyMCr6hcCiy XyXm3Khqy1cKqXd2i+Aq64YKdZuW6ZlDaD/s9GvdtR4sJgifncrh36lyE4hGmbBvpGQ718O9MGA 9G7CVri2AgABITrrekJUkWE0TtXB4xCos3SJ2783FzvY= X-Received: by 2002:a05:600c:19ca:b0:45b:47e1:ef7b with SMTP id 5b1f17b1804b1-45b6870e3dfmr133631925e9.17.1756481375437; Fri, 29 Aug 2025 08:29:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQnIO/hBs0qNYMXq7tHycA4AMiXph3kVTLMcvmAUyZPZMZFzxL9yyGg0NgnxslJA+5d6VTcg== X-Received: by 2002:a05:600c:19ca:b0:45b:47e1:ef7b with SMTP id 5b1f17b1804b1-45b6870e3dfmr133631495e9.17.1756481374679; Fri, 29 Aug 2025 08:29:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com, Peter Maydell Subject: [PATCH 04/18] target-arm: remove uses of cpu_interrupt() for user-mode emulation Date: Fri, 29 Aug 2025 17:28:55 +0200 Message-ID: <20250829152909.1589668-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756568193030124100 Content-Type: text/plain; charset="utf-8" Arm leaves around some functions that use cpu_interrupt(), even for user-mode emulation when the code is unreachable. Pull out the system-mode implementation to a separate file, and add stubs for CONFIG_USER_ONLY. Cc: Peter Maydell Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/arm/internals.h | 5 + target/arm/cpu-irq.c | 381 +++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 370 --------------------------------------- target/arm/el2-stubs.c | 37 ++++ target/arm/helper.c | 4 + target/arm/meson.build | 2 + 6 files changed, 429 insertions(+), 370 deletions(-) create mode 100644 target/arm/cpu-irq.c create mode 100644 target/arm/el2-stubs.c diff --git a/target/arm/internals.h b/target/arm/internals.h index 1b3d0244fd6..0561c2e2cc7 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1274,6 +1274,11 @@ static inline const char *aarch32_mode_name(uint32_t= psr) return cpu_mode_names[psr & 0xf]; } =20 +/** + * arm_cpu_exec_interrupt(): Implementation of the cpu_exec_inrerrupt hook. + */ +bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request); + /** * arm_cpu_update_virq: Update CPU_INTERRUPT_VIRQ bit in cs->interrupt_req= uest * diff --git a/target/arm/cpu-irq.c b/target/arm/cpu-irq.c new file mode 100644 index 00000000000..fe514cc93af --- /dev/null +++ b/target/arm/cpu-irq.c @@ -0,0 +1,381 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* + * QEMU ARM CPU - interrupt_request handling + * + * Copyright (c) 2003-2025 QEMU contributors + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "accel/tcg/cpu-ops.h" +#include "internals.h" + +#ifdef CONFIG_TCG +static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, + unsigned int target_el, + unsigned int cur_el, bool secure, + uint64_t hcr_el2) +{ + CPUARMState *env =3D cpu_env(cs); + bool pstate_unmasked; + bool unmasked =3D false; + bool allIntMask =3D false; + + /* + * Don't take exceptions if they target a lower EL. + * This check should catch any exceptions that would not be taken + * but left pending. + */ + if (cur_el > target_el) { + return false; + } + + if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) && + env->cp15.sctlr_el[target_el] & SCTLR_NMI && cur_el =3D=3D target_= el) { + allIntMask =3D env->pstate & PSTATE_ALLINT || + ((env->cp15.sctlr_el[target_el] & SCTLR_SPINTMASK) && + (env->pstate & PSTATE_SP)); + } + + switch (excp_idx) { + case EXCP_NMI: + pstate_unmasked =3D !allIntMask; + break; + + case EXCP_VINMI: + if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { + /* VINMIs are only taken when hypervized. */ + return false; + } + return !allIntMask; + case EXCP_VFNMI: + if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) { + /* VFNMIs are only taken when hypervized. */ + return false; + } + return !allIntMask; + case EXCP_FIQ: + pstate_unmasked =3D (!(env->daif & PSTATE_F)) && (!allIntMask); + break; + + case EXCP_IRQ: + pstate_unmasked =3D (!(env->daif & PSTATE_I)) && (!allIntMask); + break; + + case EXCP_VFIQ: + if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) { + /* VFIQs are only taken when hypervized. */ + return false; + } + return !(env->daif & PSTATE_F) && (!allIntMask); + case EXCP_VIRQ: + if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { + /* VIRQs are only taken when hypervized. */ + return false; + } + return !(env->daif & PSTATE_I) && (!allIntMask); + case EXCP_VSERR: + if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) { + /* VIRQs are only taken when hypervized. */ + return false; + } + return !(env->daif & PSTATE_A); + default: + g_assert_not_reached(); + } + + /* + * Use the target EL, current execution state and SCR/HCR settings to + * determine whether the corresponding CPSR bit is used to mask the + * interrupt. + */ + if ((target_el > cur_el) && (target_el !=3D 1)) { + /* Exceptions targeting a higher EL may not be maskable */ + if (arm_feature(env, ARM_FEATURE_AARCH64)) { + switch (target_el) { + case 2: + /* + * According to ARM DDI 0487H.a, an interrupt can be masked + * when HCR_E2H and HCR_TGE are both set regardless of the + * current Security state. Note that we need to revisit th= is + * part again once we need to support NMI. + */ + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) !=3D (HCR_E2H | HCR_TG= E)) { + unmasked =3D true; + } + break; + case 3: + /* Interrupt cannot be masked when the target EL is 3 */ + unmasked =3D true; + break; + default: + g_assert_not_reached(); + } + } else { + /* + * The old 32-bit-only environment has a more complicated + * masking setup. HCR and SCR bits not only affect interrupt + * routing but also change the behaviour of masking. + */ + bool hcr, scr; + + switch (excp_idx) { + case EXCP_FIQ: + /* + * If FIQs are routed to EL3 or EL2 then there are cases w= here + * we override the CPSR.F in determining if the exception = is + * masked or not. If neither of these are set then we fall= back + * to the CPSR.F setting otherwise we further assess the s= tate + * below. + */ + hcr =3D hcr_el2 & HCR_FMO; + scr =3D (env->cp15.scr_el3 & SCR_FIQ); + + /* + * When EL3 is 32-bit, the SCR.FW bit controls whether the + * CPSR.F bit masks FIQ interrupts when taken in non-secure + * state. If SCR.FW is set then FIQs can be masked by CPSR= .F + * when non-secure but only when FIQs are only routed to E= L3. + */ + scr =3D scr && !((env->cp15.scr_el3 & SCR_FW) && !hcr); + break; + case EXCP_IRQ: + /* + * When EL3 execution state is 32-bit, if HCR.IMO is set t= hen + * we may override the CPSR.I masking when in non-secure s= tate. + * The SCR.IRQ setting has already been taken into conside= ration + * when setting the target EL, so it does not have a furth= er + * affect here. + */ + hcr =3D hcr_el2 & HCR_IMO; + scr =3D false; + break; + default: + g_assert_not_reached(); + } + + if ((scr || hcr) && !secure) { + unmasked =3D true; + } + } + } + + /* + * The PSTATE bits only mask the interrupt if we have not overridden t= he + * ability above. + */ + return unmasked || pstate_unmasked; +} + +bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) +{ + CPUARMState *env =3D cpu_env(cs); + uint32_t cur_el =3D arm_current_el(env); + bool secure =3D arm_is_secure(env); + uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); + uint32_t target_el; + uint32_t excp_idx; + + /* The prioritization of interrupts is IMPLEMENTATION DEFINED. */ + + if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) && + (arm_sctlr(env, cur_el) & SCTLR_NMI)) { + if (interrupt_request & CPU_INTERRUPT_NMI) { + excp_idx =3D EXCP_NMI; + target_el =3D arm_phys_excp_target_el(cs, excp_idx, cur_el, se= cure); + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + if (interrupt_request & CPU_INTERRUPT_VINMI) { + excp_idx =3D EXCP_VINMI; + target_el =3D 1; + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + if (interrupt_request & CPU_INTERRUPT_VFNMI) { + excp_idx =3D EXCP_VFNMI; + target_el =3D 1; + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + } else { + /* + * NMI disabled: interrupts with superpriority are handled + * as if they didn't have it + */ + if (interrupt_request & CPU_INTERRUPT_NMI) { + interrupt_request |=3D CPU_INTERRUPT_HARD; + } + if (interrupt_request & CPU_INTERRUPT_VINMI) { + interrupt_request |=3D CPU_INTERRUPT_VIRQ; + } + if (interrupt_request & CPU_INTERRUPT_VFNMI) { + interrupt_request |=3D CPU_INTERRUPT_VFIQ; + } + } + + if (interrupt_request & CPU_INTERRUPT_FIQ) { + excp_idx =3D EXCP_FIQ; + target_el =3D arm_phys_excp_target_el(cs, excp_idx, cur_el, secure= ); + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + if (interrupt_request & CPU_INTERRUPT_HARD) { + excp_idx =3D EXCP_IRQ; + target_el =3D arm_phys_excp_target_el(cs, excp_idx, cur_el, secure= ); + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + if (interrupt_request & CPU_INTERRUPT_VIRQ) { + excp_idx =3D EXCP_VIRQ; + target_el =3D 1; + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + if (interrupt_request & CPU_INTERRUPT_VFIQ) { + excp_idx =3D EXCP_VFIQ; + target_el =3D 1; + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + goto found; + } + } + if (interrupt_request & CPU_INTERRUPT_VSERR) { + excp_idx =3D EXCP_VSERR; + target_el =3D 1; + if (arm_excp_unmasked(cs, excp_idx, target_el, + cur_el, secure, hcr_el2)) { + /* Taking a virtual abort clears HCR_EL2.VSE */ + env->cp15.hcr_el2 &=3D ~HCR_VSE; + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); + goto found; + } + } + return false; + + found: + cs->exception_index =3D excp_idx; + env->exception.target_el =3D target_el; + cs->cc->tcg_ops->do_interrupt(cs); + return true; +} +#endif /* CONFIG_TCG */ + +void arm_cpu_update_virq(ARMCPU *cpu) +{ + /* + * Update the interrupt level for VIRQ, which is the logical OR of + * the HCR_EL2.VI bit and the input line level from the GIC. + */ + CPUARMState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + bool new_state =3D ((arm_hcr_el2_eff(env) & HCR_VI) && + !(arm_hcrx_el2_eff(env) & HCRX_VINMI)) || + (env->irq_line_state & CPU_INTERRUPT_VIRQ); + + if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VIRQ)) { + if (new_state) { + cpu_interrupt(cs, CPU_INTERRUPT_VIRQ); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ); + } + } +} + +void arm_cpu_update_vfiq(ARMCPU *cpu) +{ + /* + * Update the interrupt level for VFIQ, which is the logical OR of + * the HCR_EL2.VF bit and the input line level from the GIC. + */ + CPUARMState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + bool new_state =3D ((arm_hcr_el2_eff(env) & HCR_VF) && + !(arm_hcrx_el2_eff(env) & HCRX_VFNMI)) || + (env->irq_line_state & CPU_INTERRUPT_VFIQ); + + if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VFIQ)) { + if (new_state) { + cpu_interrupt(cs, CPU_INTERRUPT_VFIQ); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_VFIQ); + } + } +} + +void arm_cpu_update_vinmi(ARMCPU *cpu) +{ + /* + * Update the interrupt level for VINMI, which is the logical OR of + * the HCRX_EL2.VINMI bit and the input line level from the GIC. + */ + CPUARMState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + bool new_state =3D ((arm_hcr_el2_eff(env) & HCR_VI) && + (arm_hcrx_el2_eff(env) & HCRX_VINMI)) || + (env->irq_line_state & CPU_INTERRUPT_VINMI); + + if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VINMI)) { + if (new_state) { + cpu_interrupt(cs, CPU_INTERRUPT_VINMI); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_VINMI); + } + } +} + +void arm_cpu_update_vfnmi(ARMCPU *cpu) +{ + /* + * Update the interrupt level for VFNMI, which is the HCRX_EL2.VFNMI b= it. + */ + CPUARMState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + bool new_state =3D (arm_hcr_el2_eff(env) & HCR_VF) && + (arm_hcrx_el2_eff(env) & HCRX_VFNMI); + + if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VFNMI)) { + if (new_state) { + cpu_interrupt(cs, CPU_INTERRUPT_VFNMI); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_VFNMI); + } + } +} + +void arm_cpu_update_vserr(ARMCPU *cpu) +{ + /* + * Update the interrupt level for VSERR, which is the HCR_EL2.VSE bit. + */ + CPUARMState *env =3D &cpu->env; + CPUState *cs =3D CPU(cpu); + + bool new_state =3D env->cp15.hcr_el2 & HCR_VSE; + + if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VSERR)) { + if (new_state) { + cpu_interrupt(cs, CPU_INTERRUPT_VSERR); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); + } + } +} + diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a29c3facbfd..7f927ef3c9f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -680,376 +680,6 @@ void arm_emulate_firmware_reset(CPUState *cpustate, i= nt target_el) } =20 =20 -#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) - -static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, - unsigned int target_el, - unsigned int cur_el, bool secure, - uint64_t hcr_el2) -{ - CPUARMState *env =3D cpu_env(cs); - bool pstate_unmasked; - bool unmasked =3D false; - bool allIntMask =3D false; - - /* - * Don't take exceptions if they target a lower EL. - * This check should catch any exceptions that would not be taken - * but left pending. - */ - if (cur_el > target_el) { - return false; - } - - if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) && - env->cp15.sctlr_el[target_el] & SCTLR_NMI && cur_el =3D=3D target_= el) { - allIntMask =3D env->pstate & PSTATE_ALLINT || - ((env->cp15.sctlr_el[target_el] & SCTLR_SPINTMASK) && - (env->pstate & PSTATE_SP)); - } - - switch (excp_idx) { - case EXCP_NMI: - pstate_unmasked =3D !allIntMask; - break; - - case EXCP_VINMI: - if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { - /* VINMIs are only taken when hypervized. */ - return false; - } - return !allIntMask; - case EXCP_VFNMI: - if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) { - /* VFNMIs are only taken when hypervized. */ - return false; - } - return !allIntMask; - case EXCP_FIQ: - pstate_unmasked =3D (!(env->daif & PSTATE_F)) && (!allIntMask); - break; - - case EXCP_IRQ: - pstate_unmasked =3D (!(env->daif & PSTATE_I)) && (!allIntMask); - break; - - case EXCP_VFIQ: - if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) { - /* VFIQs are only taken when hypervized. */ - return false; - } - return !(env->daif & PSTATE_F) && (!allIntMask); - case EXCP_VIRQ: - if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { - /* VIRQs are only taken when hypervized. */ - return false; - } - return !(env->daif & PSTATE_I) && (!allIntMask); - case EXCP_VSERR: - if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) { - /* VIRQs are only taken when hypervized. */ - return false; - } - return !(env->daif & PSTATE_A); - default: - g_assert_not_reached(); - } - - /* - * Use the target EL, current execution state and SCR/HCR settings to - * determine whether the corresponding CPSR bit is used to mask the - * interrupt. - */ - if ((target_el > cur_el) && (target_el !=3D 1)) { - /* Exceptions targeting a higher EL may not be maskable */ - if (arm_feature(env, ARM_FEATURE_AARCH64)) { - switch (target_el) { - case 2: - /* - * According to ARM DDI 0487H.a, an interrupt can be masked - * when HCR_E2H and HCR_TGE are both set regardless of the - * current Security state. Note that we need to revisit th= is - * part again once we need to support NMI. - */ - if ((hcr_el2 & (HCR_E2H | HCR_TGE)) !=3D (HCR_E2H | HCR_TG= E)) { - unmasked =3D true; - } - break; - case 3: - /* Interrupt cannot be masked when the target EL is 3 */ - unmasked =3D true; - break; - default: - g_assert_not_reached(); - } - } else { - /* - * The old 32-bit-only environment has a more complicated - * masking setup. HCR and SCR bits not only affect interrupt - * routing but also change the behaviour of masking. - */ - bool hcr, scr; - - switch (excp_idx) { - case EXCP_FIQ: - /* - * If FIQs are routed to EL3 or EL2 then there are cases w= here - * we override the CPSR.F in determining if the exception = is - * masked or not. If neither of these are set then we fall= back - * to the CPSR.F setting otherwise we further assess the s= tate - * below. - */ - hcr =3D hcr_el2 & HCR_FMO; - scr =3D (env->cp15.scr_el3 & SCR_FIQ); - - /* - * When EL3 is 32-bit, the SCR.FW bit controls whether the - * CPSR.F bit masks FIQ interrupts when taken in non-secure - * state. If SCR.FW is set then FIQs can be masked by CPSR= .F - * when non-secure but only when FIQs are only routed to E= L3. - */ - scr =3D scr && !((env->cp15.scr_el3 & SCR_FW) && !hcr); - break; - case EXCP_IRQ: - /* - * When EL3 execution state is 32-bit, if HCR.IMO is set t= hen - * we may override the CPSR.I masking when in non-secure s= tate. - * The SCR.IRQ setting has already been taken into conside= ration - * when setting the target EL, so it does not have a furth= er - * affect here. - */ - hcr =3D hcr_el2 & HCR_IMO; - scr =3D false; - break; - default: - g_assert_not_reached(); - } - - if ((scr || hcr) && !secure) { - unmasked =3D true; - } - } - } - - /* - * The PSTATE bits only mask the interrupt if we have not overridden t= he - * ability above. - */ - return unmasked || pstate_unmasked; -} - -static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) -{ - CPUARMState *env =3D cpu_env(cs); - uint32_t cur_el =3D arm_current_el(env); - bool secure =3D arm_is_secure(env); - uint64_t hcr_el2 =3D arm_hcr_el2_eff(env); - uint32_t target_el; - uint32_t excp_idx; - - /* The prioritization of interrupts is IMPLEMENTATION DEFINED. */ - - if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) && - (arm_sctlr(env, cur_el) & SCTLR_NMI)) { - if (interrupt_request & CPU_INTERRUPT_NMI) { - excp_idx =3D EXCP_NMI; - target_el =3D arm_phys_excp_target_el(cs, excp_idx, cur_el, se= cure); - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - if (interrupt_request & CPU_INTERRUPT_VINMI) { - excp_idx =3D EXCP_VINMI; - target_el =3D 1; - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - if (interrupt_request & CPU_INTERRUPT_VFNMI) { - excp_idx =3D EXCP_VFNMI; - target_el =3D 1; - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - } else { - /* - * NMI disabled: interrupts with superpriority are handled - * as if they didn't have it - */ - if (interrupt_request & CPU_INTERRUPT_NMI) { - interrupt_request |=3D CPU_INTERRUPT_HARD; - } - if (interrupt_request & CPU_INTERRUPT_VINMI) { - interrupt_request |=3D CPU_INTERRUPT_VIRQ; - } - if (interrupt_request & CPU_INTERRUPT_VFNMI) { - interrupt_request |=3D CPU_INTERRUPT_VFIQ; - } - } - - if (interrupt_request & CPU_INTERRUPT_FIQ) { - excp_idx =3D EXCP_FIQ; - target_el =3D arm_phys_excp_target_el(cs, excp_idx, cur_el, secure= ); - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - if (interrupt_request & CPU_INTERRUPT_HARD) { - excp_idx =3D EXCP_IRQ; - target_el =3D arm_phys_excp_target_el(cs, excp_idx, cur_el, secure= ); - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - if (interrupt_request & CPU_INTERRUPT_VIRQ) { - excp_idx =3D EXCP_VIRQ; - target_el =3D 1; - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - if (interrupt_request & CPU_INTERRUPT_VFIQ) { - excp_idx =3D EXCP_VFIQ; - target_el =3D 1; - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - goto found; - } - } - if (interrupt_request & CPU_INTERRUPT_VSERR) { - excp_idx =3D EXCP_VSERR; - target_el =3D 1; - if (arm_excp_unmasked(cs, excp_idx, target_el, - cur_el, secure, hcr_el2)) { - /* Taking a virtual abort clears HCR_EL2.VSE */ - env->cp15.hcr_el2 &=3D ~HCR_VSE; - cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); - goto found; - } - } - return false; - - found: - cs->exception_index =3D excp_idx; - env->exception.target_el =3D target_el; - cs->cc->tcg_ops->do_interrupt(cs); - return true; -} - -#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ - -void arm_cpu_update_virq(ARMCPU *cpu) -{ - /* - * Update the interrupt level for VIRQ, which is the logical OR of - * the HCR_EL2.VI bit and the input line level from the GIC. - */ - CPUARMState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); - - bool new_state =3D ((arm_hcr_el2_eff(env) & HCR_VI) && - !(arm_hcrx_el2_eff(env) & HCRX_VINMI)) || - (env->irq_line_state & CPU_INTERRUPT_VIRQ); - - if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VIRQ)) { - if (new_state) { - cpu_interrupt(cs, CPU_INTERRUPT_VIRQ); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ); - } - } -} - -void arm_cpu_update_vfiq(ARMCPU *cpu) -{ - /* - * Update the interrupt level for VFIQ, which is the logical OR of - * the HCR_EL2.VF bit and the input line level from the GIC. - */ - CPUARMState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); - - bool new_state =3D ((arm_hcr_el2_eff(env) & HCR_VF) && - !(arm_hcrx_el2_eff(env) & HCRX_VFNMI)) || - (env->irq_line_state & CPU_INTERRUPT_VFIQ); - - if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VFIQ)) { - if (new_state) { - cpu_interrupt(cs, CPU_INTERRUPT_VFIQ); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_VFIQ); - } - } -} - -void arm_cpu_update_vinmi(ARMCPU *cpu) -{ - /* - * Update the interrupt level for VINMI, which is the logical OR of - * the HCRX_EL2.VINMI bit and the input line level from the GIC. - */ - CPUARMState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); - - bool new_state =3D ((arm_hcr_el2_eff(env) & HCR_VI) && - (arm_hcrx_el2_eff(env) & HCRX_VINMI)) || - (env->irq_line_state & CPU_INTERRUPT_VINMI); - - if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VINMI)) { - if (new_state) { - cpu_interrupt(cs, CPU_INTERRUPT_VINMI); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_VINMI); - } - } -} - -void arm_cpu_update_vfnmi(ARMCPU *cpu) -{ - /* - * Update the interrupt level for VFNMI, which is the HCRX_EL2.VFNMI b= it. - */ - CPUARMState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); - - bool new_state =3D (arm_hcr_el2_eff(env) & HCR_VF) && - (arm_hcrx_el2_eff(env) & HCRX_VFNMI); - - if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VFNMI)) { - if (new_state) { - cpu_interrupt(cs, CPU_INTERRUPT_VFNMI); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_VFNMI); - } - } -} - -void arm_cpu_update_vserr(ARMCPU *cpu) -{ - /* - * Update the interrupt level for VSERR, which is the HCR_EL2.VSE bit. - */ - CPUARMState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); - - bool new_state =3D env->cp15.hcr_el2 & HCR_VSE; - - if (new_state !=3D cpu_test_interrupt(cs, CPU_INTERRUPT_VSERR)) { - if (new_state) { - cpu_interrupt(cs, CPU_INTERRUPT_VSERR); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); - } - } -} - #ifndef CONFIG_USER_ONLY static void arm_cpu_set_irq(void *opaque, int irq, int level) { diff --git a/target/arm/el2-stubs.c b/target/arm/el2-stubs.c new file mode 100644 index 00000000000..972023c337f --- /dev/null +++ b/target/arm/el2-stubs.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* QEMU ARM CPU - user-mode emulation stubs for EL2 interrupts + * + * These should not really be needed, but CP registers for EL2 + * are not elided by user-mode emulation and they call these + * functions. Leave them as stubs until it's cleaned up. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "internals.h" + +void arm_cpu_update_virq(ARMCPU *cpu) +{ + g_assert_not_reached(); +} + +void arm_cpu_update_vfiq(ARMCPU *cpu) +{ + g_assert_not_reached(); +} + +void arm_cpu_update_vinmi(ARMCPU *cpu) +{ + g_assert_not_reached(); +} + +void arm_cpu_update_vfnmi(ARMCPU *cpu) +{ + g_assert_not_reached(); +} + +void arm_cpu_update_vserr(ARMCPU *cpu) +{ + g_assert_not_reached(); +} diff --git a/target/arm/helper.c b/target/arm/helper.c index 4cd36e950aa..983eb2c4ecd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2862,8 +2862,12 @@ static void omap_threadid_write(CPUARMState *env, co= nst ARMCPRegInfo *ri, static void omap_wfi_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { +#ifdef CONFIG_USER_ONLY + g_assert_not_reached(); +#else /* Wait-for-interrupt (deprecated) */ cpu_interrupt(env_cpu(env), CPU_INTERRUPT_HALT); +#endif } =20 static void omap_cachemaint_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/meson.build b/target/arm/meson.build index 07d9271aa4d..914f1498fc5 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -26,6 +26,7 @@ arm_user_ss.add(files( 'debug_helper.c', 'helper.c', 'vfp_fpscr.c', + 'el2-stubs.c', )) =20 arm_common_system_ss.add(files('cpu.c')) @@ -38,6 +39,7 @@ arm_common_system_ss.add(files( 'arm-powerctl.c', 'cortex-regs.c', 'cpregs-pmu.c', + 'cpu-irq.c', 'debug_helper.c', 'helper.c', 'machine.c', --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756572472; cv=none; d=zohomail.com; s=zohoarc; b=bP9f3oIziWhekZ871C2FUsB4Lg5Dl9JRHSMrIjp7DtVvQYRCaGKnjCUZvUgW58LTNG8R7p89gP7rVn6+6JmoyjHd0KVjnhLxwQeTxSGwnIwe3EkdOpKwdQRiu+ErvbT6wnSt8Zuegcd1RTpY1m7Lc45A62tW2XXgXNo+ovXn58I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756572472; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ngp7yieopXFSA/+lQJw7TEMgciyxdXPlsW+grRCDpfI=; b=V244Gno0qYajCCmbBRFCWD5vRpmTXUSOQY8e3ZDmpkNHmR06NSAfq50aS34L+pJ03JSu4qVp/qAMnX5kvA8SfrrPmZI0uNgh7nu1pQW9xxryUAyNVuzBtpfwgyddw/HBDSum37jmu1QoON5gxqQP2+NJQruwlwD2kjXa/KvWHYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756572472872367.18136999024705; Sat, 30 Aug 2025 09:47:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOX-0003kK-FR; Sat, 30 Aug 2025 11:21:34 -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 1us14a-0001kn-Uz for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14Y-0000UE-73 for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:28 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-CP3NVr3NO9CAe98yracTyA-1; Fri, 29 Aug 2025 11:31:21 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45a1ad21752so13548755e9.1 for ; Fri, 29 Aug 2025 08:31:19 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d164a57097sm555536f8f.40.2025.08.29.08.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ngp7yieopXFSA/+lQJw7TEMgciyxdXPlsW+grRCDpfI=; b=arF2I2AxU20XlomJJLZF3nTyUZEdoXNm2zGF51YjMMjunhvCDoS1XT4V753e08B3RqxKEK 7owLPYKwkNJ+BjNeNEvVPV1GhZ/N+e1OWuoVIlAY/1mZMpL4R+e8i3yAEu+eVVHjFF+tl9 13iRdZpZ9ilrEpF+pfPEVAkF/wrTV8M= X-MC-Unique: CP3NVr3NO9CAe98yracTyA-1 X-Mimecast-MFC-AGG-ID: CP3NVr3NO9CAe98yracTyA_1756481479 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481478; x=1757086278; 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=ngp7yieopXFSA/+lQJw7TEMgciyxdXPlsW+grRCDpfI=; b=moBkRRF679/dxHgtkfIWWv0F14Sq+pQmBBVIqoXjKmoOzu9q0Ucqh4UYncr1OtNzhS uzZEawT4vFz2hx49Ml3d82TRs0Tz8GlWQlIOarxBZ+QXUTCeKYe86WzKwDxaqHsGItQ5 BobDBk5JZH95oMmzWY8KYZOTmAHwrlvxyq2PQCRRxsXwsHdr3nVMg5gLXXaD2qjQkxCm 11L6aFSViJw16lGXTNXe5VcBSDxm6Zd3p1NbUV/KXFJSfKLd3kviuAgDeE1os1zeF83/ x1SaRT7+7wNaMielzOUzFv83Cw5/60gERLqLDJHafrHty2oF45GgSqCx3/hhjDwCISvo hd7g== X-Gm-Message-State: AOJu0YxWeNz7AOgExVIFen1W9zXwM7oR/DDUyEH+yNv4hkxJ0JEwx2tq aPOXaG6YIUk95uHRsfTuv9tEL07CtN4gafARYSbqNM8UpU7iAUOOY5ahlb7sPgJvTNSlzA4vwxc I8tkOI/fjNIcqzi3aRjOxw8VIFKAQcpv/JxGjdY0jE7BUmR0q9PA+hQ+OmwtmiEiWc3YpLWNygu jJjXzv2o88srANkxZpeGF4RyuH3m6F6aDai2HkaKE5 X-Gm-Gg: ASbGncsU4T7s/t1XFFxLbFb71AM745JyNGu4EE20Z8I+MhhCRkHIq3I2WIl/SY4eTRf 8dp9aXRbHlJ5ntR5Zv8qKb5o0Zh7i9d9S2SpLDfJXdN6jz8yG8zjNnPsWdhp3NyTnRGHKu9tXkC rQo93dX70PKo+4750y1ESlYZPt6VJbmxpPf+VtaXYtKF9+EabCbX3HKir6WTAuewCsaqfIOj70J 5YoxM8YNo9jRS88fE6cBI1Au4b9adyl80OMJcz7XzooTbjaCcXYsGHNM0LfaAkoMzWiYB1+sz+m 3yg5FkXtUyrIsMGzmX+/dEtkvtu6vCDGQ35UKFZ3ONIrCwHgneDF7csZRz6WaUCwE2eIB4UC+WI f61hU3GYP7Fl7m6U+7PWTHoA/2rDEdGZE0qScZB4OsGM= X-Received: by 2002:a05:600c:4588:b0:45b:47e1:ef7c with SMTP id 5b1f17b1804b1-45b68714514mr117243135e9.18.1756481478091; Fri, 29 Aug 2025 08:31:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxlFDxF7dRX9RJdG01km0RtGgW67kMB4cmwu8jDL1TDPA9sCP9ygSYa5CE/ODaeMewI6EE/g== X-Received: by 2002:a05:600c:4588:b0:45b:47e1:ef7c with SMTP id 5b1f17b1804b1-45b68714514mr117242715e9.18.1756481477534; Fri, 29 Aug 2025 08:31:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 05/18] user-exec: remove cpu_interrupt() stub Date: Fri, 29 Aug 2025 17:31:02 +0200 Message-ID: <20250829153115.1590048-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756572474920116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- accel/tcg/user-exec.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 748bfab04a7..66c25fba7dd 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -46,11 +46,6 @@ __thread uintptr_t helper_retaddr; =20 //#define DEBUG_SIGNAL =20 -void cpu_interrupt(CPUState *cpu, int mask) -{ - g_assert_not_reached(); -} - /* * Adjust the pc to pass to cpu_restore_state; return the memop type. */ --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756572068; cv=none; d=zohomail.com; s=zohoarc; b=cj5WgAnWOauCVSPUt1msfj4qVq748oXOhnvp7fsywYeLAXCpeEs8716H5tNipUfokH44PIIBdoQGIrJOKI6Fw7/JX3rPvxDCcMUwh/KdqmDRfN/fkL7a/+pmy/DHZ1VXv8feftgaSls9UBafd6L4qd7hciwbouzh1YDuXXgcfzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756572068; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lX8mWkosrGmPbwi/WpQDO7oQxNxUyrkC8dHYRHFRmnU=; b=U+z+d5v/6FO8TuZ4xouRLBepnVAAROJSab/3jAO4aSB88YUh+KzB+WlIrkMAtuxKO8MhHKIxbobCEF2BgM8ToD2RMPZ6F4x5TbgOM8fzpm7nsk0gSBNRoL853N05iMKuZZoLmEOyMPYJFP1ry9J99WnRmSe/GAPMgG8s77/CaoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17565720683641017.1024053651552; Sat, 30 Aug 2025 09:41:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOX-0003mY-Kc; Sat, 30 Aug 2025 11:21:33 -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 1us14c-0001lI-AF for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14Y-0000UN-6n for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:29 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-uBhFo_5EMBmDgR4m689LSQ-1; Fri, 29 Aug 2025 11:31:22 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45b71eef08eso11826335e9.0 for ; Fri, 29 Aug 2025 08:31:22 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e7d1319sm47407925e9.5.2025.08.29.08.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lX8mWkosrGmPbwi/WpQDO7oQxNxUyrkC8dHYRHFRmnU=; b=QoTcUVg8Ns8uShvem40Z9vCPORTjIN5BEDpyRS72MInVzldL9j+8yoexFwtc1ANxlRslLJ tR9FAbm+SK3FXSegbMfSAjVi434eSczT4cJH/+jvgzWrSjJmrP9dZfkouaSgxj2ei8JpXY 5TR988l4nfxJH6gBeCYOzWjbO06sq4Q= X-MC-Unique: uBhFo_5EMBmDgR4m689LSQ-1 X-Mimecast-MFC-AGG-ID: uBhFo_5EMBmDgR4m689LSQ_1756481481 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481481; x=1757086281; 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=lX8mWkosrGmPbwi/WpQDO7oQxNxUyrkC8dHYRHFRmnU=; b=MsfWrvvGCNTTrRyVOdyUEiWHZW40tOWkPxVbZo4NbpdIZCwh2e+mghkcyH8vCIb78i RvuD4o953aeezREpBooKDhaaqlT1VbifVwwhVpcKpp5ii1O/waCHrs9jC7Mif5kK2giG ksBycPZkOhqh1k7ncayW3r9txPnKT67i7bp98tKQSTCniY+RJJWVqMrgf7m7Jq3gm3dV 0yKWPz6YmfFGDTnDbyfRC70J+35tq1DVtJqsdapPEJpJDh9Rw/2Fbnuysti5vnY42rA7 PHeH3DwyIn3ebjOiZj/qGD20IDmocFP4GNcX+GpKsBR5KxcqUsHX2elS5ZxTjjfhW1XS Ryjg== X-Gm-Message-State: AOJu0YwiAiRASUCIDHmNczpPYVD8pTsRfSr/fkMIdPTD8aIbES4DzXkz phkovHj4lIzNuaCDuMGZcfLO10f9rHwzcvspKDAmgJk5Cp5mYD97Mkz870SaHD/J4pZnugo+k0T L2p0XcV19Kq5L93YMXeJvjJQ/LK6iK3QbPeAtvec8Fn2lyT0Uy7/wa69DeJ0Ip6DYKpMHPnSbQY qlPmfHXpAdHvyMvOOi0n3afsOY5/ZBmEKkbYGU8yWo X-Gm-Gg: ASbGncu0Jo8qC15Ap6jiLgYfPtLnS81xgl7CttwhtkkzvoYoLRx7I7tbtPLLkHAaFfU b3uDsr8PFhfOMSw8BTDY95K2Q6/wCxHrucQT525nho6n0ao8VsTijwZHS/I6LFI0d1tKUAQhOgL i6IMQR/W4yw3sdZD20/vE3A86l5N8Z8l0erC4ltAYje5H/BHhWilpu0c5KCcOLvJ4YfwVb/3HoT CDANRlFmA3Mait2tUBe4DIPFxdI3NnFw5YaZLiHcMh0561E143zi1OoGJ8p3dGjgjcCeLHE1UHc D3z3p4KiMFBWpw0bnWji/xwAIljfHSE1+V3VYkZiJDckx+FQrFAIxoqIoFQm14IKhd7lgzv4Rs0 N7gHEAlj3q2J2qaDG5G7ODoocbqOgR+gm2nxlyjjJQII= X-Received: by 2002:a05:600c:3ba2:b0:45b:47e1:ef70 with SMTP id 5b1f17b1804b1-45b74421339mr71147945e9.35.1756481480506; Fri, 29 Aug 2025 08:31:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4pnXjdjae26KsNNna/M9pbXsMegsxYKYCRIqMon2WAjdS+qepPmiv/UAMQR80NUE6k1zhww== X-Received: by 2002:a05:600c:3ba2:b0:45b:47e1:ef70 with SMTP id 5b1f17b1804b1-45b74421339mr71147455e9.35.1756481479849; Fri, 29 Aug 2025 08:31:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 06/18] treewide: clear bits of cs->interrupt_request with cpu_reset_interrupt() Date: Fri, 29 Aug 2025 17:31:03 +0200 Message-ID: <20250829153115.1590048-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756572071415124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- accel/tcg/cpu-exec.c | 6 +++--- hw/core/cpu-system.c | 2 +- target/avr/helper.c | 4 ++-- target/i386/hvf/x86hvf.c | 8 ++++---- target/i386/kvm/kvm.c | 14 +++++++------- target/i386/nvmm/nvmm-all.c | 10 +++++----- target/i386/tcg/system/seg_helper.c | 13 ++++++------- target/i386/tcg/system/svm_helper.c | 2 +- target/i386/whpx/whpx-all.c | 12 ++++++------ target/openrisc/sys_helper.c | 2 +- target/rx/helper.c | 4 ++-- target/s390x/tcg/excp_helper.c | 2 +- 12 files changed, 39 insertions(+), 40 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8491e5badd1..508d2d2d9e2 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -784,7 +784,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(cpu_test_interrupt(cpu, ~0))) { bql_lock(); if (cpu_test_interrupt(cpu, CPU_INTERRUPT_DEBUG)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_DEBUG; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG); cpu->exception_index =3D EXCP_DEBUG; bql_unlock(); return true; @@ -793,7 +793,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, /* Do nothing */ } else if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HALT)) { replay_interrupt(); - cpu->interrupt_request &=3D ~CPU_INTERRUPT_HALT; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT); cpu->halted =3D 1; cpu->exception_index =3D EXCP_HLT; bql_unlock(); @@ -840,7 +840,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_EXITTB)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_EXITTB; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_EXITTB); /* ensure that no TB jump will be modified as the program flow was changed */ *last_tb =3D NULL; diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index a975405d3a0..09c928c1f92 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -204,7 +204,7 @@ static int cpu_common_post_load(void *opaque, int versi= on_id) * 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the * version_id is increased. */ - cpu->interrupt_request &=3D ~0x01; + cpu_reset_interrupt(cpu, 0x01); =20 tlb_flush(cpu); =20 diff --git a/target/avr/helper.c b/target/avr/helper.c index b9cd6d5ef27..4b29ab35263 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -47,7 +47,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_r= equest) cs->exception_index =3D EXCP_RESET; avr_cpu_do_interrupt(cs); =20 - cs->interrupt_request &=3D ~CPU_INTERRUPT_RESET; + cpu_reset_interrupt(cs, CPU_INTERRUPT_RESET); return true; } } @@ -59,7 +59,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_r= equest) =20 env->intsrc &=3D env->intsrc - 1; /* clear the interrupt */ if (!env->intsrc) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } return true; } diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index 9e05e0e5765..a502437c303 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -397,7 +397,7 @@ bool hvf_inject_interrupts(CPUState *cs) =20 if (cpu_test_interrupt(cs, CPU_INTERRUPT_NMI)) { if (!(env->hflags2 & HF2_NMI_MASK) && !(info & VMCS_INTR_VALID)) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_NMI; + cpu_reset_interrupt(cs, CPU_INTERRUPT_NMI); info =3D VMCS_INTR_VALID | VMCS_INTR_T_NMI | EXCP02_NMI; wvmcs(cs->accel->fd, VMCS_ENTRY_INTR_INFO, info); } else { @@ -409,7 +409,7 @@ bool hvf_inject_interrupts(CPUState *cs) cpu_test_interrupt(cs, CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK) && !(info & VMCS_INTR_VALID)) { int line =3D cpu_get_pic_interrupt(env); - cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); if (line >=3D 0) { wvmcs(cs->accel->fd, VMCS_ENTRY_INTR_INFO, line | VMCS_INTR_VALID | VMCS_INTR_T_HWINTR); @@ -437,7 +437,7 @@ int hvf_process_events(CPUState *cs) } =20 if (cpu_test_interrupt(cs, CPU_INTERRUPT_POLL)) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_POLL; + cpu_reset_interrupt(cs, CPU_INTERRUPT_POLL); apic_poll_irq(cpu->apic_state); } if ((cpu_test_interrupt(cs, CPU_INTERRUPT_HARD) && @@ -450,7 +450,7 @@ int hvf_process_events(CPUState *cs) do_cpu_sipi(cpu); } if (cpu_test_interrupt(cs, CPU_INTERRUPT_TPR)) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_TPR; + cpu_reset_interrupt(cs, CPU_INTERRUPT_TPR); cpu_synchronize_state(cs); apic_handle_tpr_access_report(cpu->apic_state, env->eip, env->tpr_access_type); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 306430a0521..8420c4090ef 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5066,7 +5066,7 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level) */ events.smi.pending =3D cs->interrupt_request & CPU_INTERRUPT_S= MI; events.smi.latched_init =3D cs->interrupt_request & CPU_INTERR= UPT_INIT; - cs->interrupt_request &=3D ~(CPU_INTERRUPT_INIT | CPU_INTERRUP= T_SMI); + cpu_reset_interrupt(cs, CPU_INTERRUPT_INIT | CPU_INTERRUPT_SMI= ); } else { /* Keep these in cs->interrupt_request. */ events.smi.pending =3D 0; @@ -5456,7 +5456,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) if (cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) { if (cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) { bql_lock(); - cpu->interrupt_request &=3D ~CPU_INTERRUPT_NMI; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_NMI); bql_unlock(); DPRINTF("injected NMI\n"); ret =3D kvm_vcpu_ioctl(cpu, KVM_NMI); @@ -5467,7 +5467,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_SMI)) { bql_lock(); - cpu->interrupt_request &=3D ~CPU_INTERRUPT_SMI; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_SMI); bql_unlock(); DPRINTF("injected SMI\n"); ret =3D kvm_vcpu_ioctl(cpu, KVM_SMI); @@ -5502,7 +5502,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *= run) =20 bql_lock(); =20 - cpu->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HARD); irq =3D cpu_get_pic_interrupt(env); if (irq >=3D 0) { struct kvm_interrupt intr; @@ -5597,7 +5597,7 @@ int kvm_arch_process_async_events(CPUState *cs) /* We must not raise CPU_INTERRUPT_MCE if it's not supported. */ assert(env->mcg_cap); =20 - cs->interrupt_request &=3D ~CPU_INTERRUPT_MCE; + cpu_reset_interrupt(cs, CPU_INTERRUPT_MCE); =20 kvm_cpu_synchronize_state(cs); =20 @@ -5627,7 +5627,7 @@ int kvm_arch_process_async_events(CPUState *cs) } =20 if (cpu_test_interrupt(cs, CPU_INTERRUPT_POLL)) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_POLL; + cpu_reset_interrupt(cs, CPU_INTERRUPT_POLL); apic_poll_irq(cpu->apic_state); } if ((cpu_test_interrupt(cs, CPU_INTERRUPT_HARD) && @@ -5640,7 +5640,7 @@ int kvm_arch_process_async_events(CPUState *cs) do_cpu_sipi(cpu); } if (cpu_test_interrupt(cs, CPU_INTERRUPT_TPR)) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_TPR; + cpu_reset_interrupt(cs, CPU_INTERRUPT_TPR); kvm_cpu_synchronize_state(cs); apic_handle_tpr_access_report(cpu->apic_state, env->eip, env->tpr_access_type); diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index c1ac74c4f04..e1151b04c6e 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -419,7 +419,7 @@ nvmm_vcpu_pre_run(CPUState *cpu) =20 if (!has_event && cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) { if (nvmm_can_take_nmi(cpu)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_NMI; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_NMI); event->type =3D NVMM_VCPU_EVENT_INTR; event->vector =3D 2; has_event =3D true; @@ -428,7 +428,7 @@ nvmm_vcpu_pre_run(CPUState *cpu) =20 if (!has_event && cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD)) { if (nvmm_can_take_int(cpu)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HARD); event->type =3D NVMM_VCPU_EVENT_INTR; event->vector =3D cpu_get_pic_interrupt(env); has_event =3D true; @@ -437,7 +437,7 @@ nvmm_vcpu_pre_run(CPUState *cpu) =20 /* Don't want SMIs. */ if (cpu_test_interrupt(cpu, CPU_INTERRUPT_SMI)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_SMI; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_SMI); } =20 if (sync_tpr) { @@ -697,7 +697,7 @@ nvmm_vcpu_loop(CPUState *cpu) /* set int/nmi windows back to the reset state */ } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_POLL)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_POLL; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); apic_poll_irq(x86_cpu->apic_state); } if ((cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD) && @@ -710,7 +710,7 @@ nvmm_vcpu_loop(CPUState *cpu) do_cpu_sipi(x86_cpu); } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_TPR)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_TPR; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_TPR); nvmm_cpu_synchronize_state(cpu); apic_handle_tpr_access_report(x86_cpu->apic_state, env->eip, env->tpr_access_type); diff --git a/target/i386/tcg/system/seg_helper.c b/target/i386/tcg/system/s= eg_helper.c index 794a23ddfc4..38072e51d72 100644 --- a/target/i386/tcg/system/seg_helper.c +++ b/target/i386/tcg/system/seg_helper.c @@ -178,7 +178,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt= _request) */ switch (interrupt_request) { case CPU_INTERRUPT_POLL: - cs->interrupt_request &=3D ~CPU_INTERRUPT_POLL; + cpu_reset_interrupt(cs, CPU_INTERRUPT_POLL); apic_poll_irq(cpu->apic_state); break; case CPU_INTERRUPT_SIPI: @@ -186,23 +186,22 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) break; case CPU_INTERRUPT_SMI: cpu_svm_check_intercept_param(env, SVM_EXIT_SMI, 0, 0); - cs->interrupt_request &=3D ~CPU_INTERRUPT_SMI; + cpu_reset_interrupt(cs, CPU_INTERRUPT_SMI); do_smm_enter(cpu); break; case CPU_INTERRUPT_NMI: cpu_svm_check_intercept_param(env, SVM_EXIT_NMI, 0, 0); - cs->interrupt_request &=3D ~CPU_INTERRUPT_NMI; + cpu_reset_interrupt(cs, CPU_INTERRUPT_NMI); env->hflags2 |=3D HF2_NMI_MASK; do_interrupt_x86_hardirq(env, EXCP02_NMI, 1); break; case CPU_INTERRUPT_MCE: - cs->interrupt_request &=3D ~CPU_INTERRUPT_MCE; + cpu_reset_interrupt(cs, CPU_INTERRUPT_MCE); do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0); break; case CPU_INTERRUPT_HARD: cpu_svm_check_intercept_param(env, SVM_EXIT_INTR, 0, 0); - cs->interrupt_request &=3D ~(CPU_INTERRUPT_HARD | - CPU_INTERRUPT_VIRQ); + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ); intno =3D cpu_get_pic_interrupt(env); qemu_log_mask(CPU_LOG_INT, "Servicing hardware INT=3D0x%02x\n", intno); @@ -215,7 +214,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt= _request) qemu_log_mask(CPU_LOG_INT, "Servicing virtual hardware INT=3D0x%02x\n", intno); do_interrupt_x86_hardirq(env, intno, 1); - cs->interrupt_request &=3D ~CPU_INTERRUPT_VIRQ; + cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ); env->int_ctl &=3D ~V_IRQ_MASK; break; } diff --git a/target/i386/tcg/system/svm_helper.c b/target/i386/tcg/system/s= vm_helper.c index 3569196bdda..505788b0e26 100644 --- a/target/i386/tcg/system/svm_helper.c +++ b/target/i386/tcg/system/svm_helper.c @@ -824,7 +824,7 @@ void do_vmexit(CPUX86State *env) env->intercept_exceptions =3D 0; =20 /* Clears the V_IRQ and V_INTR_MASKING bits inside the processor. */ - cs->interrupt_request &=3D ~CPU_INTERRUPT_VIRQ; + cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ); env->int_ctl =3D 0; =20 /* Clears the TSC_OFFSET inside the processor. */ diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 878cdd1668c..c09a0a64f22 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1471,14 +1471,14 @@ static void whpx_vcpu_pre_run(CPUState *cpu) if (!vcpu->interruption_pending && cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI | CPU_INTERRUPT_SMI)) { if (cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_NMI; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_NMI); vcpu->interruptable =3D false; new_int.InterruptionType =3D WHvX64PendingNmi; new_int.InterruptionPending =3D 1; new_int.InterruptionVector =3D 2; } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_SMI)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_SMI; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_SMI); } } =20 @@ -1502,7 +1502,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) vcpu->interruptable && (env->eflags & IF_MASK)) { assert(!new_int.InterruptionPending); if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HARD); irq =3D cpu_get_pic_interrupt(env); if (irq >=3D 0) { new_int.InterruptionType =3D WHvX64PendingInterrupt; @@ -1520,7 +1520,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } } else if (vcpu->ready_for_pic_interrupt && cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_HARD); irq =3D cpu_get_pic_interrupt(env); if (irq >=3D 0) { reg_names[reg_count] =3D WHvRegisterPendingEvent; @@ -1607,7 +1607,7 @@ static void whpx_vcpu_process_async_events(CPUState *= cpu) } =20 if (cpu_test_interrupt(cpu, CPU_INTERRUPT_POLL)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_POLL; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL); apic_poll_irq(x86_cpu->apic_state); } =20 @@ -1623,7 +1623,7 @@ static void whpx_vcpu_process_async_events(CPUState *= cpu) } =20 if (cpu_test_interrupt(cpu, CPU_INTERRUPT_TPR)) { - cpu->interrupt_request &=3D ~CPU_INTERRUPT_TPR; + cpu_reset_interrupt(cpu, CPU_INTERRUPT_TPR); whpx_cpu_synchronize_state(cpu); apic_handle_tpr_access_report(x86_cpu->apic_state, env->eip, env->tpr_access_type); diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index d96b41a01c2..b091a9c6685 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -196,7 +196,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) env->ttmr =3D (rb & ~TTMR_IP) | ip; } else { /* Clear IP bit. */ env->ttmr =3D rb & ~TTMR_IP; - cs->interrupt_request &=3D ~CPU_INTERRUPT_TIMER; + cpu_reset_interrupt(cs, CPU_INTERRUPT_TIMER); } cpu_openrisc_timer_update(cpu); bql_unlock(); diff --git a/target/rx/helper.c b/target/rx/helper.c index ce003af4219..41c9606fd1d 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -63,7 +63,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->bpsw =3D save_psw; env->pc =3D env->fintv; env->psw_ipl =3D 15; - cs->interrupt_request &=3D ~CPU_INTERRUPT_FIR; + cpu_reset_interrupt(cs, CPU_INTERRUPT_FIR); qemu_set_irq(env->ack, env->ack_irq); qemu_log_mask(CPU_LOG_INT, "fast interrupt raised\n"); } else if (do_irq & CPU_INTERRUPT_HARD) { @@ -73,7 +73,7 @@ void rx_cpu_do_interrupt(CPUState *cs) cpu_stl_data(env, env->isp, env->pc); env->pc =3D cpu_ldl_data(env, env->intb + env->ack_irq * 4); env->psw_ipl =3D env->ack_ipl; - cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); qemu_set_irq(env->ack, env->ack_irq); qemu_log_mask(CPU_LOG_INT, "interrupt 0x%02x raised\n", env->ack_irq); diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index e4c75d0ce01..4c7faeee82b 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -559,7 +559,7 @@ try_deliver: =20 /* we might still have pending interrupts, but not deliverable */ if (!env->pending_int && !qemu_s390_flic_has_any(flic)) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } =20 /* WAIT PSW during interrupt injection or STOP interrupt */ --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756567964; cv=none; d=zohomail.com; s=zohoarc; b=HlFfGIApz9FNB82tXTpN60O4Muv7d5CEfImviykXgjZcgT3CTdZi1nEoOaIcbL9CHyUznUxnX2E3MjRZBPoDAIA074pNdoJbo/LBhZB7TWfLb+u1jvs0sOkEfnRCi7UHLX0EzeV4dcsS8VMYrksV54kcFYPR3V6NjjkDiu9X2E8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756567964; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EsZtj6B4xNxRbWQ2j10KIrPfvYq1rdhUBi92bjvMMmM=; b=e530CNo0BK10eWSAD7XXrj6nsROCZlSmJ2iwF9NAJVEj/WhkNB7UZ1y7XT+3gRXj+V2MvfiU6A44RCO43qFWs6wCSV/CMFxHEKYx2o4tQXzklqCBdOza74juR7F8Wh9NxXEJ+wIidesW69MHHMbZ2pjygZwP5bqc6RwHEG7LNcw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756567964037363.156894107834; Sat, 30 Aug 2025 08:32:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOb-0003zJ-IL; Sat, 30 Aug 2025 11:21:37 -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 1us14i-0001nh-El for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14c-0000V4-4V for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:34 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-CSDzsGIjMRG3MmLPlKuLpw-1; Fri, 29 Aug 2025 11:31:26 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45b71fe31ffso12933055e9.2 for ; Fri, 29 Aug 2025 08:31:25 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d0c344f6casm2718163f8f.36.2025.08.29.08.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481488; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EsZtj6B4xNxRbWQ2j10KIrPfvYq1rdhUBi92bjvMMmM=; b=M54fA2GZmlWqH1cGEh/IydbM6QeXHH8Ny/cmEWFj0WS2O6uf7BhBxzxGQYn2W8BwNCInL0 UEYUnErihKCfavZrKGv39EXw3huC3CxmIZHv87tCvw4JEA/CG1dno64R5ERUjHF+025wCl 7mi7o50xCWADHRalOUGckFvDUkQR8P8= X-MC-Unique: CSDzsGIjMRG3MmLPlKuLpw-1 X-Mimecast-MFC-AGG-ID: CSDzsGIjMRG3MmLPlKuLpw_1756481484 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481484; x=1757086284; 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=EsZtj6B4xNxRbWQ2j10KIrPfvYq1rdhUBi92bjvMMmM=; b=fAEnEO8pxj6cLbc8npRRDn74e3B6TpSQhgeqPtL9qUm0g4KYKDaT3/tynP51EVBbY4 ppGbtPrfr31CorjbCR8MJjJJlK/GTGEBtpbvUV8w14RcGhqXJ29hNKcKMZM7KteXIIek dX5u95prMSIoCx5vIgDU2JtN124EoIzEGm23+V/g4miGfdh3P4MH7Wj32sUNpYwUgrat hf16j0S8ZaeVcEZ39cxCo+RPeXf1HbIFhrmLHZTnDBRAoSNDzWPWJzuA2xIgLtW35Arw ExQ2vD7sQtuv6rQPn+zFfReQ25Q5cqKrTIoUjc65apC4cSHLL/XT4MyM0ixTUcVK+gkd 6wew== X-Gm-Message-State: AOJu0YyrcIEIaOpAmu7rZLw8bW7SXQ4WOA7Q+3VPz0bjtckaCAGSlV8c nGjr/N8TC9EneN+2nQPlo9v7uaYSn2YSRGP2fT1+QBRMamXE1PyglY3VfLS+SuMRMlMUFG2lpdl ny7JpTQTneOZOb792S5oAImQeiZKBesQjKNGPH23l9UNF9GHouLcgBm0FbNWygs+aSIB5CzNT+4 y8FWGl5AWMmsPEFm3u8GaZw7tP0RvHHiW6dDiUXODo X-Gm-Gg: ASbGncsnH/NH246W+Eb3EqoFSyn74quQVroXWSvtK7fsOC1vD8XRWdobAJ8Yi14cptD rTKD4oG1OsjCaRw4+dEXlTZ8gBxHJy6BJctNTslt8lnhJIMjWYXYSA9QcIgQUvtLIbYVh+C5HV4 JwrOfjNdX80oOqaXS2SEKYob59CPgxAARYJhM/cnLzVprtJz3EWI3ebwPQLJ8gMvwLpUqT7EKml UH9YixhcPeJU+a99JRUcyAaOSQf1CbEDm+luFSupT+o3A8ApgPeGi+A0UP/12MXd5r6CLAd19Kz nJpPVW141H6jAJlFtV2Plqnl7dOkyOSnTMxj6Pse1D/fljoNyVmyM+YCcF6V+lTeSv1Iz4xu3FK 8nHbW1277znltjdJVcqywCVlZ0APbLhcNNJpVktb+Llo= X-Received: by 2002:a05:600c:3b8b:b0:45b:7951:92a2 with SMTP id 5b1f17b1804b1-45b795195c9mr54607835e9.18.1756481483626; Fri, 29 Aug 2025 08:31:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH45wRzNb7t0IxQi75lcnXmWWtTjS7Pv6ApygqocKPXnWv0MkgD33L8EbCi5JtzBKvDyJaTUw== X-Received: by 2002:a05:600c:3b8b:b0:45b:7951:92a2 with SMTP id 5b1f17b1804b1-45b795195c9mr54607495e9.18.1756481483080; Fri, 29 Aug 2025 08:31:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 07/18] cpu-common: use atomic access for interrupt_request Date: Fri, 29 Aug 2025 17:31:04 +0200 Message-ID: <20250829153115.1590048-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756567965343116600 Content-Type: text/plain; charset="utf-8" Writes to interrupt_request used non-atomic accesses, but there are a few cases where the access was not protected by the BQL. Now that there is a full set of helpers, it's easier to guarantee that interrupt_request accesses are fully atomic, so just drop the requirement instead of fixing them. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 1 - hw/core/cpu-common.c | 12 +----------- system/cpus.c | 3 +-- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index b01a0cffd64..23bd02277f4 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -495,7 +495,6 @@ struct CPUState { bool exit_request; int exclusive_context_count; uint32_t cflags_next_tb; - /* updates protected by BQL */ uint32_t interrupt_request; int singlestep_enabled; int64_t icount_budget; diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 39e674aca21..9ea1f3764a8 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -67,19 +67,9 @@ CPUState *cpu_create(const char *typename) return cpu; } =20 -/* Resetting the IRQ comes from across the code base so we take the - * BQL here if we need to. cpu_interrupt assumes it is held.*/ void cpu_reset_interrupt(CPUState *cpu, int mask) { - bool need_lock =3D !bql_locked(); - - if (need_lock) { - bql_lock(); - } - cpu->interrupt_request &=3D ~mask; - if (need_lock) { - bql_unlock(); - } + qatomic_and(&cpu->interrupt_request, ~mask); } =20 void cpu_exit(CPUState *cpu) diff --git a/system/cpus.c b/system/cpus.c index 437848b5eb4..9bfbe2b0607 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -257,8 +257,7 @@ int64_t cpus_get_elapsed_ticks(void) void cpu_set_interrupt(CPUState *cpu, int mask) { /* Pairs with cpu_test_interrupt(). */ - qatomic_store_release(&cpu->interrupt_request, - cpu->interrupt_request | mask); + qatomic_or(&cpu->interrupt_request, mask); } =20 void generic_handle_interrupt(CPUState *cpu, int mask) --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756567692; cv=none; d=zohomail.com; s=zohoarc; b=Efte+NmxxKalb4flep4YLwOsxTwfHnB55sqSmeFNlSQIPER2WPmc0FNwD3oR2jnTwdzLLMlDdO/R90PrsX5nOxyntWJmb3GXoCh7XaBbk70PBuDW8bEaYk0ycwhbTcxlq9NiqluKpbNC7uoje4CIPlKqcnT5Unuv/26rumV5XJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756567692; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wHiXTdD+JdkJ3K5Wgrb7J368fVXnGUo4N+Ao9AD46aI=; b=ho04+F28OwRjGPnRWG5ZtPSLiDhDjWZAbXzGuXp36ZdwtfhBsBAJ+Ey7+5YV+3SsOET4qM4kZwOjKZfXY714/DvvfTy2bqeqy+plEJbKpBlClCkS2frKqXyzz7o76cuKqiAK/vJjfCLJzIe2RZefGPNqe2vqWkEPydVaCtLuNVg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756567692750435.1454669743574; Sat, 30 Aug 2025 08:28:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOa-0003vQ-Dp; Sat, 30 Aug 2025 11:21:36 -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 1us14i-0001ni-GN for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14f-0000Ve-UX for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:35 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-gFFm9Sz3Pp23zpMc3XgYTA-1; Fri, 29 Aug 2025 11:31:30 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45a1b05a59cso14966165e9.1 for ; Fri, 29 Aug 2025 08:31:30 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf270fd2dfsm3926917f8f.3.2025.08.29.08.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHiXTdD+JdkJ3K5Wgrb7J368fVXnGUo4N+Ao9AD46aI=; b=YXlOI1TEWGP48olXruYUx3CWUR+hHxtQt53bES/r/YOJuKZgUfyp9pLcl5poWWs20nBKBj kj99YdN5VHGUDDqEJMRG7TgLo+gY7k1t7DpyghuJeR+Gq3dHwx15isp69wayNuch1s2FeF SSjNKpmlwKJaT6yIkOMRYgZrYqksHF0= X-MC-Unique: gFFm9Sz3Pp23zpMc3XgYTA-1 X-Mimecast-MFC-AGG-ID: gFFm9Sz3Pp23zpMc3XgYTA_1756481489 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481488; x=1757086288; 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=wHiXTdD+JdkJ3K5Wgrb7J368fVXnGUo4N+Ao9AD46aI=; b=Y46A5wUnyzSFdB8wb8xumvOSNcZcM/zkmptZNFkSbsYpukc5sf0kIkNLj+qCs6MdU0 nmf/J2oX1x2Ew+8hU0HH8FdxqOWqcscbx9g0YCLIDJlEHuN/MbGvSkQzcOFi5r5hpv7M ND9FGmM8Rz9JlXVKU23UstSo3wEufhk9e5RcG1olYflwqX+waPpMbaDic+elDnuSZyOs oECk1zwDEOQC6i7gYoT78nD0kq9u1/I2G/6hZGBeoEr4gM/9FlQgqeFe/SU9O7U25nzQ Vk21uR+plXtKJ/pATYeiAgunjY1Luj5WeEoBrcJKZ5SPkDwrsf752u3zEHftjpgMkbAJ OODg== X-Gm-Message-State: AOJu0YyqLD78ZMZjrcRUqmFG+PeV0gA0Ro2BOhjBg8swun8dH1Q6yvfk tBDaRZ4PX+rcP5P0x/2lmOmhg/IbLoJSDj70L4J/jCohChrkUd+AIyA168RqckYWYIIGf/wmfKL qcbYiNCRydII6b+nkwBVTjYzHQjhE/6jd2WMPgHlU/tJTT2NzBdAC1igsI5GmGEuJB8OJTyDo1Q SrU1drrMUDsv+aGbj+ikc6tR+/NRD4aPLBjZ8d68yR X-Gm-Gg: ASbGncux2ZNjJphdGrbmGfoLGc6Zg01dsJiaPsMvWmmWl6TEgrw6k5+ZzagS2TYT1Jb 8hKW72xJtwzQVzItMHeYY0kNDFgN4okRsoXJOKLkh5pgIJLK35nZY3d9pBfvLgF8Pr7tQ++pTX1 p8ST4aHrTqDwlKAlfjWl/tjFGSAqt+3Fg+jOGwe2tEOOpkvjqIskp3b5Vbxb+YGGg2Tohy5iMx+ J2ufhZUQchkyVCrAkZru8EySN69UujBesjIPcJbieMpf4Fg4+ldTnJOVFhPZ1xcAp0YwZw7BPCb pNZzZ6vBFOicpwK6sg6dPSi3vfsMtZHxsn7NrRDR2PZ3nabZQGTXLbeL/Uiz6O+/l0qWb5QI5qr TR8+DcT5Ozv9CrITJplnFtS6aGVAQ6Z5ZrlkWOUPfyR0= X-Received: by 2002:a05:600c:4617:b0:45b:7deb:3f07 with SMTP id 5b1f17b1804b1-45b7deb495fmr29290095e9.5.1756481488635; Fri, 29 Aug 2025 08:31:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqIpqtDTEzUzErYWJ417I16eY0x9D/bMIsQx2SY1DYNWVLkPhv5Owh18nRxW8wOpwO1kCo0A== X-Received: by 2002:a05:600c:4617:b0:45b:7deb:3f07 with SMTP id 5b1f17b1804b1-45b7deb495fmr29289835e9.5.1756481488143; Fri, 29 Aug 2025 08:31:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 08/18] cpus: document that qemu_cpu_kick() can be used for BQL-less operation Date: Fri, 29 Aug 2025 17:31:05 +0200 Message-ID: <20250829153115.1590048-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756567693942116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 23bd02277f4..8b57bcd92c9 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -829,7 +829,8 @@ bool qemu_cpu_is_self(CPUState *cpu); * qemu_cpu_kick: * @cpu: The vCPU to kick. * - * Kicks @cpu's thread. + * Kicks @cpu's thread to exit the accelerator. For accelerators that + * can do that, the target vCPU thread will try not to take the BQL. */ void qemu_cpu_kick(CPUState *cpu); =20 --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756567959; cv=none; d=zohomail.com; s=zohoarc; b=Jhl4ZFvO+kkULF9eMNWrrPxn7oDd8JAMPaYgdWOjh0cj2lzxOwMrE+OAkI53+GQNvwKH/jEGPiB90YCJp+/CQWtXMSjturfhcs2Y0VtJ5T51yxqoJFrcHiRmVwzdM7ItuW/1F2WoBOortP13Gl8LtMciC5fufz+qfbfaF/gb3Mc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756567959; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Il9fVLSXcWcC7+/gSGPAuA02qOumhhulMbyrxn4IdXI=; b=l5CHevJCH/DJWS7aiXmBRYz+dOJOXkuU7/wlZDbAOKM87whPd2NJIUbsK/gJj2pUeDG8ovo4THB3IqmsW8PYM8bv4wrUvzNs+mIVmYo2U+ncCZL+l+LKGOpoZ5wt3I13AR/zeZpHrFWDU9njU1WEwy0cDYQCA8TtjStPIlfzwho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756567959703136.58091129883712; Sat, 30 Aug 2025 08:32:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOa-0003vq-EV; Sat, 30 Aug 2025 11:21:36 -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 1us14o-0001pd-TE for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14j-0000Wh-Lh for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:42 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-mXV8banKMNq69OzpXNdSpw-1; Fri, 29 Aug 2025 11:31:35 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45b7d497abbso9698015e9.0 for ; Fri, 29 Aug 2025 08:31:34 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e887fdcsm43206055e9.13.2025.08.29.08.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Il9fVLSXcWcC7+/gSGPAuA02qOumhhulMbyrxn4IdXI=; b=i1sjlZD0E+k2N31EEm4D8v46YUfKi/yuGTDw54FQMclJxs4jnDPKIncPYo/dDCyxDWUgwk FqLtQQh+sfvHbk8Ix4UdXLSbwCECjBBgfOXtnmDh+5j9R3ZMGvtq3cvQrxrorVRNoiGHf2 VFe29O4Oyc1ARAt8FNv07FHbeqZr+eg= X-MC-Unique: mXV8banKMNq69OzpXNdSpw-1 X-Mimecast-MFC-AGG-ID: mXV8banKMNq69OzpXNdSpw_1756481494 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481493; x=1757086293; 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=Il9fVLSXcWcC7+/gSGPAuA02qOumhhulMbyrxn4IdXI=; b=E7QRrInlRAkCwCax1RFQ63rfvRBjDCqARKSLX5rNlNEtimZbP3veWNeZyavzYUsFvA vhCeONmW+w3tNKvspU0eu+UY77ilHfY9uvrq2FqcZofMpmVp91rnJapvODM3RP9xV2MR YQ+dVsSS6xEsEVQq6RRAbfPN7igdhFZz8Bq18BhoenshlNvA8CSqA7shHyA9AOad9FmS qHI94Tpelh70LqQ+otLxs2gfaokBCmhEUoJNof7/l+6TrNxznM9RcQ6ADeE234QtjTHn 1e8idcqSc/d2JmpFzrhgMzx6w8zwgRLoztJL7VddFhch/UUJUsKO7S20bucXaUx4I+// vVJA== X-Gm-Message-State: AOJu0YwzcYmDGXEIaeIxXNukJ+eu3wd7lqpEEi+lFYPyeffZWfcx7YXz gZ/NwWxDG1OYC6gAvi/mcTX2G1jB0lHvDtmNkga+joHGvzDT6xiY3b9PV/zvsUgznsf0At1q6W7 92G4KWc+o+MGwnAu3utHzuotR1OxOoEATgmDyrNNZuygvJM6zLsyGJ/76ZCKg7IR8eNQBmnYc3F Bia4d1B0ofjzs71uoot2kURqoY/Cdh1peyXNi3ENJj X-Gm-Gg: ASbGnctbTBUysjSfvVHR3AjCP2H9VMS/Uko0e5cPR/1Uy7ZKmJyeV6cDdQZ1bwLO/0g xCAFgxuHz8qDD7yJM0bz9QRsvoQzhVI4EcWdN45/TD87DPV6bQKGTTLhq8M1eloVHCFbQiKnI8N Rl3eZS/baIB6yqSf7ddTLxf8MQl6dwF9/Ek4HYCIQgSDC5yu3A3Z5Kj6REPtGnlatYk6Y9YpGeD 5t0WNnF1eJtS2miGVv2vi7FjPbXSNduKPVVn3pR/znK+72da1rxgHeiPuRoQ1is+wum2ZOM4VT0 u1Q2TVYM52E91oawXbbciLkovPSW2eB608oJz2O8bCo/O8uAJRUUNwsTQ+3+6aLS4Odh1rZnsHA XLgYSYW928nmGwr5+ajlTxATxR8iySAXG3xXy9d+ujx0= X-Received: by 2002:a05:600c:c87:b0:45b:47e1:ef76 with SMTP id 5b1f17b1804b1-45b517dfe11mr226904545e9.37.1756481492772; Fri, 29 Aug 2025 08:31:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZ0PgVX0P1ngjZik4srSxcKc3GT0bZbMIcmHMQfPUWXhmLJSzivFXQ/aVf8nwyqSALh/TTVQ== X-Received: by 2002:a05:600c:c87:b0:45b:47e1:ef76 with SMTP id 5b1f17b1804b1-45b517dfe11mr226904115e9.37.1756481492228; Fri, 29 Aug 2025 08:31:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 09/18] accel: use store_release/load_acquire for cross-thread exit_request Date: Fri, 29 Aug 2025 17:31:06 +0200 Message-ID: <20250829153115.1590048-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756567961057124100 Content-Type: text/plain; charset="utf-8" Reads and writes cpu->exit_request do not use a load-acquire/store-release pair right now, but this means that cpu_exit() may not write cpu->exit_requ= est after any flags that are read by the vCPU thread. Probably everything is protected one way or the other by the BQL, because cpu->exit_request leads to the slow path, where the CPU thread often takes the BQL (for example, to go to sleep by waiting on the BQL-protected cpu->halt_cond); but it's not clear, so use load-acquire/store-release consistently. Reviewed-by: Richard Henderson Reviewed-by: Peter Xu Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- accel/kvm/kvm-all.c | 19 +++++++++---------- accel/tcg/cpu-exec.c | 7 +++++-- accel/tcg/tcg-accel-ops-rr.c | 2 +- hw/core/cpu-common.c | 3 ++- target/i386/nvmm/nvmm-all.c | 5 ++--- target/i386/whpx/whpx-all.c | 3 ++- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f36dfe33492..bd9e5e3886d 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3029,10 +3029,6 @@ static void kvm_eat_signals(CPUState *cpu) =20 if (kvm_immediate_exit) { qatomic_set(&cpu->kvm_run->immediate_exit, 0); - /* Write kvm_run->immediate_exit before the cpu->exit_request - * write in kvm_cpu_exec. - */ - smp_wmb(); return; } =20 @@ -3187,7 +3183,8 @@ int kvm_cpu_exec(CPUState *cpu) } =20 kvm_arch_pre_run(cpu, run); - if (qatomic_read(&cpu->exit_request)) { + /* Corresponding store-release is in cpu_exit. */ + if (qatomic_load_acquire(&cpu->exit_request)) { trace_kvm_interrupt_exit_request(); /* * KVM requires us to reenter the kernel after IO exits to com= plete @@ -3197,13 +3194,15 @@ int kvm_cpu_exec(CPUState *cpu) kvm_cpu_kick_self(); } =20 - /* Read cpu->exit_request before KVM_RUN reads run->immediate_exit. - * Matching barrier in kvm_eat_signals. - */ - smp_rmb(); - run_ret =3D kvm_vcpu_ioctl(cpu, KVM_RUN, 0); =20 + /* + * After writing cpu->exit_request, cpu_exit() sends a signal that= writes + * kvm->run->immediate_exit. The signal is already happening afte= r the + * write to cpu->exit_request so, if KVM read kvm->run->immediate_= exit + * as true, cpu->exit_request will always read as true. + */ + attrs =3D kvm_arch_post_run(cpu, run); =20 #ifdef KVM_HAVE_MCE_INJECTION diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 508d2d2d9e2..f838535d111 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -851,8 +851,11 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } #endif /* !CONFIG_USER_ONLY */ =20 - /* Finally, check if we need to exit to the main loop. */ - if (unlikely(qatomic_read(&cpu->exit_request)) || icount_exit_request(= cpu)) { + /* + * Finally, check if we need to exit to the main loop. + * The corresponding store-release is in cpu_exit. + */ + if (unlikely(qatomic_load_acquire(&cpu->exit_request)) || icount_exit_= request(cpu)) { qatomic_set(&cpu->exit_request, 0); if (cpu->exception_index =3D=3D -1) { cpu->exception_index =3D EXCP_INTERRUPT; diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 6eec5c9eee9..1e551e92d6d 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -242,7 +242,7 @@ static void *rr_cpu_thread_fn(void *arg) cpu =3D first_cpu; } =20 - while (cpu && cpu_work_list_empty(cpu) && !cpu->exit_request) { + while (cpu && cpu_work_list_empty(cpu) && !qatomic_load_acquire(&c= pu->exit_request)) { /* Store rr_current_cpu before evaluating cpu_can_run(). */ qatomic_set_mb(&rr_current_cpu, cpu); =20 diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 9ea1f3764a8..ca00accd162 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -74,7 +74,8 @@ void cpu_reset_interrupt(CPUState *cpu, int mask) =20 void cpu_exit(CPUState *cpu) { - qatomic_set(&cpu->exit_request, 1); + /* Ensure cpu_exec will see the reason why the exit request was set. = */ + qatomic_store_release(&cpu->exit_request, true); /* 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/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index e1151b04c6e..10bd51d9b59 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -743,7 +743,8 @@ nvmm_vcpu_loop(CPUState *cpu) =20 nvmm_vcpu_pre_run(cpu); =20 - if (qatomic_read(&cpu->exit_request)) { + /* Corresponding store-release is in cpu_exit. */ + if (qatomic_load_acquire(&cpu->exit_request)) { #if NVMM_USER_VERSION >=3D 2 nvmm_vcpu_stop(vcpu); #else @@ -751,8 +752,6 @@ nvmm_vcpu_loop(CPUState *cpu) #endif } =20 - /* Read exit_request before the kernel reads the immediate exit fl= ag */ - smp_rmb(); ret =3D nvmm_vcpu_run(mach, vcpu); if (ret =3D=3D -1) { error_report("NVMM: Failed to exec a virtual processor," diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index c09a0a64f22..2106c29c3a0 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1714,7 +1714,8 @@ static int whpx_vcpu_run(CPUState *cpu) if (exclusive_step_mode =3D=3D WHPX_STEP_NONE) { whpx_vcpu_pre_run(cpu); =20 - if (qatomic_read(&cpu->exit_request)) { + /* Corresponding store-release is in cpu_exit. */ + if (qatomic_load_acquire(&cpu->exit_request)) { whpx_vcpu_kick(cpu); } } --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756569062; cv=none; d=zohomail.com; s=zohoarc; b=h1Z2wUbPdD/y542KSxigLUFnzy6sX54rzPzkLq+MOiy/Z5sQupv9THwfBiaMd5hGA9LkehvmIco3OjAh4VZor7ZJ011LQVEBLyOLRpkn8u+klEsH6r4Ka+Lzdh2Rwkp0YvYWBu+iRi4hx5t/4tIIVkpPDtzYeAJbLGDjMfkAib4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756569062; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+VEFfrQ6wYQXuSlplw9CE9p8BId4srOZeKt1LzTdYAs=; b=eNrWi8SuNqw67nZ8ufOnjw98WeMRRQfPbLsTWvOUEzdfMTQu6UVecF/P0fGHv4E2hEXQ5BxqEbRScrCPNQrv0iDztY1ZluD3eJ1FvwaXaTTFQRoi/CgBVnUF8mZaCFWExqWuW/jDNm+Q7Aqiz1Fm7MKsk897LOHzbvYHwDtJtHI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756569062563227.8546254461054; Sat, 30 Aug 2025 08:51:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOd-00049a-E4; Sat, 30 Aug 2025 11:21:39 -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 1us14x-0001s5-VD for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14p-0000XQ-L9 for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:47 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-UNCxd7-mOMC0Xj2MEln7fA-1; Fri, 29 Aug 2025 11:31:39 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45b80aecb97so5048565e9.3 for ; Fri, 29 Aug 2025 08:31:39 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e887fdcsm43208105e9.13.2025.08.29.08.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+VEFfrQ6wYQXuSlplw9CE9p8BId4srOZeKt1LzTdYAs=; b=C2owp/8Mj7AZGZ5372VG6l5BIbAjoRudP59X3oOWQC1sxyXIgF+IasYIphQZWW5kxp7MoH +hDRM2+nceHX8JJ8vgTQSwX03llsmydcFpEVOVjfPZRlcu3UqxpIOd6/Q+g3+N7NMgEmxo Xr01eK6EnJdKnLhiFQWXFtJqB1MOWgQ= X-MC-Unique: UNCxd7-mOMC0Xj2MEln7fA-1 X-Mimecast-MFC-AGG-ID: UNCxd7-mOMC0Xj2MEln7fA_1756481498 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481497; x=1757086297; 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=+VEFfrQ6wYQXuSlplw9CE9p8BId4srOZeKt1LzTdYAs=; b=CaI2DGUSC5VFswoaKzblHjt/un/dIWPALSbxEqtqfaBfNWFw0gBqI8KmNB88a4CleL xtqeCKQWTwpGsMZAHF9jDBBIKkMx3uwacfDj0DcJvGtLbzF/CT6lK9S9RKdnamWfidN7 MIc2FZlhmPO48TYAgR4dIAwD+AB8M4GaE+XH1REepMj4hRZiz7nDgZzyUSlZTLzxl8q7 c8H0U+lA2WblbAd5Lp7kaeSgaO5oS48qBDAY2X+BxClg06LFX5q85aWi7QyuVesNgbtd 2nt1TVaiXyELvjouMFqR3GOa1R8OLr0PZ1+RVtAlaxtCAT0pKL9GjO0xKDuJtXRRYAPV J8Nw== X-Gm-Message-State: AOJu0YwwAui8B+3er20z4y+N5A5MBVkk5z5kE03VDAHRT8Y3VDeScx27 85zQzNKY7uD8SVQBGv9EItGNEyv7yPuSNEW07LQ0oseTGPWhCwc9eQos2bpoF60a2lzkNJQNGfA 5kZRRFFb4lWpHae5XWACtZg2KsUCFPRDKnVfYq0yDvxvYy0+yeKZ/11mwCOUJ2GH/LmhHDPswmM 3lYT5rD7oARuHORTZ4dtiFzTQadjM6R6k0Bm3hyPDQ X-Gm-Gg: ASbGncsZlNkyLSFfV12nlZO90WADFQ5SuteP5k1cmcwc/F4wkf7XQS1iSfABNYAzI7j ycQLKRWnC9ZHp18jXLeY9n/GzHO9DV/iRX4oxfSpgpE36gcklFdso16BcrZPg3DG0P3CVUn+6z0 ox18S2D9JMYveUWZLU/vFmaMhJJDAt8XqvGzIRFpAIj6T0j01+P5491N3wotT/tSP6+d91UvjbZ 9+sBawcqj9XiLmA7bXfyqIpMOsrgVyhcCql8j9SCMOXv2fuBWveKkvIWLXAptiWMyXQVEd9NmxT fsRpKk18KwqPWdj7AYC/kEhhmjI2YupCT/jt/cyvVnu2CRBzOstMZWTlVGpIQg8p888gsV2q3fU 8a/VBYwkcPT2FX/4zZcyBkgfm7Fqcc8YY99jIQ3sJ38U= X-Received: by 2002:a05:600c:3544:b0:45b:7c4c:cfbf with SMTP id 5b1f17b1804b1-45b7c4cd1e7mr53014765e9.23.1756481497097; Fri, 29 Aug 2025 08:31:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcy+3rn7g6Vn8bodWtxBllDGdzOlI6nzqpScDek4uqhlPXxsfi6TxXEB4Cbe6mp7bs6twqZQ== X-Received: by 2002:a05:600c:3544:b0:45b:7c4c:cfbf with SMTP id 5b1f17b1804b1-45b7c4cd1e7mr53014345e9.23.1756481496520; Fri, 29 Aug 2025 08:31:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 10/18] accel: use atomic accesses for exit_request Date: Fri, 29 Aug 2025 17:31:07 +0200 Message-ID: <20250829153115.1590048-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756569063632124100 CPU threads write exit_request as a "note to self" that they need to go out to a slow path. This write happens out of the BQL and can be a data race with another threads' cpu_exit(); use atomic accesses consistently. While at it, change the source argument from int ("1") to bool ("true"). Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- include/hw/core/cpu.h | 9 +++++++++ accel/kvm/kvm-all.c | 2 +- accel/tcg/tcg-accel-ops-mttcg.c | 2 +- accel/tcg/tcg-accel-ops-rr.c | 4 ++-- hw/ppc/spapr_hcall.c | 6 +++--- target/i386/kvm/kvm.c | 6 +++--- target/i386/nvmm/nvmm-accel-ops.c | 2 +- target/i386/nvmm/nvmm-all.c | 2 +- target/i386/whpx/whpx-all.c | 6 +++--- 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 8b57bcd92c9..338757e5254 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -422,6 +422,15 @@ struct qemu_work_item; * valid under cpu_list_lock. * @created: Indicates whether the CPU thread has been successfully create= d. * @halt_cond: condition variable sleeping threads can wait on. + * @exit_request: Another thread requests the CPU to call qemu_wait_io_eve= nt(). + * Should be read only by CPU thread with load-acquire, to synchronize w= ith + * other threads' store-release operation. + * + * In some cases, accelerator-specific code will write exit_request from + * within the same thread, to "bump" the effect of qemu_cpu_kick() to + * the one provided by cpu_exit(), especially when processing interrupt + * flags. In this case, the write and read happen in the same thread + * and the write therefore can use qemu_atomic_set(). * @interrupt_request: Indicates a pending interrupt request. * Only used by system emulation. * @halted: Nonzero if the CPU is in suspended state. diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index bd9e5e3886d..e4167d94b4f 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3730,7 +3730,7 @@ int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void = *addr) have_sigbus_pending =3D true; pending_sigbus_addr =3D addr; pending_sigbus_code =3D code; - qatomic_set(&cpu->exit_request, 1); + qatomic_set(&cpu->exit_request, true); return 0; #else return 1; diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttc= g.c index 337b993d3da..b12b7a36b5d 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -85,7 +85,7 @@ static void *mttcg_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 /* process any pending work */ - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); =20 do { if (cpu_can_run(cpu)) { diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 1e551e92d6d..c2468d15d4f 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -212,7 +212,7 @@ static void *rr_cpu_thread_fn(void *arg) cpu =3D first_cpu; =20 /* process any pending work */ - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); =20 while (1) { /* Only used for icount_enabled() */ @@ -286,7 +286,7 @@ static void *rr_cpu_thread_fn(void *arg) /* Does not need a memory barrier because a spurious wakeup is oka= y. */ qatomic_set(&rr_current_cpu, NULL); =20 - if (cpu && cpu->exit_request) { + if (cpu && qatomic_read(&cpu->exit_request)) { qatomic_set_mb(&cpu->exit_request, 0); } =20 diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 1e936f35e44..51875e32a09 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -509,7 +509,7 @@ static target_ulong h_cede(PowerPCCPU *cpu, SpaprMachin= eState *spapr, if (!cpu_has_work(cs)) { cs->halted =3D 1; cs->exception_index =3D EXCP_HLT; - cs->exit_request =3D 1; + qatomic_set(&cs->exit_request, true); ppc_maybe_interrupt(env); } =20 @@ -531,7 +531,7 @@ static target_ulong h_confer_self(PowerPCCPU *cpu) } cs->halted =3D 1; cs->exception_index =3D EXCP_HALTED; - cs->exit_request =3D 1; + qatomic_set(&cs->exit_request, true); ppc_maybe_interrupt(&cpu->env); =20 return H_SUCCESS; @@ -624,7 +624,7 @@ static target_ulong h_confer(PowerPCCPU *cpu, SpaprMach= ineState *spapr, } =20 cs->exception_index =3D EXCP_YIELD; - cs->exit_request =3D 1; + qatomic_set(&cs->exit_request, true); cpu_loop_exit(cs); =20 return H_SUCCESS; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 8420c4090ef..34e74f24470 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -5486,10 +5486,10 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run= *run) if (cpu_test_interrupt(cpu, CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) { if (cpu_test_interrupt(cpu, CPU_INTERRUPT_INIT) && !(env->hflags & HF_SMM_MASK)) { - qatomic_set(&cpu->exit_request, 1); + qatomic_set(&cpu->exit_request, true); } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_TPR)) { - qatomic_set(&cpu->exit_request, 1); + qatomic_set(&cpu->exit_request, true); } } =20 @@ -5604,7 +5604,7 @@ int kvm_arch_process_async_events(CPUState *cs) if (env->exception_nr =3D=3D EXCP08_DBLE) { /* this means triple fault */ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - cs->exit_request =3D 1; + qatomic_set(&cs->exit_request, true); return 0; } kvm_queue_exception(env, EXCP12_MCHK, 0, 0); diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-acce= l-ops.c index 3799260bbde..86869f133e9 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -77,7 +77,7 @@ static void nvmm_start_vcpu_thread(CPUState *cpu) */ static void nvmm_kick_vcpu_thread(CPUState *cpu) { - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); cpus_kick_thread(cpu); } =20 diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index 10bd51d9b59..7e36c42fbb4 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -414,7 +414,7 @@ nvmm_vcpu_pre_run(CPUState *cpu) * or commit pending TPR access. */ if (cpu_test_interrupt(cpu, CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) { - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); } =20 if (!has_event && cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) { diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 2106c29c3a0..00fb7e23100 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1489,10 +1489,10 @@ static void whpx_vcpu_pre_run(CPUState *cpu) if (cpu_test_interrupt(cpu, CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) { if (cpu_test_interrupt(cpu, CPU_INTERRUPT_INIT) && !(env->hflags & HF_SMM_MASK)) { - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); } if (cpu_test_interrupt(cpu, CPU_INTERRUPT_TPR)) { - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); } } =20 @@ -1539,7 +1539,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) if (tpr !=3D vcpu->tpr) { vcpu->tpr =3D tpr; reg_values[reg_count].Reg64 =3D tpr; - cpu->exit_request =3D 1; + qatomic_set(&cpu->exit_request, true); reg_names[reg_count] =3D WHvX64RegisterCr8; reg_count +=3D 1; } --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756568532; cv=none; d=zohomail.com; s=zohoarc; b=L0BZoXVD3P+BphfuaMfH5CUr1xaEeHlrnfMOOS/HwT32dC4vquMZSBIkA3KTgBN7p54lR8mALLQZinpKI2tSk3+vcAqoeisxLcXiD7j00L2+qlRyolB41vkoX6LrlgOunmDQdfsMY+pG3B+9UPjGR1PfPcoILcXm/LyNRLnWZ4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756568532; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7ri8tfaP+olN7gHTTVouP5IWTFfLQvvzUr0uPOKLPHA=; b=LzIptDuiT9bCIkeRyDLKz4o/yw3xHNIyu9xeu2LJGos5VjgkeL2NBLe/tENmZTmda1duQlKIsDog7KMEiObHxjWOzHJ8RTpcnBGhS69ANkBMd5h4wV2h5NVWPQA4T3MQb8rjw56/9/h9cH8cmWBbc+jdJxr6eV3VCwyr3QtXmsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756568532513729.6378643769381; Sat, 30 Aug 2025 08:42:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOe-0004Bj-5n; Sat, 30 Aug 2025 11:21:40 -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 1us152-0001tD-4s for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14y-0000YM-0Z for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:55 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-RkCHi1CYPRezFAKjQhBlUQ-1; Fri, 29 Aug 2025 11:31:43 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45b7c01a6d3so8352335e9.2 for ; Fri, 29 Aug 2025 08:31:42 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf33add7f2sm4063344f8f.32.2025.08.29.08.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ri8tfaP+olN7gHTTVouP5IWTFfLQvvzUr0uPOKLPHA=; b=jJg8H034XAx16Du2bB0OMsawkxjA3uPM+mJazS/MuDtWmRuPMsj6rIQDTzA4BPt6fkHicw RzGN3YObuUcN5TRtx56oZuKSIg+pWPTfJBb7hcNo7rQqHnfZt/BvhS9RNpDAFhC1MN35mW Ak0dtrqGe4m5/mQDtyFKAylnwEhd9Rk= X-MC-Unique: RkCHi1CYPRezFAKjQhBlUQ-1 X-Mimecast-MFC-AGG-ID: RkCHi1CYPRezFAKjQhBlUQ_1756481501 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481500; x=1757086300; 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=7ri8tfaP+olN7gHTTVouP5IWTFfLQvvzUr0uPOKLPHA=; b=FPvKnI9yxNzDtOc9moMAnd1rCX2IIOdIrWnpNMOTjBmcydhUiDOS1GZ+S9j2rz5H70 +Y6IppUuO4JENmDCxvTFZvbDTQNyyDMjoZ+B6fB24DcMtHd5CjvtdncAVRk6Cci2cKAl 9FxU+1fFboc1US05YQMnDzOkhR24D1UCY9AfEouaS1YYDouDHjYmDr23YQMk/8fyJibO XXYyS9wY1eB9VA6iMG9witMsdmZw328HrVaUQF5EaoRKrw1Kw/qz1VUDklmZ5xWpFgjD CHfMAlw3qB1OdtTKNFeTQ+itYJ1Bm1HSMnkNJuUECvXAr8ckv4aUdiqDpaYqe4cjRDwn LZyA== X-Gm-Message-State: AOJu0YzqIxcbKFAYJKHrN+XTrF1iBfw5CB0+OXonVlt89eS1cakM/4+y NVIUU/zxFYy4w/1RTjsuFjYIAonmT6un62iV8IYP4GwNZcSZOb4lzhY50jkAupP7hIk3w62OiEq xzouOwJtXNuSiY11Xel2U1DZ/onXuSbAMnCWT/eltfXuTIjIbZt0gmdXxmZ3mVC8OR5R0PWLwMx Y7QhNshDN2VY7lF9ymWJPOAjK8I2jiW6rqYXFtYB9P X-Gm-Gg: ASbGnctgqfJJR2mgvD22Mjxi40VMS5JS844guGfa6Q9VFQnBb41S/NRtlHxFPU5APoy DN+3Dta9+1VxtNPg46g/5XhIUQsxgcGI9dOXcaHJ+DLsN21M/y/fgBGFv8fTvGj4+idwC4YpC2l tj1Tzw+YKsgeWudPL0RRWDityt1qGeKndCMgt3/3k9GDZgl+NcQvNhbPUddAbAd58ly7LAemdY1 DA3Ks2KzlamnN4CVrr8xhvRGzLNnoEIrrmxCzDvXfbPwPwfOfq99Xp6+N+OBRIr3mbJt9VS7pDg ur47mqrdSeb2cZt1/pdSBwTIfJozgO4xWKwhwTEfVH28Xu+xnEqpysUpGp2LDngqZUkZVmTy1Pw aGgiuPfpWuHMHBpbMRoPwDnRFnDw14gWMkuX6mhLV43w= X-Received: by 2002:a05:6000:18ad:b0:3b7:8892:ed8d with SMTP id ffacd0b85a97d-3c5da54ed40mr20282501f8f.6.1756481500368; Fri, 29 Aug 2025 08:31:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqqFrN01uzVzHLVl+FpqXWr4R4+yjYC6EtMpsdmOlp3W0ighiG6+zV3Icr2auqVGBgMDbOjQ== X-Received: by 2002:a05:6000:18ad:b0:3b7:8892:ed8d with SMTP id ffacd0b85a97d-3c5da54ed40mr20282469f8f.6.1756481499736; Fri, 29 Aug 2025 08:31:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 11/18] accel/tcg: create a thread-kick function for TCG Date: Fri, 29 Aug 2025 17:31:08 +0200 Message-ID: <20250829153115.1590048-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756568534213116600 Content-Type: text/plain; charset="utf-8" Round-robin TCG is calling into cpu_exit() directly. In preparation for making cpu_exit() usable from all accelerators, define a generic thread-kick function for TCG which is used directly in the multi-threaded case, and through CPU_FOREACH in the round-robin case. Use it also for user-mode emulation, and take the occasion to move the implementation to accel/tcg/user-exec.c. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- docs/devel/tcg-icount.rst | 2 +- accel/tcg/tcg-accel-ops-mttcg.h | 3 --- accel/tcg/tcg-accel-ops.h | 1 + accel/tcg/cpu-exec.c | 6 ++++++ accel/tcg/tcg-accel-ops-mttcg.c | 5 ----- accel/tcg/tcg-accel-ops-rr.c | 2 +- accel/tcg/tcg-accel-ops.c | 2 +- accel/tcg/user-exec.c | 6 ++++++ bsd-user/main.c | 5 ----- linux-user/main.c | 5 ----- 10 files changed, 16 insertions(+), 21 deletions(-) diff --git a/docs/devel/tcg-icount.rst b/docs/devel/tcg-icount.rst index 7df883446a7..a1dcd79e0fd 100644 --- a/docs/devel/tcg-icount.rst +++ b/docs/devel/tcg-icount.rst @@ -37,7 +37,7 @@ translator starts by allocating a budget of instructions = to be executed. The budget of instructions is limited by how long it will be until the next timer will expire. We store this budget as part of a vCPU icount_decr field which shared with the machinery for handling -cpu_exit(). The whole field is checked at the start of every +qemu_cpu_kick(). The whole field is checked at the start of every translated block and will cause a return to the outer loop to deal with whatever caused the exit. =20 diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/tcg-accel-ops-mttc= g.h index 8ffa7a9a9fe..5c145cc8595 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.h +++ b/accel/tcg/tcg-accel-ops-mttcg.h @@ -10,9 +10,6 @@ #ifndef TCG_ACCEL_OPS_MTTCG_H #define TCG_ACCEL_OPS_MTTCG_H =20 -/* kick MTTCG vCPU thread */ -void mttcg_kick_vcpu_thread(CPUState *cpu); - /* start an mttcg vCPU thread */ void mttcg_start_vcpu_thread(CPUState *cpu); =20 diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h index 6feeb3f3e9b..aecce605d7b 100644 --- a/accel/tcg/tcg-accel-ops.h +++ b/accel/tcg/tcg-accel-ops.h @@ -18,5 +18,6 @@ void tcg_cpu_destroy(CPUState *cpu); int tcg_cpu_exec(CPUState *cpu); void tcg_handle_interrupt(CPUState *cpu, int mask); void tcg_cpu_init_cflags(CPUState *cpu, bool parallel); +void tcg_kick_vcpu_thread(CPUState *cpu); =20 #endif /* TCG_ACCEL_OPS_H */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index f838535d111..9241bcadb5f 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -40,6 +40,7 @@ #include "exec/replay-core.h" #include "system/tcg.h" #include "exec/helper-proto-common.h" +#include "tcg-accel-ops.h" #include "tb-jmp-cache.h" #include "tb-hash.h" #include "tb-context.h" @@ -748,6 +749,11 @@ static inline bool cpu_handle_exception(CPUState *cpu,= int *ret) return false; } =20 +void tcg_kick_vcpu_thread(CPUState *cpu) +{ + cpu_exit(cpu); +} + static inline bool icount_exit_request(CPUState *cpu) { if (!icount_enabled()) { diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttc= g.c index b12b7a36b5d..1148ebcaae5 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -123,11 +123,6 @@ static void *mttcg_cpu_thread_fn(void *arg) return NULL; } =20 -void mttcg_kick_vcpu_thread(CPUState *cpu) -{ - cpu_exit(cpu); -} - void mttcg_start_vcpu_thread(CPUState *cpu) { char thread_name[VCPU_THREAD_NAME_SIZE]; diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index c2468d15d4f..610292d3bac 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -43,7 +43,7 @@ void rr_kick_vcpu_thread(CPUState *unused) CPUState *cpu; =20 CPU_FOREACH(cpu) { - cpu_exit(cpu); + tcg_kick_vcpu_thread(cpu); }; } =20 diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 9c37266c1e0..1f662a9c745 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -206,7 +206,7 @@ static void tcg_accel_ops_init(AccelClass *ac) =20 if (qemu_tcg_mttcg_enabled()) { ops->create_vcpu_thread =3D mttcg_start_vcpu_thread; - ops->kick_vcpu_thread =3D mttcg_kick_vcpu_thread; + ops->kick_vcpu_thread =3D tcg_kick_vcpu_thread; ops->handle_interrupt =3D tcg_handle_interrupt; } else { ops->create_vcpu_thread =3D rr_start_vcpu_thread; diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 66c25fba7dd..3c072fd868f 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -38,6 +38,7 @@ #include "qemu/int128.h" #include "trace.h" #include "tcg/tcg-ldst.h" +#include "tcg-accel-ops.h" #include "backend-ldst.h" #include "internal-common.h" #include "tb-internal.h" @@ -46,6 +47,11 @@ __thread uintptr_t helper_retaddr; =20 //#define DEBUG_SIGNAL =20 +void qemu_cpu_kick(CPUState *cpu) +{ + tcg_kick_vcpu_thread(cpu); +} + /* * Adjust the pc to pass to cpu_restore_state; return the memop type. */ diff --git a/bsd-user/main.c b/bsd-user/main.c index 7e5d4bbce09..fc33e4d4880 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -214,11 +214,6 @@ bool qemu_cpu_is_self(CPUState *cpu) return thread_cpu =3D=3D cpu; } =20 -void qemu_cpu_kick(CPUState *cpu) -{ - cpu_exit(cpu); -} - /* Assumes contents are already zeroed. */ static void init_task_state(TaskState *ts) { diff --git a/linux-user/main.c b/linux-user/main.c index 6edeeecef38..2ba073eb830 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -189,11 +189,6 @@ bool qemu_cpu_is_self(CPUState *cpu) return thread_cpu =3D=3D cpu; } =20 -void qemu_cpu_kick(CPUState *cpu) -{ - cpu_exit(cpu); -} - void task_settid(TaskState *ts) { if (ts->ts_tid =3D=3D 0) { --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756568257; cv=none; d=zohomail.com; s=zohoarc; b=MN24vq+zrKuI5Wt0udLm/bskFD66cyy2joK3maYir8bP3bM1dWyw777/woDob3ZqljuoCfhJQ9lHAGJtKezImDAdYLrvVjUNIzkY+teAlrrgW4Ge62Omlg9uNnDQwmcKy60Bwj0+fIBmGw7ufrQvoPFw8EPnO3Ly5EHPlcfbJzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756568257; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TU+ohCQldOE8jzcl9QfpH85Y+2xtKzIGiqUp+GEQ8Cc=; b=Wduov5DDe13/dgBUs8074I6c0KjGcgv5swf1J5uJSFg784krmIlcX4EM4PIDZKT5dPBKvVHE7IfR0xkSIMZBTt/C/XgJyxELs2ReVQ51Ym47xZHtMFzdYvrteGkKCL3cv+uepQEYSCSfRMsuTatOc3eid0QpfYEwmAEpxjzWSl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756568257834406.55778855908693; Sat, 30 Aug 2025 08:37:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOb-00043J-QP; Sat, 30 Aug 2025 11:21:37 -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 1us151-0001sv-A9 for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14y-0000Ya-4G for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:55 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-79-u9j31uDrMiC6J25rVZVjXg-1; Fri, 29 Aug 2025 11:31:47 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3d1114879a4so335802f8f.0 for ; Fri, 29 Aug 2025 08:31:46 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf33fba9c4sm3703019f8f.48.2025.08.29.08.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TU+ohCQldOE8jzcl9QfpH85Y+2xtKzIGiqUp+GEQ8Cc=; b=QmUhP86Fcsdm/qDZziFoEfJWf5BtRBZK7VVtcenV/UAmMgFrfoGUx3vFSr1QzqTwAoREim o5WtkN9XWtleFOMjo2ONNZW5u5TlvfWQaFVQ0auUYTx+2dRFi0J1WSMRpubjOYUqrNW7kA H+ZbJwwQvgUknAwhj0JvJWWYIEa/5WM= X-MC-Unique: u9j31uDrMiC6J25rVZVjXg-1 X-Mimecast-MFC-AGG-ID: u9j31uDrMiC6J25rVZVjXg_1756481506 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481505; x=1757086305; 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=TU+ohCQldOE8jzcl9QfpH85Y+2xtKzIGiqUp+GEQ8Cc=; b=tb2IMrCZwzZA0mdVyiwSNwOE30In82w72/f+qW8mJzasI8RBR+4B2ClPo6zmWplbwC IrjyMc6S6q2SpXaUvXH3HSH1qRCSU0slw9SlhNYnL6s2hYjqF9u2YUCGoTkds8feOr3l c1J7TxpAo3eLuOFRw0RjWAUkRZyB1QQRVHVysdsatW2pO/yauGhpEFeThyB1PJ75i7Z/ JuvGkffW8djKjG6kuKeUl6fU7rAsw6bDAWLu667g+6cpAI9uNfz+4GCdpbs5cB9Jd3M9 NjLwL3NL11UaqOiChTOXIw1orAxYydB4RGNTsw2VJkDuMyaSHzqP79yFYYBGb9NKsnou fFkA== X-Gm-Message-State: AOJu0YwW+7BEDON68JZ+LAnQOFog03UdE63lLivMoqFXYUyNhqIpfzdF mOI4HBThWAeCXL4ajWVoAvUuAQEEmNiabie5zPahc3Qlh7YGVdFzEclQXxW1lnqPnBQGCpwHtfb BQO03vKgor6+DBhSKIBNF+y2QPfL11GtqDQ9yG9YnB+k0orIwIPym2+c6oNl2u4mJlFPZkAZeOG FcimsSFKO5ImnWTdhr/1vLaB+YPCmpDopMBafxck1f X-Gm-Gg: ASbGncvzWKOceERlXGJ1ZPKBcYUlQ6Eoa121FO9iUqQ//NjGAR1J075r0fQ1YKU4g85 GbPgk9B6jHshJfXA+/0B6cvf4m97AmiVMo0n9Ybu0gTcwgSu0PV0i51v4N/4Q98BRxrP/6Eeh5G MX9qbcwCuH/DBcIMxab5d5nAwc4UtS+5+8OPPhrNRPTDDZ9xzh7FjwoV2oyJz22fC912rx4PKqe gu5bLw3LlqL+QH9sfkRmI2PYGSLtqd12WGqeMOvAMFQqKMO7zC/lCKOalgRP302PQ9e62luhhc1 OOZUqINL8EaheWLNMcR3ZfNpp3FT70Hwd6pVZgbBHXTDOtsGtIE6OVXkluvRocmxPVuMiHZK4ma a6cvRlAY6Wx7wiIUkvehxlWPqcEOCUVsIuhwvbDBwlZ0= X-Received: by 2002:a05:6000:4021:b0:3ce:f0a5:d56d with SMTP id ffacd0b85a97d-3cef0a5dcd0mr3284104f8f.29.1756481504932; Fri, 29 Aug 2025 08:31:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3fNvGmLL2L+TNMGiG0RAJ1/h7IlaHvOaUVfCOBvMbWXq5vkegRGJi9mW+Ms8D8wcZX1melw== X-Received: by 2002:a05:6000:4021:b0:3ce:f0a5:d56d with SMTP id ffacd0b85a97d-3cef0a5dcd0mr3284070f8f.29.1756481504374; Fri, 29 Aug 2025 08:31:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 12/18] accel/tcg: inline cpu_exit() Date: Fri, 29 Aug 2025 17:31:09 +0200 Message-ID: <20250829153115.1590048-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756568260439124101 Content-Type: text/plain; charset="utf-8" Right now, cpu_exit() is not usable from all accelerators because it includes a TCG-specific thread kick. In fact, cpu_exit() doubles as the TCG thread-kick via tcg_kick_vcpu_thread(). In preparation for changing that, inline cpu_exit() into tcg_kick_vcpu_thread(). The direction of the calls can then be reversed, with an accelerator-independent cpu_exit() calling into qemu_vcpu_kick() rather than the opposite. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- accel/tcg/cpu-exec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 9241bcadb5f..3ae545e888f 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -751,7 +751,16 @@ static inline bool cpu_handle_exception(CPUState *cpu,= int *ret) =20 void tcg_kick_vcpu_thread(CPUState *cpu) { - cpu_exit(cpu); + /* + * Ensure cpu_exec will see the reason why the exit request was set. + * FIXME: this is not always needed. Other accelerators instead + * read interrupt_request and set exit_request on demand from the + * CPU thread; see kvm_arch_pre_run() for example. + */ + qatomic_store_release(&cpu->exit_request, true); + + /* Ensure cpu_exec will see the exit request after TCG has exited. */ + qatomic_store_release(&cpu->neg.icount_decr.u16.high, -1); } =20 static inline bool icount_exit_request(CPUState *cpu) @@ -780,7 +789,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, /* Clear the interrupt flag now since we're processing * cpu->interrupt_request and cpu->exit_request. * Ensure zeroing happens before reading cpu->exit_request or - * cpu->interrupt_request (see also smp_wmb in cpu_exit()) + * cpu->interrupt_request (see also store-release in + * tcg_kick_vcpu_thread()) */ qatomic_set_mb(&cpu->neg.icount_decr.u16.high, 0); =20 --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756568505; cv=none; d=zohomail.com; s=zohoarc; b=kEp28MwtbS8Q/H4FQmqOU+DMs1ZG4lW8XaUDsj1ftNnY1GXxVUF3QNSYRYhvzaHU1xvfkJ2mstXa7RMvn4pF8HH7QghTXs9IGxrwPMNHdt6megLqfEZuL4x9cxI1ApE+hbwGSczMX7iFvDSB+66TpU7hyWbCWgLF5DUYfU3Iewo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756568505; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OIZ/GEl4kDZnmqyRnHirJQEA0qTP8X+DRdscFCyUtVA=; b=bu9y+K32HjzsBo1hNBKwDTefDzNOiVgrlDauCLXaeGa1337qUaZTdHRUkNaG/Shr1KqipNx9ZGF1rr8KLHIuGgNCNpcaCEvvK6P5JDR2kWeTVcNhyEJcOQl6wbuo4+C/vuuXOPWsLCVbRBnSKo00s9Cc9Fmi4y3Al23EijjTqtk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756568505512261.28709663626546; Sat, 30 Aug 2025 08:41:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOe-0004Bk-6l; Sat, 30 Aug 2025 11:21:40 -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 1us156-0001uJ-Gn for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us14y-0000Ym-TE for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:00 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-qwF_9CVeOBmi4zXSukoHhQ-1; Fri, 29 Aug 2025 11:31:49 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45b7c4c738cso7744605e9.0 for ; Fri, 29 Aug 2025 08:31:49 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e7d23ddsm42693385e9.4.2025.08.29.08.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OIZ/GEl4kDZnmqyRnHirJQEA0qTP8X+DRdscFCyUtVA=; b=FNcjlZioLMFxCTpr0mv4JM/KNc7jtd9j4W96FAIqOlj+YJMgPuK4NA8xBNPr/tsxAMRD7g goExU1QzT0gOaC2KvzO+fYh0pb+kf+9xGGhjrYULJ0uDgr6RwsDAuB3ggHp0ctI72OfC1I 37mAF1p6cnVdzM9X6beOtl3fte784rs= X-MC-Unique: qwF_9CVeOBmi4zXSukoHhQ-1 X-Mimecast-MFC-AGG-ID: qwF_9CVeOBmi4zXSukoHhQ_1756481508 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481507; x=1757086307; 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=OIZ/GEl4kDZnmqyRnHirJQEA0qTP8X+DRdscFCyUtVA=; b=mC2kerPsz/kHKtH6YiW8QtvmJJbY2dDS51tBnl1BApUafPii4RhdA3elYAywCRzAJS Va2I2WWf3ZIqb7YFsxvRfetwiaUC7GWDKttOgnIzmaNHKfjeNvmPb4DS4lHECH/JWV+C /SHlFf06TwBxxqCattcl6tx8fOjge/BitKa7HPhKAdnMTZC4OCEVk9eXp7Dj0oQw2o96 EdGKdZSlwMWzLePf0e9o4SR0uRHeIS2hJxPjc7Xsn/fvc35BDxAj3mnHcp5NZeI9i4IA vWHq/OtFQRdfM5YUOxh+Y8vvp5AWWV+qOlKzr4H0cSZ9f40+emCoXOM68cmjBIaXXFwu DyPw== X-Gm-Message-State: AOJu0YzPN4MdCaqgLeZIQxyy8n1YjeIvc0PulBiY7aZo++6+IIxUpM9H Zr4zW8Xpk4YvTGjOTLBjW+D4LbpiU8h6EPM3KDS0sT3RWBqdwNNgXdOAsoKuCIdNA8El83FBHf8 xr9xGo9we6eE2iunGMPs9oJ38WRqCSzLq7BoCzRj5goLc/FmXuYHT61GojBZWGSHyzOKOjC3CXX Tvhn0z3cgBx0i9AHLLrwwaYD5e1qoV9lGGDz/uMV+6 X-Gm-Gg: ASbGnct3/M+fXIgcVqWNElv2HhS6jQUvoUpOvUCgW8CzG5pSV3F1xFlj5H/pRpfvIIr 9uyHVF/JYj36f1NE1vPcq+BR7dFYKKNChARFHBPVAJRnAfAdMtKvAxo73g2adndvgGYS6nlmQPS Y8i7kZ+GpVOuEUg79Rt0sfkiuS4GQPYHm9nv1vuk18UV0zcfeyt1OVAR0oUaB8MObC5wcnEacf9 srrhVPouad9RGOW1ZhGDshyIPAZljgeTpGL4iyi70h2qXEpl8Cf8IjdtXnUUjB5lH+AFRQSQTMR Tg2Q++4MRv99muNOjUY6A49JI6hZ0vDeH14amX4dcJ8zOm4dvJa6JJxw1odSrq2LpJ8hlUXUUiw rw1yWqhZct+XCABiy0LXeT0BYa09Z5RgNRR/Z4sfYBLA= X-Received: by 2002:a05:600c:1d06:b0:455:ed48:144f with SMTP id 5b1f17b1804b1-45b5179669dmr207493335e9.14.1756481507442; Fri, 29 Aug 2025 08:31:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGh04SToA6KYjoF4S/pMtkzcIwTEud5hYK9UbJmkplEPhrtexHOBlCZlpUS2Fp2EfJGvi8VKQ== X-Received: by 2002:a05:600c:1d06:b0:455:ed48:144f with SMTP id 5b1f17b1804b1-45b5179669dmr207493045e9.14.1756481507029; Fri, 29 Aug 2025 08:31:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 13/18] cpus: remove TCG-ism from cpu_exit() Date: Fri, 29 Aug 2025 17:31:10 +0200 Message-ID: <20250829153115.1590048-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756568507136124100 Now that TCG has its own kick function, make cpu_exit() do the right kick for all accelerators. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- hw/core/cpu-common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ca00accd162..3fa9fa82228 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -76,9 +76,7 @@ void cpu_exit(CPUState *cpu) { /* Ensure cpu_exec will see the reason why the exit request was set. = */ qatomic_store_release(&cpu->exit_request, true); - /* Ensure cpu_exec will see the exit request after TCG has exited. */ - smp_wmb(); - qatomic_set(&cpu->neg.icount_decr.u16.high, -1); + qemu_cpu_kick(cpu); } =20 static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, in= t reg) --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756568242; cv=none; d=zohomail.com; s=zohoarc; b=l1wfOTqrRXHNm0QSsZKNleRKDhcw6ADRkrVlopvfL4XksNAH9+wWVuSRhTCK2II2mbZAC/qlE0Lx28aTKk96kCk1RvMr93gzgVtD8R5hoS/ryznCR6mrTRugL5BD1TToZEG3o0GkgphsTYlXREIXHvKWBqetq7Pgp71W7TQpq5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756568242; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3PkxGeX9T+Pbn++peZb7XxFUEJB9Ya56yMRu7fcEwv4=; b=kvEXMO6e5SQnqKAvOvc4R27aRO65zkBsHAfiR3YCZ0GBbI/ZQC/gs4Ytst5S61b7JSISarVXc9YZhF/9ae+E0FObA9YDmH6bB+9Pes5BsI/LeWbB/NrXnzZ/w9Z3GGgSVEuPFAh4WTHts6M3JPsR/K2DuTF7udMeK5CiAsINwBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756568242721609.2882577997323; Sat, 30 Aug 2025 08:37:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOb-00043H-Rx; Sat, 30 Aug 2025 11:21:37 -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 1us153-0001td-Uw for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us151-0000ZL-5q for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:31:57 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-JLvvCd-kOlSF5i2eCh7glg-1; Fri, 29 Aug 2025 11:31:52 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45a1b05d31cso11221765e9.1 for ; Fri, 29 Aug 2025 08:31:51 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e7d2393sm43224695e9.3.2025.08.29.08.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3PkxGeX9T+Pbn++peZb7XxFUEJB9Ya56yMRu7fcEwv4=; b=i0k+cs5IeIbUNz2x7SjvNCPalA/sKZUzugj2cxk+ES5qhM8ePPDPBWbCdoqzrSh1OW0YY8 vbWz/ff32mlGKkCDHCJCtH1yVKfRCLpP4Rr/vo+JnW0kprFEe+Zn+YW/3S0nF6fcwGyStK 6HDsrXTX20kDzZrMhqwfvzhsq5pyXEQ= X-MC-Unique: JLvvCd-kOlSF5i2eCh7glg-1 X-Mimecast-MFC-AGG-ID: JLvvCd-kOlSF5i2eCh7glg_1756481511 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481510; x=1757086310; 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=3PkxGeX9T+Pbn++peZb7XxFUEJB9Ya56yMRu7fcEwv4=; b=fpJnxXggwN0KnN3WC1er1PPl660KHkimM7zvsuDgMn+wMqfKGhLJotn/aGyj5oJf55 hpIjJcQKBqv1ldeCHqXHQMd9h3iri+/thFxk6ZlzyDkj65NwP+f9OeBmaj1WcfVPRW0K I1668U/RmL0sYUSNaOvcnerKfQOV2em+N1F5s6CEW6wWWdDqlTwhZB7thVuW4ux73XCZ KloOVCYOUKs/chY7QP2f/zRtkUFpgliZbk08L4uBkm9mPYWJg+va/d4wgbCIP6RHTV2O EfZZnTBNx2XjiD3FOxi1j1ygIBuNliFGMAr5XN2a2Z2ChSeWDBpJrCPGNc17wnyDaMTA Bgcw== X-Gm-Message-State: AOJu0YxXZ8ipj0bcUYZCUsQHkE+5DrQT/9d0YPtVlAliZqO3MEfegshe syTtcABdq/S0KRn9+gmucYBmSboGq/aCiVtzXLs4LGrGe845GRaPtkHMFfuctDXWE4Uf7LxuzMn rvnhwocyL6pHumxeM2hSiluKejVRjS2PCWchz5Md052BMkMC8vCd4S+yem+6Y5IGJHf0f1LV+Sm 8JE/VYYSt8eTYeFDwRgRml57uRfoFjW+Otq+nYp4oj X-Gm-Gg: ASbGncscR49z1mZoaICTGhFRufwNgmhX3zuesZNMpcSMOQEjQeIzs6S3c+7BJpsb2Ph lA9idAhbmq2EGCTqPnolCqr7q6Jyou4s0hWf1aJU/WgmyTFYhDiLZVLum4egUdd4Kp9U+sVW/aJ 4jvpdp0wBmIBcgPAVZt5E63ibdhmBN34dqKe8gK+Y5bogLEX00X7P/Mmrxye2fi/rATg2OHXC5l QFkggyvO11bnNOpni3tx913fAl8p9hMwPqoOuPqS5IqE2dI8W32T9Irxo+CG1ADAJfXl/lDr5mG LZi9h3oomMY7XUk7x8oCx0fAzybSBRizQ2Uu204+rWdsJeGWe70HgqubZm4i1UXFRZvj67tg98D A4/4HJff4qKsF++lVFmykeCs5LcumcvzufR9vngKM8bo= X-Received: by 2002:a5d:584f:0:b0:3ca:6a35:13ff with SMTP id ffacd0b85a97d-3ca6a351850mr14209960f8f.19.1756481509886; Fri, 29 Aug 2025 08:31:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPJTkM+LgAZnxpvyi444avC23qMjSuRAgrlH3VolZyPSwbXaHy8rGjXOrXJo87O71bFPFYXg== X-Received: by 2002:a5d:584f:0:b0:3ca:6a35:13ff with SMTP id ffacd0b85a97d-3ca6a351850mr14209937f8f.19.1756481509423; Fri, 29 Aug 2025 08:31:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 14/18] cpus: properly kick CPUs out of inner execution loop Date: Fri, 29 Aug 2025 17:31:11 +0200 Message-ID: <20250829153115.1590048-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756568244800116600 Content-Type: text/plain; charset="utf-8" Now that cpu_exit() actually kicks all accelerators, use it whenever the message to another thread is processed in qemu_wait_io_event(). Signed-off-by: Paolo Bonzini --- cpu-common.c | 3 ++- hw/ppc/ppc.c | 2 ++ hw/ppc/spapr_hcall.c | 7 +++---- hw/ppc/spapr_rtas.c | 2 +- replay/replay-events.c | 3 ++- system/cpu-timers.c | 6 +++--- system/cpus.c | 5 +++-- target/arm/tcg/mte_helper.c | 2 +- target/i386/kvm/hyperv.c | 1 - 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cpu-common.c b/cpu-common.c index ef5757d23bf..152661df8e9 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -137,7 +137,8 @@ static void queue_work_on_cpu(CPUState *cpu, struct qem= u_work_item *wi) wi->done =3D false; qemu_mutex_unlock(&cpu->work_mutex); =20 - qemu_cpu_kick(cpu); + /* exit the inner loop and reach qemu_wait_io_event_common(). */ + cpu_exit(cpu); } =20 void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data da= ta, diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 43d0d0e7553..3e436c70413 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -190,6 +190,7 @@ static void ppc970_set_irq(void *opaque, int pin, int l= evel) if (level) { trace_ppc_irq_cpu("stop"); cs->halted =3D 1; + cpu_exit(cs); } else { trace_ppc_irq_cpu("restart"); cs->halted =3D 0; @@ -386,6 +387,7 @@ static void ppc40x_set_irq(void *opaque, int pin, int l= evel) if (level) { trace_ppc_irq_cpu("stop"); cs->halted =3D 1; + cpu_exit(cs); } else { trace_ppc_irq_cpu("restart"); cs->halted =3D 0; diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 51875e32a09..c594d4b916e 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -509,8 +509,8 @@ static target_ulong h_cede(PowerPCCPU *cpu, SpaprMachin= eState *spapr, if (!cpu_has_work(cs)) { cs->halted =3D 1; cs->exception_index =3D EXCP_HLT; - qatomic_set(&cs->exit_request, true); ppc_maybe_interrupt(env); + cpu_exit(cs); } =20 return H_SUCCESS; @@ -531,8 +531,8 @@ static target_ulong h_confer_self(PowerPCCPU *cpu) } cs->halted =3D 1; cs->exception_index =3D EXCP_HALTED; - qatomic_set(&cs->exit_request, true); ppc_maybe_interrupt(&cpu->env); + cpu_exit(cs); =20 return H_SUCCESS; } @@ -624,8 +624,7 @@ static target_ulong h_confer(PowerPCCPU *cpu, SpaprMach= ineState *spapr, } =20 cs->exception_index =3D EXCP_YIELD; - qatomic_set(&cs->exit_request, true); - cpu_loop_exit(cs); + cpu_exit(cs); =20 return H_SUCCESS; } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 78309dbb09d..143bc8c3794 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -221,7 +221,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, SpaprMachin= eState *spapr, cs->halted =3D 1; ppc_store_lpcr(cpu, env->spr[SPR_LPCR] & ~pcc->lpcr_pm); kvmppc_set_reg_ppc_online(cpu, 0); - qemu_cpu_kick(cs); + cpu_exit(cs); } =20 static void rtas_ibm_suspend_me(PowerPCCPU *cpu, SpaprMachineState *spapr, diff --git a/replay/replay-events.c b/replay/replay-events.c index 8959da9f1fa..a96e47e7740 100644 --- a/replay/replay-events.c +++ b/replay/replay-events.c @@ -118,7 +118,8 @@ void replay_add_event(ReplayAsyncEventKind event_kind, =20 g_assert(replay_mutex_locked()); QTAILQ_INSERT_TAIL(&events_list, event, events); - qemu_cpu_kick(first_cpu); + /* Kick the TCG thread out of tcg_cpu_exec(). */ + cpu_exit(first_cpu); } =20 void replay_bh_schedule_event(QEMUBH *bh) diff --git a/system/cpu-timers.c b/system/cpu-timers.c index cb35fa62b8a..6a00691b8d5 100644 --- a/system/cpu-timers.c +++ b/system/cpu-timers.c @@ -246,14 +246,14 @@ void qemu_timer_notify_cb(void *opaque, QEMUClockType= type) =20 if (qemu_in_vcpu_thread()) { /* - * A CPU is currently running; kick it back out to the + * A CPU is currently running; kick it back out of the * tcg_cpu_exec() loop so it will recalculate its * icount deadline immediately. */ - qemu_cpu_kick(current_cpu); + cpu_exit(current_cpu); } else if (first_cpu) { /* - * qemu_cpu_kick is not enough to kick a halted CPU out of + * cpu_exit() is not enough to kick a halted CPU out of * qemu_tcg_wait_io_event. async_run_on_cpu, instead, * causes cpu_thread_is_idle to return false. This way, * handle_icount_deadline can run. diff --git a/system/cpus.c b/system/cpus.c index 9bfbe2b0607..bb13942cbb7 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -604,7 +604,7 @@ void cpu_pause(CPUState *cpu) qemu_cpu_stop(cpu, true); } else { cpu->stop =3D true; - qemu_cpu_kick(cpu); + cpu_exit(cpu); } } =20 @@ -644,6 +644,7 @@ void pause_all_vcpus(void) =20 while (!all_vcpus_paused()) { qemu_cond_wait(&qemu_pause_cond, &bql); + /* FIXME: is this needed? */ CPU_FOREACH(cpu) { qemu_cpu_kick(cpu); } @@ -672,7 +673,7 @@ void cpu_remove_sync(CPUState *cpu) { cpu->stop =3D true; cpu->unplug =3D true; - qemu_cpu_kick(cpu); + cpu_exit(cpu); bql_unlock(); qemu_thread_join(cpu->thread); bql_lock(); diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c index 0efc18a181e..302e899287c 100644 --- a/target/arm/tcg/mte_helper.c +++ b/target/arm/tcg/mte_helper.c @@ -591,7 +591,7 @@ static void mte_async_check_fail(CPUARMState *env, uint= 64_t dirty_ptr, * which is rather sooner than "normal". But the alternative * is waiting until the next syscall. */ - qemu_cpu_kick(env_cpu(env)); + cpu_exit(env_cpu(env)); #endif } =20 diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c index 9865120cc43..f7a81bd2700 100644 --- a/target/i386/kvm/hyperv.c +++ b/target/i386/kvm/hyperv.c @@ -81,7 +81,6 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exi= t *exit) * necessary because memory hierarchy is being changed */ async_safe_run_on_cpu(CPU(cpu), async_synic_update, RUN_ON_CPU_NUL= L); - cpu_exit(CPU(cpu)); =20 return EXCP_INTERRUPT; case KVM_EXIT_HYPERV_HCALL: { --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756574343; cv=none; d=zohomail.com; s=zohoarc; b=ZmxXpFmMEJV5fUFxDI6cjllcAs7wjCUQUcT/KnRNo0XJPq78aTOuRI/xd3e9VVdyf+SWNRvTV0E1UJ9YtP4dfNlZrL8RNVFvlgUxQnwnAqF6WkJ/9Tjlp6EMlzV40+tV/EMIbuYvlLo4fV49npH4JtfL1r3/neDPLV3JPBu/NC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756574343; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mZd6LcPXZdEGsNumQwGYHNC9F7djFaIPp8BsfVJR/SE=; b=hDxRWaykhqMsZmcFEVrtJGLI/evtp33DbYb6I99A+xN9brRvmIaBXvfWEKlP7Ng+DvYDuTtV65yKwJ73l+4FhZMGwPs5nyLzUBfii1hZgzosCQE8g0ryzFbYl2rxguaYKR0RcPAWEnpIEcdLBxzPA7xEBCoWdBCNaPwwXuIcqf0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17565743435181002.4021107407472; Sat, 30 Aug 2025 10:19:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOf-0004Ht-Tt; Sat, 30 Aug 2025 11:21:42 -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 1us159-0001we-9K for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us156-0000aC-Eh for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:02 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-7ELIpv2pPjyvXbwKTPMWeA-1; Fri, 29 Aug 2025 11:31:55 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3d17731acb6so108986f8f.3 for ; Fri, 29 Aug 2025 08:31:55 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf270fc3fasm3808697f8f.5.2025.08.29.08.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mZd6LcPXZdEGsNumQwGYHNC9F7djFaIPp8BsfVJR/SE=; b=DcCbsy45+HfpEwQesm+T0+W+t0efDL6vMG/MfEF8mp5bIHvcYQ3dicCmLyEP1bekXCsMkY VAzGjN+YQr4g95bVy6WCkXqmU33fhIgf+UVE9bjpx2v3M/1qngylTpBpiNBT9RnBmXorRy tAD1Qw4n1llsYrfrdVCZaoDtwiJN97g= X-MC-Unique: 7ELIpv2pPjyvXbwKTPMWeA-1 X-Mimecast-MFC-AGG-ID: 7ELIpv2pPjyvXbwKTPMWeA_1756481514 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481513; x=1757086313; 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=mZd6LcPXZdEGsNumQwGYHNC9F7djFaIPp8BsfVJR/SE=; b=rpTLClKXmO76K8XXObSTJCFzyohgnB/MtfTw3hbh97hR0IndE2NXcvWy48e1sMmCe1 JY/iG2tC1qU0u0TuWc4W7qH1d6sF0rsf8dAUy6azUYh+t/UES4VHZWrEewKIF6PRvbY4 yszBLPWznj7gIEDOP0qAmGJbxN6OS93adt6Qo3Dg13qbvPk8nh0kcldU0Pe7Ew0lAixT yD1LS2QR5201Rx6mtIG7lwIKXY7ADFfSMSAnNwQJ2DJKmYujmKDhJu3cK8Jdu8YGzms6 wZ5OArOuRaar2qIsRyLOp+O9vgtRnxoGrb1Dl1zgCht3tlecKqfPgjsYTul301oA4L7w UCrw== X-Gm-Message-State: AOJu0YwP0WcL5dSLAnZSMpDdB4YrxXzDRJ81taOWhhZrVs2VIYgbuJxf /7BVd5YGDfsV5u0Rl/nCDrv+KLPKZCSMfdUsjJiL03gLm3eiTpryi423j6f2peDnHOQSs3t8UP6 P4uzWzkCI3dC5xOnVHusuqxfArCVAVt9FicCsLTWDgRE0jQGMKxzzocW2nRlJzMnM+l3V7Fewxs F2UgdFhrw7ub/1Bao+4S8DxRLBzChtizx8CElNr3df X-Gm-Gg: ASbGncviDQw4nowMIdKYBA3RcHGM99WeorCjx1JitoKBVxcCjFLHA8pfaJ6Znxec9eh 0bNLVwLLR0QBebWSonYlqmpuSn+9c27rlZrYGp4LLem3u1dSzRdC9dPPUJyevsJYdgUPkbmZZ6m Seljup/ET+Pe47ZsP0zBmaotvcvtXgdjDjbKnYKFDm3PA4MNIN/CS5yfq/H5FUxJ5l6qW8INBhl J5DueFocFhRZApvjw4LHkYTC5nMDITcZeP/QRQFjrEFsw7B2V4yJ9h7fmJsP+zmUvEmO+FGT1n8 HRpeAItBTOb1F8m5wv3W4Vhz0xIbkIfjUykHY/dnmoguNPyAc8IJa5i/Z1xkfyDXYHZ91bLvd5u +PkZMNeam8KipBpX/dFrNELeDz4gE/FDaOjL6uwLdeYo= X-Received: by 2002:a05:6000:26cf:b0:3d0:affe:ed78 with SMTP id ffacd0b85a97d-3d0affef23dmr1781203f8f.48.1756481512510; Fri, 29 Aug 2025 08:31:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpjxQoiKkiNhPX7y4x/G4G1LOYrqQ3UlvdwDnJLH0wNDNWd0TcF6xq1w9zp6zHqqvxRgAeSQ== X-Received: by 2002:a05:6000:26cf:b0:3d0:affe:ed78 with SMTP id ffacd0b85a97d-3d0affef23dmr1781171f8f.48.1756481511986; Fri, 29 Aug 2025 08:31:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 15/18] bsd-user, linux-user: introduce qemu_wait_io_event Date: Fri, 29 Aug 2025 17:31:12 +0200 Message-ID: <20250829153115.1590048-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756574345551124100 Content-Type: text/plain; charset="utf-8" Add a user-mode emulation version of the function. More will be added later, for now it is just process_queued_cpu_work. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- bsd-user/aarch64/target_arch_cpu.h | 2 +- bsd-user/arm/target_arch_cpu.h | 2 +- bsd-user/i386/target_arch_cpu.h | 2 +- bsd-user/riscv/target_arch_cpu.h | 2 +- bsd-user/x86_64/target_arch_cpu.h | 2 +- include/hw/core/cpu.h | 9 +++++++++ include/system/cpus.h | 1 - accel/tcg/user-exec.c | 5 +++++ linux-user/aarch64/cpu_loop.c | 2 +- linux-user/alpha/cpu_loop.c | 2 +- linux-user/arm/cpu_loop.c | 2 +- linux-user/hexagon/cpu_loop.c | 2 +- linux-user/hppa/cpu_loop.c | 2 +- linux-user/i386/cpu_loop.c | 2 +- linux-user/loongarch64/cpu_loop.c | 2 +- linux-user/m68k/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 2 +- linux-user/mips/cpu_loop.c | 2 +- linux-user/openrisc/cpu_loop.c | 2 +- linux-user/ppc/cpu_loop.c | 2 +- linux-user/riscv/cpu_loop.c | 2 +- linux-user/s390x/cpu_loop.c | 2 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- linux-user/xtensa/cpu_loop.c | 2 +- 25 files changed, 36 insertions(+), 23 deletions(-) diff --git a/bsd-user/aarch64/target_arch_cpu.h b/bsd-user/aarch64/target_a= rch_cpu.h index 87fbf6d6775..4407f35fb97 100644 --- a/bsd-user/aarch64/target_arch_cpu.h +++ b/bsd-user/aarch64/target_arch_cpu.h @@ -54,7 +54,7 @@ static inline G_NORETURN void target_cpu_loop(CPUARMState= *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_SWI: diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index bc2eaa0bf4e..a79ecf15f8f 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -46,7 +46,7 @@ static inline G_NORETURN void target_cpu_loop(CPUARMState= *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); switch (trapnr) { case EXCP_UDEF: case EXCP_NOCP: diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cp= u.h index 5d4c931decd..592702a8a1e 100644 --- a/bsd-user/i386/target_arch_cpu.h +++ b/bsd-user/i386/target_arch_cpu.h @@ -113,7 +113,7 @@ static inline G_NORETURN void target_cpu_loop(CPUX86Sta= te *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case 0x80: { diff --git a/bsd-user/riscv/target_arch_cpu.h b/bsd-user/riscv/target_arch_= cpu.h index ef92f004803..dbe7c7231f5 100644 --- a/bsd-user/riscv/target_arch_cpu.h +++ b/bsd-user/riscv/target_arch_cpu.h @@ -49,7 +49,7 @@ static inline G_NORETURN void target_cpu_loop(CPURISCVSta= te *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 signo =3D 0; =20 diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arc= h_cpu.h index f82042e30af..f298fbc9808 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -121,7 +121,7 @@ static inline G_NORETURN void target_cpu_loop(CPUX86Sta= te *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_SYSCALL: diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 338757e5254..ffa553b2318 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1145,6 +1145,15 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, i= nt asidx); G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...) G_GNUC_PRINTF(2, 3); =20 +/** + * qemu_wait_io_event: + * @cpu: CPU that left the execution loop + * + * Perform accelerator-independent work after the CPU has left + * the inner execution loop. + */ +void qemu_wait_io_event(CPUState *cpu); + /* $(top_srcdir)/cpu.c */ void cpu_class_init_props(DeviceClass *dc); void cpu_exec_class_post_init(CPUClass *cc); diff --git a/include/system/cpus.h b/include/system/cpus.h index 69be6a77a75..e6864861c0b 100644 --- a/include/system/cpus.h +++ b/include/system/cpus.h @@ -18,7 +18,6 @@ bool cpu_thread_is_idle(CPUState *cpu); bool all_cpu_threads_idle(void); bool cpu_can_run(CPUState *cpu); void qemu_wait_io_event_common(CPUState *cpu); -void qemu_wait_io_event(CPUState *cpu); void cpu_thread_signal_created(CPUState *cpu); void cpu_thread_signal_destroyed(CPUState *cpu); void cpu_handle_guest_debug(CPUState *cpu); diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 3c072fd868f..81906d2e033 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -52,6 +52,11 @@ void qemu_cpu_kick(CPUState *cpu) tcg_kick_vcpu_thread(cpu); } =20 +void qemu_wait_io_event(CPUState *cpu) +{ + process_queued_cpu_work(cpu); +} + /* * Adjust the pc to pass to cpu_restore_state; return the memop type. */ diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 4c4921152e8..9d0f09c3a13 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -38,7 +38,7 @@ void cpu_loop(CPUARMState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_SWI: diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index 728b64906d9..1f2d1c5565f 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -35,7 +35,7 @@ void cpu_loop(CPUAlphaState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_RESET: diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 9aeb9b0087f..026a189b884 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -295,7 +295,7 @@ void cpu_loop(CPUARMState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch(trapnr) { case EXCP_UDEF: diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c index 25c97edcaef..675c157a3de 100644 --- a/linux-user/hexagon/cpu_loop.c +++ b/linux-user/hexagon/cpu_loop.c @@ -36,7 +36,7 @@ void cpu_loop(CPUHexagonState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_INTERRUPT: diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 3af50653bb7..a8e715cb59b 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -119,7 +119,7 @@ void cpu_loop(CPUHPPAState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_SYSCALL: diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 7b2d8b03d84..7af476c9d44 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -214,7 +214,7 @@ void cpu_loop(CPUX86State *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch(trapnr) { case 0x80: diff --git a/linux-user/loongarch64/cpu_loop.c b/linux-user/loongarch64/cpu= _loop.c index a0a4cbb7cc3..dc83118e389 100644 --- a/linux-user/loongarch64/cpu_loop.c +++ b/linux-user/loongarch64/cpu_loop.c @@ -27,7 +27,7 @@ void cpu_loop(CPULoongArchState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_INTERRUPT: diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index aca0bf23dc6..5b62260212d 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -33,7 +33,7 @@ void cpu_loop(CPUM68KState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch(trapnr) { case EXCP_ILLEGAL: diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_l= oop.c index d8277961c73..a7f3f0e6a68 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -32,7 +32,7 @@ void cpu_loop(CPUMBState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_INTERRUPT: diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index e67b8a2e463..9ac4af6ae52 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -74,7 +74,7 @@ void cpu_loop(CPUMIPSState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch(trapnr) { case EXCP_SYSCALL: diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c index 8c72347a99a..9512e34e2af 100644 --- a/linux-user/openrisc/cpu_loop.c +++ b/linux-user/openrisc/cpu_loop.c @@ -33,7 +33,7 @@ void cpu_loop(CPUOpenRISCState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_SYSCALL: diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index 22885ffd906..3b5d775a49f 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -77,7 +77,7 @@ void cpu_loop(CPUPPCState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 arch_interrupt =3D true; switch (trapnr) { diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index b3162815320..940fd67f7b3 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -36,7 +36,7 @@ void cpu_loop(CPURISCVState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_INTERRUPT: diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c index 49e44548f85..be179a073f6 100644 --- a/linux-user/s390x/cpu_loop.c +++ b/linux-user/s390x/cpu_loop.c @@ -64,7 +64,7 @@ void cpu_loop(CPUS390XState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case EXCP_INTERRUPT: diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index 259ea1cc8bb..a7edd52e37c 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -34,7 +34,7 @@ void cpu_loop(CPUSH4State *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case 0x160: diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7d30cd1ff22..b9228708bf4 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -220,7 +220,7 @@ void cpu_loop (CPUSPARCState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 switch (trapnr) { case TARGET_TT_SYSCALL: diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c index 43a194fc4a4..bf19377dc29 100644 --- a/linux-user/xtensa/cpu_loop.c +++ b/linux-user/xtensa/cpu_loop.c @@ -133,7 +133,7 @@ void cpu_loop(CPUXtensaState *env) cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); - process_queued_cpu_work(cs); + qemu_wait_io_event(cs); =20 env->sregs[PS] &=3D ~PS_EXCM; switch (trapnr) { --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756574067; cv=none; d=zohomail.com; s=zohoarc; b=VRpx3gq8UwqUF4MwHxE3EwXnle9AyqIMzed6y3kRVcEpVYY6PgRgfERsmJB5L0LqdZeCmrF9VEr1vT+fY+FBigP0gGGU6lJJfhmk6/9nBUQNeTpmMCMGq00SqfmPIQK0GQiXtJSHXgxB/KJmhT/Ox3rAYKuRLbu5RhWtcfS4rqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756574067; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RU656r1zopCHhkasbtOtRNl8eqkrSuEKMSPB6VC/E24=; b=ekAUq9z+y40S4oA0DncKcvHQfV6/jHkci8hXmCga8Qbh7wFHdCbyp1MmdG44M6xR2wbDKPSK9dyc2EL/DzLhPtmatvaLxFYkojR+aKrvmEm7MvWrjPvqFFHZgd/rmvqZSd7eWz7vSe0KV8mfPDNwJZUylqH+WI98MOu6jo+3FIQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756574067079863.1325673181334; Sat, 30 Aug 2025 10:14:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOf-0004Ee-80; Sat, 30 Aug 2025 11:21:41 -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 1us15A-0001xi-Fh for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us158-0000aj-8c for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:04 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-27-4iMoxjDVP1q6kodJljr_Zg-1; Fri, 29 Aug 2025 11:31:59 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ccd58af2bbso1162390f8f.0 for ; Fri, 29 Aug 2025 08:31:58 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf33fb9431sm3756297f8f.44.2025.08.29.08.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RU656r1zopCHhkasbtOtRNl8eqkrSuEKMSPB6VC/E24=; b=SzZdXMs+tcRsxeQf5iEs19ruV/ckIxwpC4EvQji0GhucjpdiYgE+Jsszpx/tB9flwGpxAM 78yRjZ9NWtCXRGMEhtPAoi60AyMMQ/vY19ID2dC+pAfRes1i6EF2NMQDC0NYXnszQWn3DG tB4qJwWGnny2Bw1xdwuWqBx+nOc5oRc= X-MC-Unique: 4iMoxjDVP1q6kodJljr_Zg-1 X-Mimecast-MFC-AGG-ID: 4iMoxjDVP1q6kodJljr_Zg_1756481518 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481517; x=1757086317; 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=RU656r1zopCHhkasbtOtRNl8eqkrSuEKMSPB6VC/E24=; b=uiNXrTbspZmsYE1On6rdNfSdY6P6iWHCDK2s+pRagbU78Z+QMyxQp1HnSiWv29eAzx XTe7YWUgopbFot11F3yV++qJ1YxYBySemqoHiJ89d0LzvzmWT3+eP8hCLv7Wdl9l1Y+5 c4JubLfvaiZpX695c6PxFeI7gmq0Ys5RqDTaQCtVR4ge4fmq/WcOD1yvyR/dryJAT0Bz QejtHKQsdjKXua1o2I5f8MjQWh82PR1gx1XVgvsTAyzr/ymskn7C29qxfMhFBgcdK3AJ RWDGVXjrV6zl0wIvESekqjViInoxRVfL/ETeSnXmZcZFonafE8vwI1du0r8ij4uIduct tPoQ== X-Gm-Message-State: AOJu0YxoYSPmVFahveJskzvKLVrVTa/KeYjuZXmjcjqSXtypG6KZ/m51 8Hn2nV/q3EdG6MLj5mR6tPmC7PUrDD7SN/zqtaHmYebOZ8cwZWfTpc3xMsTWuk9oyZSJZPgS+nD JebVSUNsU6x5jZ7lEvSElbU6zYbRgKZr5UzZXQusyIMmwlEC05bLSY2OvJgox9c/0FSZjcBnFnF zyOvbCegqA7AoxdgikEG9UCuLBn4EMaY65uyNxqUS/ X-Gm-Gg: ASbGncuQH91d5kVlRRHybRZ9yMxwi48Onv6upGNpjHgUbC6EKHRjlGU1C86+bE8OTXs QxmK8Dpa3mv9/FpUsNIvOTW5Ndo0ZTY8SEtICiZzhNBGG45gooCHu1tEBY1iMdT2speuuCgqI2f 9WEtHO+xGhzbU8Vbak0L0lxKEGxXKVp21CgJNlPHwbRNiNTOeBIWvFo4YKgxJtdnt16/XPNyIL5 F6btehzCoU+FfC2XpyTid/m51PKxaoB3CkrGRfLJNV2Ur6ImhHlTGrj1lSOelXYkq9fYKbtW7dz oSx/M/mIIh9kbNCXtCrPtyiUefFDC59YAbf6pClfxAWzUlYhfjxNlo8+wvL2SABlvsXZCwgscsu 6AX88j40SkfJv8fQ+ZT7/QaPffF9wykR4XF8tsSfL9l0= X-Received: by 2002:a05:6000:2f86:b0:3c2:95c8:b71a with SMTP id ffacd0b85a97d-3cbb15ca0a0mr11998798f8f.5.1756481516948; Fri, 29 Aug 2025 08:31:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFj24O12qFLqJew2DlCZx1qddZf6WrHJ+phrvUbezL+awgZqH+ttarVp/je5O8qWqu1xFwJCA== X-Received: by 2002:a05:6000:2f86:b0:3c2:95c8:b71a with SMTP id ffacd0b85a97d-3cbb15ca0a0mr11998759f8f.5.1756481516470; Fri, 29 Aug 2025 08:31:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 16/18] cpus: clear exit_request in qemu_wait_io_event Date: Fri, 29 Aug 2025 17:31:13 +0200 Message-ID: <20250829153115.1590048-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756574068476124100 Content-Type: text/plain; charset="utf-8" Make the code common to all accelerators: after seeing cpu->exit_request set to true, accelerator code needs to reach qemu_wait_io_event_common(). So for the common cases where they use qemu_wait_io_event(), go ahead and clear it in there. Note that the cheap qatomic_set() is enough because at this point the thread has taken the BQL; qatomic_set_mb() is not needed. In particular, this is the ordering of the communication between I/O and vCPU threads is always the same. In the I/O thread: (a) store other memory locations that will be checked if cpu->exit_request or cpu->interrupt_request is 1 (for example cpu->stop or cpu->work_list for cpu->exit_request) (b) cpu_exit(): store-release cpu->exit_request, or (b) cpu_interrupt(): store-release cpu->interrupt_request >>> at this point, cpu->halt_cond is broadcast and the BQL released (c) do the accelerator-specific kick (e.g. write icount_decr for TCG, pthread_kill for KVM, etc.) In the vCPU thread instead the opposite order is respected: (c) the accelerator's execution loop exits thanks to the kick (b) then the inner execution loop checks cpu->interrupt_request and cpu->exit_request. If needed cpu->interrupt_request is converted into cpu->exit_request when work is needed outside the execution loop. (a) then the other memory locations are checked. Some may need to be read under the BQL, but the vCPU thread may also take other locks (e.g. for queued work items) or none at all. qatomic_set_mb() would only be needed if the halt sleep was done outside the BQL (though in that case, cpu->exit_request probably would be replaced by a QemuEvent or something like that). Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson --- accel/kvm/kvm-all.c | 2 -- accel/tcg/cpu-exec.c | 1 - accel/tcg/tcg-accel-ops-rr.c | 9 +++++++-- accel/tcg/tcg-accel-ops.c | 2 -- accel/tcg/user-exec.c | 1 + system/cpus.c | 1 + target/i386/nvmm/nvmm-all.c | 2 -- target/i386/whpx/whpx-all.c | 2 -- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e4167d94b4f..d13156bee87 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3155,7 +3155,6 @@ int kvm_cpu_exec(CPUState *cpu) trace_kvm_cpu_exec(); =20 if (kvm_arch_process_async_events(cpu)) { - qatomic_set(&cpu->exit_request, 0); return EXCP_HLT; } =20 @@ -3345,7 +3344,6 @@ int kvm_cpu_exec(CPUState *cpu) vm_stop(RUN_STATE_INTERNAL_ERROR); } =20 - qatomic_set(&cpu->exit_request, 0); return ret; } =20 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 3ae545e888f..ad94f96b252 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -872,7 +872,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, * The corresponding store-release is in cpu_exit. */ if (unlikely(qatomic_load_acquire(&cpu->exit_request)) || icount_exit_= request(cpu)) { - qatomic_set(&cpu->exit_request, 0); if (cpu->exception_index =3D=3D -1) { cpu->exception_index =3D EXCP_INTERRUPT; } diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 610292d3bac..e9d291dc391 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -286,8 +286,13 @@ static void *rr_cpu_thread_fn(void *arg) /* Does not need a memory barrier because a spurious wakeup is oka= y. */ qatomic_set(&rr_current_cpu, NULL); =20 - if (cpu && qatomic_read(&cpu->exit_request)) { - qatomic_set_mb(&cpu->exit_request, 0); + if (cpu) { + /* + * This could even reset exit_request for all CPUs, but in pra= ctice + * races between CPU exits and changes to "cpu" are so rare th= at + * there's no advantage in doing so. + */ + qatomic_set(&cpu->exit_request, false); } =20 if (icount_enabled() && all_cpu_threads_idle()) { diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 1f662a9c745..3bd98005042 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -82,8 +82,6 @@ int tcg_cpu_exec(CPUState *cpu) ret =3D cpu_exec(cpu); cpu_exec_end(cpu); =20 - qatomic_set_mb(&cpu->exit_request, 0); - return ret; } =20 diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 81906d2e033..8f4f049b924 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -54,6 +54,7 @@ void qemu_cpu_kick(CPUState *cpu) =20 void qemu_wait_io_event(CPUState *cpu) { + qatomic_set(&cpu->exit_request, false); process_queued_cpu_work(cpu); } =20 diff --git a/system/cpus.c b/system/cpus.c index bb13942cbb7..f989d9938b6 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -463,6 +463,7 @@ void qemu_wait_io_event(CPUState *cpu) { bool slept =3D false; =20 + qatomic_set(&cpu->exit_request, false); while (cpu_thread_is_idle(cpu)) { if (!slept) { slept =3D true; diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index 7e36c42fbb4..ed424251673 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -817,8 +817,6 @@ nvmm_vcpu_loop(CPUState *cpu) cpu_exec_end(cpu); bql_lock(); =20 - qatomic_set(&cpu->exit_request, false); - return ret < 0; } =20 diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 00fb7e23100..2a85168ed51 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2050,8 +2050,6 @@ static int whpx_vcpu_run(CPUState *cpu) whpx_last_vcpu_stopping(cpu); } =20 - qatomic_set(&cpu->exit_request, false); - return ret < 0; } =20 --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756574943; cv=none; d=zohomail.com; s=zohoarc; b=Oufkm6lHc7ZUBJGAAy/8LcNz+TNkE/WQwIi5qKfanxBQEY7IwDVo18itgZ6QewoQgUh6bwv7k3F+CR444Ob3Y0S/HyVqUCl2WtQY1OCNXiTfaSQDqdLkBb/asScTCISEY2UA/lsDbwAioYvSMlab235EI57pRTGs2eHabCzvXn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756574943; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5xEtUsJi2kRdlofIL/bHxeoYx243AvCSlnxju7PVGk0=; b=ODgGRzHCaFdw/geoW+kAAK1e4LIXPsgcjyS9USQytoXvqmD6vVSb93AB56ifIwqBvQ8DTYkAlaGbOPT8oOxucM9xYaYeVS/X4m0zORJpwQIRnwIjB+LXBSbTx5WnF/fbqxCiFhtsx0xqi8m4zIJ60s9mGCLsJoO8I4yj43FUF/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756574943353486.2150900716024; Sat, 30 Aug 2025 10:29:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOh-0004Mw-QN; Sat, 30 Aug 2025 11:21:44 -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 1us15C-0001zT-5U for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us15A-0000b5-1h for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:06 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-tYLIXmZBN--ZCbROzjxejQ-1; Fri, 29 Aug 2025 11:32:01 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3c9bf5c8b12so1265934f8f.0 for ; Fri, 29 Aug 2025 08:32:01 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf270fd01csm3911965f8f.12.2025.08.29.08.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5xEtUsJi2kRdlofIL/bHxeoYx243AvCSlnxju7PVGk0=; b=HLNn/KWudYJOcKIXGw/K2unJouyiMOrA1+6wqsFAzpkuVm7eiPY85DwK+8ZM34lWPkYEqb Mvh9KASjpT2CvB/WF4Ik8yrCVP7j7yv3ud+K6EE3wCfvzglsHcQ6LDRlMHDeTnBNCMATmT 3ydlOkOl72L0ZGm0dvCkcN0KDtV+U0w= X-MC-Unique: tYLIXmZBN--ZCbROzjxejQ-1 X-Mimecast-MFC-AGG-ID: tYLIXmZBN--ZCbROzjxejQ_1756481520 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481520; x=1757086320; 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=5xEtUsJi2kRdlofIL/bHxeoYx243AvCSlnxju7PVGk0=; b=q3TMNusGc9rilVK+eaukrOt3jAEqkrEwt6sFwkEGPz8/30zgbUKqfCbYy8eTiXhtDr keHPpKtoqvW6k9U/e5MrDbsNOWhXbZw3dtzFaMJt41ioIHU2Vn4Tw+3LxmDrsl/atjfc r6Ox/41oj+ebXVmHuxHsFC+P9RPTnh/WJfevlrKYRQK/iJWNXBNwQEuRt8lD3x3hcKZU fUHpX04bwxCMTCtTYRZjlUMGQD+z27f72bQ5njpLnPF6Eh3yEgeYOnpPCUU3PSAgtCLa 8W5agALjcCFA8QN0G/Bi8qm1eRB6KF3E4OuVn8jtcWdtzgLeL486qQ4nyAMKbwXjffsT 0LNQ== X-Gm-Message-State: AOJu0Yxi5mgT3ibjG/LI7QM++BLw/o8Jx3oqpE//DgEzoOBCCkxqyabo bo3PgRXtJccVbm/qSEY8kTa/NGZK3Kh/Nc5QeGFbaxkxB9EjJ3w8IcrfLzSa53gmJgUYevi6VxL 4sZjhiy5/Va+gEpbr5OWqwekhpHnLSFwLEZntGVvwujGJefJHL/5PSfWS1zt8d590JFROCWkHTn +yR9yeskNX8p11wIG8J6JYyi4KAYVKyGS2+Eqc3+M4 X-Gm-Gg: ASbGncszu5Lec7nGQ18Z60TogxyED2zxCVhf7ixyPs+WHQMbAQrmyf2g3v3UVHz0O+Z ciPBd+xn0Gp7XZ0RpCTisNr0gUVMUQ62O5uD1pblRD5v01r0UjBMKSBcFKTDXi795jkDY1QaPvQ sGy7mo3h9OQmIgrYMJSq9SsvP/MhKjNrtyMOW/1128UfIhzWfSIC4i1OXK0d8Wn9szuQy08IH9y gp0oAFFBUC1HEWEwCpxlh5IsABsdOPExtJZmDUB7n04uTDfi+NXCqsRckfIxheSiflh6deXyibY tNKQg0M71WfKejoRCvMkxBjNV5gjnw7VHYOtKWacR5e2kMGVO2RRVk2ycQwHfOsU3CHk+orQl70 fBldKS/deetmMMX7NNmMQXfrRgbyt1VUFaMwqz96mQPA= X-Received: by 2002:a05:6000:288c:b0:3c7:e6d0:b1b6 with SMTP id ffacd0b85a97d-3cbb15c9be8mr12089818f8f.9.1756481519868; Fri, 29 Aug 2025 08:31:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDd0hSecw53TDIY0Eq5K2Ve1opxUjoRN2WNO7QmHlB76yVxirGLYKu0o6muX+xVYkkkKrsOw== X-Received: by 2002:a05:6000:288c:b0:3c7:e6d0:b1b6 with SMTP id ffacd0b85a97d-3cbb15c9be8mr12089781f8f.9.1756481519316; Fri, 29 Aug 2025 08:31:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 17/18] accel: make all calls to qemu_wait_io_event look the same Date: Fri, 29 Aug 2025 17:31:14 +0200 Message-ID: <20250829153115.1590048-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756574944794116600 Content-Type: text/plain; charset="utf-8" There is no reason for some accelerators to use qemu_wait_io_event_common (which is separated from qemu_wait_io_event() specifically for round robin). They can also check for events directly on the first pass through the loop, instead of setting cpu->exit_request to true. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- accel/dummy-cpus.c | 2 +- accel/hvf/hvf-accel-ops.c | 2 +- accel/kvm/kvm-accel-ops.c | 3 ++- accel/tcg/tcg-accel-ops-mttcg.c | 7 ++--- accel/tcg/tcg-accel-ops-rr.c | 43 ++++++++++++++----------------- target/i386/nvmm/nvmm-accel-ops.c | 6 ++--- target/i386/whpx/whpx-accel-ops.c | 6 ++--- 7 files changed, 30 insertions(+), 39 deletions(-) diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c index 03cfc0fa01e..1f74c727c42 100644 --- a/accel/dummy-cpus.c +++ b/accel/dummy-cpus.c @@ -43,6 +43,7 @@ static void *dummy_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 do { + qemu_wait_io_event(cpu); bql_unlock(); #ifndef _WIN32 do { @@ -57,7 +58,6 @@ static void *dummy_cpu_thread_fn(void *arg) qemu_sem_wait(&cpu->sem); #endif bql_lock(); - qemu_wait_io_event(cpu); } while (!cpu->unplug); =20 bql_unlock(); diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index d488d6afbac..4ba3e40831f 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -192,13 +192,13 @@ static void *hvf_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 do { + qemu_wait_io_event(cpu); if (cpu_can_run(cpu)) { r =3D hvf_vcpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } - qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 hvf_vcpu_destroy(cpu); diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index b709187c7d7..80f0141a8a6 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -47,13 +47,14 @@ static void *kvm_vcpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 do { + qemu_wait_io_event(cpu); + if (cpu_can_run(cpu)) { r =3D kvm_cpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } - qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 kvm_destroy_vcpu(cpu); diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttc= g.c index 1148ebcaae5..04012900a30 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -84,10 +84,9 @@ static void *mttcg_cpu_thread_fn(void *arg) cpu_thread_signal_created(cpu); qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 - /* process any pending work */ - qatomic_set(&cpu->exit_request, true); - do { + qemu_wait_io_event(cpu); + if (cpu_can_run(cpu)) { int r; bql_unlock(); @@ -112,8 +111,6 @@ static void *mttcg_cpu_thread_fn(void *arg) break; } } - - qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 tcg_cpu_destroy(cpu); diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index e9d291dc391..28897288db7 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -211,13 +211,30 @@ static void *rr_cpu_thread_fn(void *arg) =20 cpu =3D first_cpu; =20 - /* process any pending work */ - qatomic_set(&cpu->exit_request, true); - while (1) { /* Only used for icount_enabled() */ int64_t cpu_budget =3D 0; =20 + if (cpu) { + /* + * This could even reset exit_request for all CPUs, but in pra= ctice + * races between CPU exits and changes to "cpu" are so rare th= at + * there's no advantage in doing so. + */ + qatomic_set(&cpu->exit_request, false); + } + + if (icount_enabled() && all_cpu_threads_idle()) { + /* + * When all cpus are sleeping (e.g in WFI), to avoid a deadlock + * in the main_loop, wake it up in order to start the warp tim= er. + */ + qemu_notify_event(); + } + + rr_wait_io_event(); + rr_deal_with_unplugged_cpus(); + bql_unlock(); replay_mutex_lock(); bql_lock(); @@ -285,26 +302,6 @@ static void *rr_cpu_thread_fn(void *arg) =20 /* Does not need a memory barrier because a spurious wakeup is oka= y. */ qatomic_set(&rr_current_cpu, NULL); - - if (cpu) { - /* - * This could even reset exit_request for all CPUs, but in pra= ctice - * races between CPU exits and changes to "cpu" are so rare th= at - * there's no advantage in doing so. - */ - qatomic_set(&cpu->exit_request, false); - } - - if (icount_enabled() && all_cpu_threads_idle()) { - /* - * When all cpus are sleeping (e.g in WFI), to avoid a deadlock - * in the main_loop, wake it up in order to start the warp tim= er. - */ - qemu_notify_event(); - } - - rr_wait_io_event(); - rr_deal_with_unplugged_cpus(); } =20 g_assert_not_reached(); diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-acce= l-ops.c index 86869f133e9..f51244740d8 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -42,16 +42,14 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 do { + qemu_wait_io_event(cpu); + if (cpu_can_run(cpu)) { r =3D nvmm_vcpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } - while (cpu_thread_is_idle(cpu)) { - qemu_cond_wait_bql(cpu->halt_cond); - } - qemu_wait_io_event_common(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 nvmm_destroy_vcpu(cpu); diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-acce= l-ops.c index da58805b1a6..611eeedeef7 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -42,16 +42,14 @@ static void *whpx_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); =20 do { + qemu_wait_io_event(cpu); + if (cpu_can_run(cpu)) { r =3D whpx_vcpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } - while (cpu_thread_is_idle(cpu)) { - qemu_cond_wait_bql(cpu->halt_cond); - } - qemu_wait_io_event_common(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 whpx_destroy_vcpu(cpu); --=20 2.51.0 From nobody Sat Sep 6 03:50:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1756574652; cv=none; d=zohomail.com; s=zohoarc; b=MhZUbqgLwRGIFjW3ziQ8KNNdkxFglJHB/IowlcLiCxA4PppyjiZb8qwAsiCEBOZuhOtyZsvpvzWY2c2I6n4soipaM1I/LpH8OZvN8FQ5fYJ0xThfCDcCQDjs3k/oeQp6/5UQMTqMMPwcRlKTCo2Bq04niuYElHmpvhfNtjr5FlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756574652; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jUNUdhp/2kvl0t2rlFqMP5IKnOgcmAf+2Ax3cFj3WDc=; b=gW6ML8LG4MQ9us373G9VADgBMbUaVvX0WViUViPkRDaqo472uRBt2zNFMD+u4ZLjOr9pHDGwnAoZoABb45n9dn7tXCwbspe7r1NtmIGiIQHuuhFV6ojf+SRyvVI6Se8wbmEY0JEciR9NylRaQbbJ9uiBd+eC5/uIOx0FSCQZnmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756574652493813.5182183506188; Sat, 30 Aug 2025 10:24:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1usNOh-0004LH-7T; Sat, 30 Aug 2025 11:21:43 -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 1us15E-00020n-Kc for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1us15C-0000be-TI for qemu-devel@nongnu.org; Fri, 29 Aug 2025 11:32:08 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-oZtP84KqOYS8ZYaEbJ0DKQ-1; Fri, 29 Aug 2025 11:32:04 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45b7d497abbso9700525e9.0 for ; Fri, 29 Aug 2025 08:32:04 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf340b3f6esm3712275f8f.54.2025.08.29.08.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 08:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756481525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jUNUdhp/2kvl0t2rlFqMP5IKnOgcmAf+2Ax3cFj3WDc=; b=fJ3cSmUCHhgYG2zexZuKwguEyr8F7zC8MA/eXuD3rvqzvlo3ba21CdZ83d/Cs3jaLsF08P Xr3U1NskItlVZO177whlfVQ0zFaGA2UQO7/SQz0CeZ3LWmFGOIBBpvU9REWZxTI9C3QNUc QrtCg0f7I1wzwNFZmtkhDB2mA0epye8= X-MC-Unique: oZtP84KqOYS8ZYaEbJ0DKQ-1 X-Mimecast-MFC-AGG-ID: oZtP84KqOYS8ZYaEbJ0DKQ_1756481524 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756481523; x=1757086323; 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=jUNUdhp/2kvl0t2rlFqMP5IKnOgcmAf+2Ax3cFj3WDc=; b=BXx3QMVqAODrtTc2r3LpRnE4by6u5OPUtLvPhNsAviEJd9BTzJdCx1vQEPCbhKPZJn lLDSGFv2bO2qGtWplNux5i1+UPI9PqfPLLPaKiUB7D94ULubs5qnCkL+X/6H2C7piRHN 7HlkXH32iNL64Lbd8Xbg/0gxBfZCXAZavATbVQj0VyGuo88uBG1j/E5YUgHmWjrt8ZDP 8fPYMErI/xlcAIJrTrwB0FMk2nClv0JTgvKNjLe9O5vH2YxBMbSRzf2Yk86uy53NZCBZ toQ+vrS9ERL8OM2TUWFdV2WyFOik3kDoJVk1rfN8tQZM3gm5zA3GPEPHgTS4FKu/FaUd 3xsw== X-Gm-Message-State: AOJu0YyhDoyW+Rs72ZHHYUA+6RZxahUIi15+KUqNtjrnBdcGSduxd85W ItRd33rP55FFkRBiqnSL+9I3zEUDTR/0K/DqH8ulyNalmQz1vYjp4qrxlx7WFYIgncWCxNqhMh8 8gROPhH4/I1nQhQs9/tjImMcCE9lB2a9Rk1uA12Tloq3Da7S0cB3yQHqPNUiIk4uaupvFaUSIPg n5tO6RNXY4GChFPbfxBXeQyVksdBclybr7qFuq5fan X-Gm-Gg: ASbGncvzZQvNcsXY69OdHB+jnhakeMLi3hVLesyRIJMZ8tVBOPZJBXQW5zjKA8NjK/D z6rn5vXY9Shk51u0BrAUJ0ltNhAHqD9BKFcFex+YUa3Mo0Az2Ud7Kt13z8DWmn4NX5/8MS1a41t Lbws8rsMnk2Pi8nBylooudLIJIMkMh0cwAARNKdpj2Jr9nr8WUhqiyr81Y6bUly4UOrVyF5g+xv kdrUY+hEwBc9pTpJ/BLNuTYApVwxSsyg5jBcLNsKhUkJfCGUVkoZDlgdhTvE9XmEsy9dXvzGL6y +C4wNBHcqz/jHCsBYQqF0WJ4uV3QBL8bAEaB4ReuS9U8MSFDyRNCytRtaWH6Da9jMPswfrYx5G9 2V+JSscCL3mEfnSW97m2Hk38YZSzArpPPDpFUz7jYmz0= X-Received: by 2002:a05:600c:1c0c:b0:458:bda4:43df with SMTP id 5b1f17b1804b1-45b727a2c43mr93391755e9.17.1756481522667; Fri, 29 Aug 2025 08:32:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiKA5+9WcGOj9LIZVY6JkHxRNRVWnG6VPlf9GCNQzCnQ7A6Jqm4X+VAmtCmBqxZuKvwfqvRg== X-Received: by 2002:a05:600c:1c0c:b0:458:bda4:43df with SMTP id 5b1f17b1804b1-45b727a2c43mr93391485e9.17.1756481522204; Fri, 29 Aug 2025 08:32:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: peterx@redhat.com, richard.henderson@linaro.org, imammedo@redhat.com Subject: [PATCH 18/18] tcg/user: do not set exit_request gratuitously Date: Fri, 29 Aug 2025 17:31:15 +0200 Message-ID: <20250829153115.1590048-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829152909.1589668-1-pbonzini@redhat.com> References: <20250829152909.1589668-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1756574653083116600 Content-Type: text/plain; charset="utf-8" Whenever user-mode emulation needs to go all the way out of the cpu exec loop, it uses cpu_exit(), which already sets cpu->exit_request. Therefore, there is no need for tcg_kick_vcpu_thread() to set cpu->exit_request again outside system emulation. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- accel/tcg/cpu-exec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index ad94f96b252..7c20d9db122 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -751,6 +751,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) =20 void tcg_kick_vcpu_thread(CPUState *cpu) { +#ifndef CONFIG_USER_ONLY /* * Ensure cpu_exec will see the reason why the exit request was set. * FIXME: this is not always needed. Other accelerators instead @@ -758,6 +759,7 @@ void tcg_kick_vcpu_thread(CPUState *cpu) * CPU thread; see kvm_arch_pre_run() for example. */ qatomic_store_release(&cpu->exit_request, true); +#endif =20 /* Ensure cpu_exec will see the exit request after TCG has exited. */ qatomic_store_release(&cpu->neg.icount_decr.u16.high, -1); --=20 2.51.0