From nobody Sun Sep 28 16:28:00 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=1757326459; cv=none; d=zohomail.com; s=zohoarc; b=AEYLnwvmltyeOrMkmxPZbWwCCx+kCH9HYMwnUQT86LxUri1i3/3BDRyxvd98PmaJjxWleVzHFQLMIC03BN/DMqgSZcRM/1xIhz1BM2adnSeA4taJnb+kf72xHEc/4age+s+r2iZ+Xr3WKWseoyn/sfoTvs4hvGdzE/h/p7WGcrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326459; 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=xDMh8Tj9XNE2pbl7SQeVp29Pr5x/uZR6F1csyzVp1gE=; b=DvDBI5Ric7oIhjNVEsxJCrJQvuU/2PmyQ02lzYgBFO6My2AB3CXSKz/2ZcfLkNoH/HVSVnXTJna7ug6p3cvPjkI8B/7jh717jAhLxmROTuW5tKH82cuVatiXg1cyD61V+tuLtKIgUQfzQBbhOzdXmGDt0BnWMr0h8+BRAti3WGI= 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 1757326459646135.35849254090874; Mon, 8 Sep 2025 03:14:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYrv-0001Ud-V2; Mon, 08 Sep 2025 06:13:03 -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 1uvYrt-0001U4-SU for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:02 -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 1uvYrk-0000tM-SA for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:00 -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-203-qZfMMGy7N-uBLZi8gcCPSw-1; Mon, 08 Sep 2025 06:12:48 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45ddbfd44aaso18518195e9.2 for ; Mon, 08 Sep 2025 03:12:47 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45de229238fsm69836945e9.16.2025.09.08.03.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326369; 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=xDMh8Tj9XNE2pbl7SQeVp29Pr5x/uZR6F1csyzVp1gE=; b=b63aAu4EiPJE36MS2C4H4QNzQwD4t3QO8mJaY4qTSyT8YLMg88cJzSFoJUPPsSdjrowKxl n7FeDJEuSYnFmF7RSLa2Yyp+m0TZc0frwu5FQoUSx62WQCevoIcNZEDJ1O8nj6wn4G6BHD IhmTXkS+UIo5+YKatkXTmtEgRfHT7Rs= X-MC-Unique: qZfMMGy7N-uBLZi8gcCPSw-1 X-Mimecast-MFC-AGG-ID: qZfMMGy7N-uBLZi8gcCPSw_1757326367 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326365; x=1757931165; 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=xDMh8Tj9XNE2pbl7SQeVp29Pr5x/uZR6F1csyzVp1gE=; b=RTtyyL+/R9qOis6K+TVzNGpL3iU/Il2YcPEJKQ/tE1LgeSCjEUAyHj2Rvja2jY1kJa WuAOkDMpLQL4kN41qPUunYjlNgYbnJhhZtZNdByf9syxsFn3L963mbT6xlWN5eDnFJOO nRkPLlGmmBQf9eFCAwDSZAE/IWAZMZtZZiG+f9XxOONppSekAyBXazrqULmkU7+4hnWc KxG0STpyFVyeU9+4Mp/NSd0GIZopozGWpGbBaEY+d9+1LXaAW4cA1UxnTLqaIM7Xq+Mm tEAMcheP0RhyQuB8xygY+VW/JT54VSTp45mLG4s6MrAfQMvu1LmXDlNdVPfL9BVddYc6 2Zgw== X-Gm-Message-State: AOJu0YyoBArYXbf85Td2IZ+/A+8j8191NKqF3e+LFh8qURS5v0Mrp0Fj df8GiFOpG355C50nCqinavopP0zpr2wNvmqK8/9F37jhKP3uBgT1sA2fu7q2X9vtOJlgOL5lUet ahLHnP1g3ANDLghHdlLyj2sqeJJTJyecUdZ7ntUOJ81I9OZ8XR0DMPsi+nhC+8Fm1QNSABEsjz5 p0jgny0sDV3GEQZrjWjOI8Goi3nxi9up3C50D5vgvn X-Gm-Gg: ASbGncvsaCLkhdxjtN/FrfQRbdGxMTT1zYNKMaZZPE/4cuAhMEpS61KegyUg0yaBJNQ mH5GatJQ8VRdT8jC6m03P8XZw+g2jj7kVlfIx8UyqikNgbmJ8Bw5ROUcKeRAJ8LARW6nrJSX6Ug D88OBVqUCzzZGTWX0CyNVNptyBtAcJHGJ4NN+tm49Y9ewyOO3H/mv3WaFurOrQWsnEAf2YYsXnz t9yMle7UE3lyUtFDEFcnBZqxdushfFOi0+tWVgk3mDw1dA8NV9+ZOuu4fwFlILx8FaUUnu5ZlYT TXQ9sk5CILypiDMXYktvTi2iS4Lzz67YijtMMnhNRxfckDYYs4YvNFqGaRt0fiCoYTptLpJ07Fh du9MzNWfFY9tcu9XM8PW3m47obHdACaDA0OQ7OMRoxJQ= X-Received: by 2002:a05:600c:1991:b0:45c:b575:1aa8 with SMTP id 5b1f17b1804b1-45dddeed95emr50676845e9.35.1757326365207; Mon, 08 Sep 2025 03:12:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5kA4ZtNfoZF0xG1edGVELFWWNrBZbx2lf/NBUTrXIZuv4NNykJbpryLfgAlFNRPsXyZNT1Q== X-Received: by 2002:a05:600c:1991:b0:45c:b575:1aa8 with SMTP id 5b1f17b1804b1-45dddeed95emr50676485e9.35.1757326364730; Mon, 08 Sep 2025 03:12:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , Richard Henderson Subject: [PATCH 01/19] target/ppc: limit cpu_interrupt_exittb to system emulation Date: Mon, 8 Sep 2025 12:12:23 +0200 Message-ID: <20250908101241.2110068-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326462762124100 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. Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757326507; cv=none; d=zohomail.com; s=zohoarc; b=c+UFpVFQhASGjgzGzWSylkvr3w4xYaZMZdW8BzJc0cIW0owLXSqOLhSx26ipF6hVoj/NUPvPY1oVGmadD3Ns+L3/ZyTJwx2M6AvAJc6u1bxHCzqfSkZBSGKNp81VrHL7EKNKTXZ61l6CzOkAbvcTG7/1b+dm8AoNWV6zFA4u+nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326507; 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=7F7JtBib3HtIMCET12RYVWnFXL3A+/WcjU3+rd9Ob6M=; b=J+Eltm7sDNj9KjI6fhZrrFh/vPn7ozkEh5gJZiEGIwcWjVaFP7balU6AsleQgneJsoc3sud/2x1UPVChsZmf4qZXRfGR+cRWWvXWPuvuo7l1ukuYcTWaYk9S2EtCpWW834aJaVX3Hex49aP9TuYu9imed4w6xDuoYKizFp4faDk= 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 1757326507315643.3984369395639; Mon, 8 Sep 2025 03:15:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsA-0001dr-Eb; Mon, 08 Sep 2025 06:13:18 -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 1uvYs7-0001cZ-Gu for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:15 -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 1uvYrm-0000tY-BJ for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:15 -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-400-OgHveoIjMFKiEs0uBhBDHw-1; Mon, 08 Sep 2025 06:12:50 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45de14da365so13296885e9.3 for ; Mon, 08 Sep 2025 03:12:50 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45cb61377a7sm231030425e9.13.2025.09.08.03.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326371; 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=7F7JtBib3HtIMCET12RYVWnFXL3A+/WcjU3+rd9Ob6M=; b=KduLtCeHyJ0yhLscWLDXAgyOF7yyWo8w4yr8UI/oDu2tizmcwK+cb4TA3Fb+RBEntEJpLL Vh1EZxQCunb63+U8lCR+ya2lyQBgGv2Zg1tz42FO7Jb+qCEO9Ykml/L6Vhw6GstD3dHlPQ LMSMnk62hDhTwW+N6rIgxX3eYoxi67w= X-MC-Unique: OgHveoIjMFKiEs0uBhBDHw-1 X-Mimecast-MFC-AGG-ID: OgHveoIjMFKiEs0uBhBDHw_1757326369 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326368; x=1757931168; 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=7F7JtBib3HtIMCET12RYVWnFXL3A+/WcjU3+rd9Ob6M=; b=m8igFD3DBzSMelTMHg0FfTE5UmS2moQYvmDSFLkBvP1YiZzPG71QVsB3UFg7w4bJH/ GWTSsPQKScd7RMOfSrQR6BeqKC4uIOnRXlSmhS7PEGXmu/lhzIsUKZcdIUhYumy3CZ4z SgTtgc8Yx47qQ/E9laQOg7bxdhF5h4/ao3FFqeqM0S6xDr4DC9m2qUs0XOR3TXSzseIq lHweRD9kPcQHN9JYq12n8zezUhV3nirWGq6HGQViQy99jZffnuoaG8IPSVlpwC+5d8bg R3WBNxmvuOj+OX1FbZOK2qBvnCXL0MFrFqc6l+MDwCvxga3Z6PgpAImHnAHTWZfY3K7r id7Q== X-Gm-Message-State: AOJu0YwB6v1Cxs80bUUOiGkF+vn0pMkWFsRnQcFC7FUKqYKBAAr4D5Xd 4NWIBlRilzPytWSVcovV2pbJhjVWRB91n5LuIPveXDi3ST9q4VK5SA0QO3dcxRbS/lZNiJrsLN8 xhNEpyVn6pjia/lrIhLJQwBZNMvCAezJDUW8xCn0/johyTcMN/OLQcOXmcEj5RFZvFi2BAEdw75 CJ11i03yjf/lgxpk9c+KBQJ1Xq8vr3irdTM93Hj8DV X-Gm-Gg: ASbGncvEv6LqtkFedsfCQWnTo0pJdKfZfvKb4Zc7v415taVGEVPqqf+2cODi5UV+3QZ eqPXwn638PI2eHqOkQLQuxw0vZlNJoH+TFkTqrk1AwK5l/pSMFTAjzuTLSFpv6i92+tPbtI3N03 4TNMtepDmfZS7doWt9ZWhaolN2zKEACdswnEVtuI09NeW0Jhutm4tqAU2VAhRIpFrP49obxB2bx suiDIHxePmEdW/Kx2jOhAnuMBDLMTtiB9w/nyU5ZagpSUbTVU3s1UG3BFTs9Wf2Trlctvhdx2mR HjYjKQeX0ezQThoQxzSvwcnkr/DMOLhZWnXaOVdhE0c4BA8+ontkCQG4aTgF0fCKu4zUNQtGeaq Bph8CiDo0atMT6p5gaGC642jIYQsmpkCSKvDMQTwHrsg= X-Received: by 2002:a5d:5f82:0:b0:3e7:42ae:d3dd with SMTP id ffacd0b85a97d-3e742aed713mr3940211f8f.53.1757326368554; Mon, 08 Sep 2025 03:12:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcKD6udcCUcULOY2R+Z2Tzs5rjwZBGDVQuz1UhG6afXgRb+ISjKUtCVbJ+NSCk2FEua+zyPw== X-Received: by 2002:a5d:5f82:0:b0:3e7:42ae:d3dd with SMTP id ffacd0b85a97d-3e742aed713mr3940187f8f.53.1757326368131; Mon, 08 Sep 2025 03:12:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 02/19] target/sparc: limit cpu_check_irqs to system emulation Date: Mon, 8 Sep 2025 12:12:24 +0200 Message-ID: <20250908101241.2110068-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1757326508362116600 It is not used by user-mode emulation and is the only caller of cpu_interrupt() in qemu-sparc* binaries. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757326739; cv=none; d=zohomail.com; s=zohoarc; b=GAQh3uCiDoEJafypSeOr2B3dADrDCp3BoxvnB4HF4zI63QYPQFxcJtNc2pZScasWRQM6FQI05K7QzibNbUdB2PS6vh4adzJoMxcc+asAjPuyVSJX28T6eG4BOOiEceOd6I8xr/1NIqNGy557sXRy/31zPZG0AuL20qr1b1yoJUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326739; 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=W3FQSNcvluKEhgLR2MUjySlRLq+bsJkp7JvA9EI2Wgo=; b=Lc7JWrWw7OWinJlYN/huUy36TL1iLZ0T/McBIB+2a0B2Rwjfh5De7I0/UsEnWY2HXgtCK0lU3ua1JAI0H0bwZFNVpn7WspLH6XZA9EIF8lpp42iWvBD5jEiZe23+aOP4b3shRtsDMsSwa+JF/UZwUEO5UNARl+T/QmEWZ0IJ3hM= 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 1757326739890782.8204718314126; Mon, 8 Sep 2025 03:18:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsC-0001dm-Eu; Mon, 08 Sep 2025 06:13:20 -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 1uvYs8-0001cW-7n for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:16 -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 1uvYrs-0000tp-17 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:14 -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-472-LU0QyyLHPfKaYonlYsokEQ-1; Mon, 08 Sep 2025 06:12:52 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-45dd62a0dd2so15147825e9.1 for ; Mon, 08 Sep 2025 03:12:52 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e8879cesm439159775e9.12.2025.09.08.03.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326373; 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=W3FQSNcvluKEhgLR2MUjySlRLq+bsJkp7JvA9EI2Wgo=; b=ap1jea98G4b+0d9ee+E7Hp8gJhZUhhUYiobeOpfo3+9WyVCL8TYkqMQqM0A6wJSJ5AUs1i gMxT2YqoY2aF6gMVDC481+gEyc3d+9ik6nhQ0ygrbm+UUZ7QfG4NFSM5c/5uiQEhR1uHtG OUBjBbeO/mV2HXFALlDnPIn5CzshimM= X-MC-Unique: LU0QyyLHPfKaYonlYsokEQ-1 X-Mimecast-MFC-AGG-ID: LU0QyyLHPfKaYonlYsokEQ_1757326371 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326371; x=1757931171; 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=W3FQSNcvluKEhgLR2MUjySlRLq+bsJkp7JvA9EI2Wgo=; b=KY0jX9vWW5M+z2nT7K5uu83Ac2NO4vfhqrlo63ifsDRpDfBpJFyFwaa/0VX3ZH7RTG pNlwgvgddTWOdmaa8BoT9swlFpMEY9mmG5tywes4DqJKJOngIODcyqKrnu2TIbRb9vgo q5i30Afpn/GGHh0qoP14EcRD/AlE3Lnx6X09/iwjnkEtkG7GLMmSdRwVpjyE9qVyudsu EmeGNlUhdqSqEzp7Jw4mj8cswraZaGbOqaGjkUWzlAKzx43aE/fLiWiDM7L/0UC3jGo9 Ihv8NaaOEXN8QZq9Z5JS3gsD2/tU/6HJ08hPb8rNDzj8uVxv0xKa7uZR063+0vwyVJaC R5ow== X-Gm-Message-State: AOJu0YynR++0EKb/Fuoj59NME8WodzimCrSmOqhoqlKL175VGreaIXli TK0OEv1OwYFqdICRoGikg8jkmu2iBjEJso31zJ6dX7yW3WvMER0dZ++sApXTqMD6VGOKYZleTGh eKfhBPKfVEVTj71CreKQdxNQNOiCKC9ReH/APrVwg6d6Pomj/eTTWo/US0ButMVrA4hC7q84E/7 ZC1E3mUAlPB3v0BnEmuY4zaQ0UT4MmHX/LmRsFbDBm X-Gm-Gg: ASbGncs4d+oAcCPwJGdyWjQK6BpMCW80v+BCybOmOs8tKY3+1vX4y6szeOMPD2opYDS 0GW52p/2KDqGVvBwRX8YzSvdWRx0WIMchuNX6HYanHpCCV3BM9ke9czYh4CmQsPMhEbwfzooRgL tHTgGx+WzH0sLV9Q0xPsaw/n0diJGfJYIj2y0NEFjVEgj//HurCyGRDKnEFhi+p09ai9A1lDKjv wO5/fWeGfYhkaqlCRLJGBa+E19GFJAXdpTeA59dtHeP/DmdYTuTDQVM/nvaVtkoKEUR/XoF+sKi AlQbO31xqJ2o3quqK0FqL4iBbdSUhuYi4XIWfBlk6HRgva4gDZeKHEySwMYvWqNORe2OUmN8hsk adpYE6XJr1KBLVFkA6KXc9S67XKn2RWSmUt+9TD4Fhok= X-Received: by 2002:a05:600c:8b5c:b0:45b:9b9f:88cb with SMTP id 5b1f17b1804b1-45dd5b78584mr97865095e9.16.1757326370797; Mon, 08 Sep 2025 03:12:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYKXTKSPxPqGOXHimUcEKnbe+5MhjBPp4oldtBktDXNtJWwNAdq4u6QxDR6zcw76EOMnrLmg== X-Received: by 2002:a05:600c:8b5c:b0:45b:9b9f:88cb with SMTP id 5b1f17b1804b1-45dd5b78584mr97864755e9.16.1757326370355; Mon, 08 Sep 2025 03:12:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 03/19] target/i386: limit a20 to system emulation Date: Mon, 8 Sep 2025 12:12:25 +0200 Message-ID: <20250908101241.2110068-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326740728116600 It is not used by user-mode emulation and is the only caller of cpu_interrupt() in qemu-i386 and qemu-x86_64. Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757326465; cv=none; d=zohomail.com; s=zohoarc; b=gI2i0MXV85UHIDyS4BCL90GSUqpZKFlTVve4n+tC77Ofg3DR/Wqd6PVExjGSOBYLfKx2SI1By1dQtGc5TouSGs4FW0HiUBqESFz5/9Pg/c16+YPC0rI76TYzXJH6cIcpQk5imK/H5IPvJW5gqPoU8LFcSYXAqGPCIAK3ECOmgPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326465; 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=WFAxEBE2vTBq9sN8WpMlUM9AjgGajtnYOUlEqhXuNQY=; b=imx2TRzeQaoq7B+CJyOKPmyCsnmj4a4aN4y2CgYP2DLVEhewz9in8Yv8cfgJ5CBOErbkoByOO6LW919qz2r/a/gVzUttNt4UEyHYcGn02Y6AzmezX1j5b3Gi7428Pn7lP95XxKquFl5PcPtIlNlj9rfz7KysrJVd6ZH3Cjx3JOw= 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 1757326465240816.4803937807472; Mon, 8 Sep 2025 03:14:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYs9-0001d2-H3; Mon, 08 Sep 2025 06:13:17 -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 1uvYs6-0001c9-L1 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:14 -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 1uvYrv-0000uR-AM for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:13 -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-248-Bo9fsHFgPUGNy-7_3UbdbA-1; Mon, 08 Sep 2025 06:12:56 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45d6c770066so21685865e9.0 for ; Mon, 08 Sep 2025 03:12:56 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf275d2717sm40935771f8f.15.2025.09.08.03.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326377; 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=WFAxEBE2vTBq9sN8WpMlUM9AjgGajtnYOUlEqhXuNQY=; b=eAfVoypl10oKd1m54bIWArpSQ0aLi6EV2+REBY65qS2C5Qlp0mP7daKqdJR6+Y9tyNEobI qOQG+LDoESdZlBtcz1rGku3mSZp27iFHNzl9JsD2/qxdH8svz2PeU952zLf6K73rwuPeQ0 JmaWIgYHf/amUx0bd33RtFT/RP7JBZA= X-MC-Unique: Bo9fsHFgPUGNy-7_3UbdbA-1 X-Mimecast-MFC-AGG-ID: Bo9fsHFgPUGNy-7_3UbdbA_1757326375 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326374; x=1757931174; 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=WFAxEBE2vTBq9sN8WpMlUM9AjgGajtnYOUlEqhXuNQY=; b=VVG3w40kXRycM7IsJxUHq6RClGi9FEwlKQOFOfPRGiRJAuP3a777/m6q63X4MiG4ap I/ocu3fmWuHPy5qvrreYnFC8DQo4oGd/0Zb6AqO1QLJzp0uFMr6pV2qpCTqXH1k/ZJWY uBiNd4Kqa4K68fOuX58Y34F6y7gH8Ccd/BUhPZqVHMyMrOd/c9vdlM4sM6WUDlyLA1/s +UcIXnausBXxhd5+rFJqtHJxbJ/d/xtbgutUbRwYVCHA9p4dYM7He+U535ZpG/sX8dWw 59paUR/1fLe6e3386yjzSq5hjzRjENv2pwiYvNZgCVmqmky4coffs2KWv90iBJuILIZf oJFQ== X-Gm-Message-State: AOJu0Yze0Qer+2St+09HrffEIJzn0WS0gL5yw7T/Fc1NUvq06+VIRuwg px0YXpc7mLl7QIb9wwaAoghk4uU30TFFChULHCyJJJW5AsRguH5e7CKsLC/fN8Pq7+77TMe6Oit mVZiddODbF/3tMvFWalIePJElOsX2j7adg00qkbo4mJVNcnYIxIUXjduz2yRyWJT4OTRqy3V5Sg r8ngQdg//wpInYcko2IvBBeqjXK1rRiW1BBD4BKnMO X-Gm-Gg: ASbGnctZaUepPvCzzONFRUWEqpkqTzkQ1XPnDMnZqTcEMZ/gJrj3sBn45Ut3RMMbQZ/ wzS/Km3SWCozgBIjkM3Ao/FJVOturnPR8teDEQmRP22mDiO5QxMDjDjTva/EdtyOdG0dRLRbLHB aOcVHd/HZvR4+lXAMQs3xypHfonWb+iWzI3eqIFQjCw/mr5J4w7SGs27X8hi5Z2UznbgOCOqt6E awvHblFBP6hw2D5fGNbLYSFhg9BZwPT6quTjvMRkP3owO4GlTBr7MPlPO+sdaHOcFAcWgdR7bq9 pvHlbL7kBnN28MfRE/D3sZXoEOjeqhAZVrxrmIvJEW6NSk0xmK9fd6QlgCZZkAT7i4bhMFp4nPy pUys+DLvHwcrYulJY3Zg901i6b1fwRFYkju9q5MOgcA8= X-Received: by 2002:a05:600c:1993:b0:45c:b5eb:b0c6 with SMTP id 5b1f17b1804b1-45ddde80fd3mr64703075e9.5.1757326374136; Mon, 08 Sep 2025 03:12:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/hbU9C9bwvGH+d1L3BSVfhHGWtFFlfeyDcmI+L4VfO0Ja+rylKh9RCbxakSRCb9sap/nU/Q== X-Received: by 2002:a05:600c:1993:b0:45c:b5eb:b0c6 with SMTP id 5b1f17b1804b1-45ddde80fd3mr64702415e9.5.1757326373292; Mon, 08 Sep 2025 03:12:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 04/19] target-arm: remove uses of cpu_interrupt() for user-mode emulation Date: Mon, 8 Sep 2025 12:12:26 +0200 Message-ID: <20250908101241.2110068-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_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: 1757326467082124100 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. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 f5a1e75db37..f0aa26c5117 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1292,6 +1292,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 d0f6fcdfcea..633ec55a57c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -686,376 +686,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 19637e7301b..fb62742d983 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2868,8 +2868,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 Sun Sep 28 16:28:00 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=1757326458; cv=none; d=zohomail.com; s=zohoarc; b=JSCVGD7nG9LUW8NfdXA5aQv4ohk5Hiq8+bnp7Wm4z2JpOuI9YVWJOKoGD/6EPyGP0dIcDDnWcuXchoS7+umGmI39WMyPhdLZcQPRox1MQq4iNfrTi3vkeWDPKzAFBIwzFnvF9yJ79jDj0VwDRThXdvHebuobC3DFIi5BKMkSisI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326458; 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=NWm914yPu/Z+1a+QMagwFJTO39uJw4aRXD1IlivLAnM=; b=cRxW9J/uE25zhCPEY5q7l6iMassRlVEEUlhBzhYp8AggRAef24qMMYuk1KP5NgwsvSwDkNTT1EGTjYv/e6nxg4E6YlgQMMTWbkZyERPSG8W4eNQo2XCg4HWpN1nygzWxFsBeg2aX1TEp5UGjxk3Pm8aUgMtSkI2j8U6BvlgCbuo= 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 1757326458118807.6644507855964; Mon, 8 Sep 2025 03:14:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYs7-0001cX-AX; Mon, 08 Sep 2025 06:13:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uvYs5-0001as-LN for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:13 -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 1uvYru-0000v7-Rq for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:12 -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-137-oyWDSrbtPo2p0HpX4Lup7w-1; Mon, 08 Sep 2025 06:12:57 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3df9f185b82so1902115f8f.1 for ; Mon, 08 Sep 2025 03:12:57 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d1007c0dc8sm39510181f8f.53.2025.09.08.03.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326378; 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=NWm914yPu/Z+1a+QMagwFJTO39uJw4aRXD1IlivLAnM=; b=D9PeABZlp5gYsyLgx85CsgwfzIbcgZ5qtnUWldyNcJ1wisrhfwh1taCyKsyYNXsxhXtQpv wCWosS+E76W3XYPBYKxiX1r1LM01j9vBRxN69e21DJA9m/NflqN2+GSNsClftp4IApvMNh 4QntVa9o/Sbxl1oDwOl2MfeEoUbWss8= X-MC-Unique: oyWDSrbtPo2p0HpX4Lup7w-1 X-Mimecast-MFC-AGG-ID: oyWDSrbtPo2p0HpX4Lup7w_1757326376 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326375; x=1757931175; 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=NWm914yPu/Z+1a+QMagwFJTO39uJw4aRXD1IlivLAnM=; b=gmJsSBHKHuWkYhNQmlqPuKouCINgRf93YZKug52I8jrYmgYo9xI5+XwehmyQjELHfv dDMIAAT9KkatOiS0BCHOgjcBTO+BKK0BQoO0Jy/w/a9PA7Bmx2rUELVPzML3nVR3MdRt 8OZYR5UTbl3cDNs5yIu98C0Prlzxi4upffY9lJXVV/ukrgDdJLyYX9T2T6IVIFcgoT6z LbT787AMijGzT3BucGmY0ud8gdgFQW5ELenc18eL3gR2gFvLYjdZ79SR6lPAUv3+SpVu f8bzic1qbPiCb7zY+I4NMjrkCk475/gRXQ4yL+gH8876AyxabQNhIRkPXmSc0tQesbor LdXA== X-Gm-Message-State: AOJu0Yxup00KDDjt0X/x4IbYEifdAOpdUoT+P0SvmKti/NWMwRICZCGw ys+uGlsWw/UXzppS5O8jmkbJpylR5mAXjR0bx6rWwGvloiaPx1gGsZfJ6m578/WYCjALoapbhzT Xf6moqbZFRLN8JKOVpa4AiLNom6dwFtiTIiZg2HkQdRH9NDRK3iYNIxiopuZFeZ41N30zgXK23A Cw9yi/skg/g1cRU0KGryBVLOSIqSAF/xQ0dGNxtFld X-Gm-Gg: ASbGncvM3Mngp9kdYGaqla4mLt+9DybPwSP0vo21LSvbu61BpM0YDj4MuUNQ3gqVpst xdtSKjn9GWvXVClvYbTNFX+Aep/JBEYnNGw/dlIYF726iqy8Xx2KNBD/DsShlDTWqLHmykWKeg/ hcx5k4WJ2GELeSg3U3ft6rcK+YQblTzE9tnzAoz05h6P+apz9C5qpV+FNPor9I6bPiRRcsMSCUt lDtsT8wZkuhZHf2TJri2dMiIWTwNZF2TawKiZ7rhwOrEN4Zbr0xPJHsJffHL1gFeKCHPl06dmo4 rdscQ9Cp1cHE1R4Jli5nj/OR7oRZ97ERWkzS91YBTf5SQXPku6ShV0/rPljMyLZlvLTZRYvqzct rHSLlsfNxMDKK6h3Tbe+IaGJLyf/tFtzS3nBWXGzBLi4= X-Received: by 2002:a05:6000:2f87:b0:3df:d8ea:1f87 with SMTP id ffacd0b85a97d-3e643c1d91fmr4919196f8f.58.1757326375317; Mon, 08 Sep 2025 03:12:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGN0cRRn44+j1+Hz1FyCYHnnw4S7R91ciITF4bibT4/CtfgWY7qkqPTtEg+jQK7pHrVpH1n+A== X-Received: by 2002:a05:6000:2f87:b0:3df:d8ea:1f87 with SMTP id ffacd0b85a97d-3e643c1d91fmr4919166f8f.58.1757326374837; Mon, 08 Sep 2025 03:12:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 05/19] user-exec: remove cpu_interrupt() stub Date: Mon, 8 Sep 2025 12:12:27 +0200 Message-ID: <20250908101241.2110068-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326461085124100 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757326656; cv=none; d=zohomail.com; s=zohoarc; b=f/U3UyH/+t8SIvdn0rV/OyROouieOnpE11yKEb8n3tHBAfquSd0GkB1814n/8ndxzAI/gffNnGraj7Nd5ZmlbM3yWm9KUfnWMgIhmN+9mZVE/CsZCyjYAWWzaN09nY7JJ4lvGfnreMLg4d9FbaSKMgAMIVjev8CK+3/XCLe1Uy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326656; 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=tQF19VJadKTqyXrZHyk7Nk2a3lmDngVPUnI4hoa6BvU=; b=kUVpHoQH9hhvcAJsVBNaIas/5JbSD67I1e7kfX1T+iFmArsbhpmxwKSAgDLinCvxGYcfYzFVrtu0E0q2i6Rdcq9qsO/ezVhjKEeLyVvRH5SVxXz8dSsiCVPRJEZMVyS9tWWiNTl8T0imaV5KiYaEH4kl85aXqS6N4vp9yfy9haY= 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 1757326656575778.6108470915992; Mon, 8 Sep 2025 03:17:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsI-0001nj-5f; Mon, 08 Sep 2025 06:13:26 -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 1uvYsF-0001fj-KB for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:23 -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 1uvYs6-0000wC-B1 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:22 -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-623-49FWne5qNLCq7hNpa4fuHA-1; Mon, 08 Sep 2025 06:13:02 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3db4cfcc23eso2151263f8f.3 for ; Mon, 08 Sep 2025 03:13:02 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e748aa8104sm3557380f8f.40.2025.09.08.03.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326389; 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=tQF19VJadKTqyXrZHyk7Nk2a3lmDngVPUnI4hoa6BvU=; b=VTOjf9Ob7FD865LpW+mxzmD0kinkmLUKM7bFnxU80V+9pz/Xb3rzugN8x4gIGLTee9U4y+ ZHVdEX5k0r4KeDXmNW2zYmDS1afUUYBhRig/EJvmRoeSI2SiWSG+0IzJH+XAN4RoJSTl0L CMkJA22k1QTnh0OA2mbeRACPxVc8SjQ= X-MC-Unique: 49FWne5qNLCq7hNpa4fuHA-1 X-Mimecast-MFC-AGG-ID: 49FWne5qNLCq7hNpa4fuHA_1757326380 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326378; x=1757931178; 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=tQF19VJadKTqyXrZHyk7Nk2a3lmDngVPUnI4hoa6BvU=; b=ocVfKpK0sB1CsNHli5p5CIQUyNaUVka8sDMW9yyn+IrGv8/ermroyeXz1V7pFNh6px /5X+1YyfoWCXBbOS38i9h8nIlthZGzIYOv1NaaC07gObgG38auuOEnfH9OrisOyOo0AF gjvSFoOv8CjvIj+GFF85esVPYwKo3jbh9WQZmQ0DcfcM4Z04VdevRwSznW+cnge3XpWK MZ00YlLvHwzBM9ZOZnnyc1GlWmSmUIWsU/ppKRvfX/48C2VlfkGj/7EpHz7EsDpmCyB1 hjb8Yz1QjrvcnZ0BnBnzSqBJCAY4cmymAEUyBKbsVp515rXw2Eq/esVFwZbVVcEKXgkk OC1A== X-Gm-Message-State: AOJu0YxVEfG/kmrUTHkPQkuK97/Q2+HpYugntZHVo5ivjtVE3ChBdsdo +jiUPVwfa9UDykYfsn7eEwjXdwTEjpkyCGmK0VQDqjJf6IyshA4cylu54yitR1fjgopLJiYvO4k bTII2n3Lmy7nW3NsR0et6I46a0myrRlTR6AWSmz0piv8Mf4YsBizcbkXFQWPeHCgFZjPUuJGzdo 3LYZOKc+9hFWScnEMv70PvbvbTAXfXdAyUtcE83iAS X-Gm-Gg: ASbGncvTV0ZwNEUl3BjajztkLqR47eg1vqX8Kr8UFZhEr62AIV/rfmX/Bm6G3bKPcDP 3Yba/IQDayqF/kCmuIaMFsagu6ohsWopzoKtJNnXuaP33npQMesW4wr/yqzG2Y2Ez8UUUQCZUy4 rIeJdsn+jYb7LH4lpNq6PSLqdrMkak+DkyNF3UFbxhXPHDolUUd0cifgYLRGQznS3OI+gZLvbSu GEgasygz+itgTWtkubKLICtDiQTW3hJj+Uv8kMTIFDMNyI/HnKDKDp+2HSlyrcrld93e/koxl6h qjIei8hm8iS0x/cYMAm7DT1sxj113QNzAoWbwm1zwh0iW6mzz0O03cN/s4h//nUKKE3MyxV5DWJ TEpWqT3oDHeKJd+z1B1oFP4EM+rGhLutiQ19TpQSXh2M= X-Received: by 2002:a05:6000:2689:b0:3d2:52e3:920c with SMTP id ffacd0b85a97d-3e643555d8cmr5586580f8f.44.1757326378324; Mon, 08 Sep 2025 03:12:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9DvSlUs7gkDAhO3CRRxk0TJV91LvXsp+22vusJhMTpQeocXsDRXHR8E1QaHLvNuBzNgyYTw== X-Received: by 2002:a05:6000:2689:b0:3d2:52e3:920c with SMTP id ffacd0b85a97d-3e643555d8cmr5586557f8f.44.1757326377793; Mon, 08 Sep 2025 03:12:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 06/19] treewide: clear bits of cs->interrupt_request with cpu_reset_interrupt() Date: Mon, 8 Sep 2025 12:12:28 +0200 Message-ID: <20250908101241.2110068-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326657496116600 Open coding cpu_reset_interrupt() can cause bugs if the BQL is not taken, for example i386 has the call chain kvm_cpu_exec() -> kvm_put_vcpu_events() -> kvm_arch_put_registers(). Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757326578; cv=none; d=zohomail.com; s=zohoarc; b=M2Kje0Lncn8W4+PK9iGupXJUiCOSUBYayQ0x0zq2SmMTVOpfvZjIqrWjzlntDRLmPyKC2xUxflmFzQzkpqxEz3479k6ZaujXl4bcXq9wdBEyHseDVkfZMInnSjmC29hgnbRDUH0i5RmbVPxGlpdxbQ0xU1epj3yraaEUY7Uo5Ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326578; 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=7929tqjr/p/MqUXWGl/GVOXgHyxRWujXMrtUmPUHm9Y=; b=kBBMabNmx+x0uzH1x1slsdBNbSq5VxpGAgbToKMGYYkopP0Rx3KHN3PG2PA0l9RLCtqv5fuugZZ7gP+EbcP3ca6BOlAyqbgaqz7xJWLMnJKeUgHtlir2/OvgZeMJMw8vpOVS9DM0dg/acak6Ps3FIwEPx6zMApTE4Vc9GaCqlOI= 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 1757326578525759.8654564322068; Mon, 8 Sep 2025 03:16:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsE-0001fe-9s; Mon, 08 Sep 2025 06:13:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uvYsD-0001fA-DX for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:21 -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 1uvYs6-0000vT-MX for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:21 -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-338-sc1GTG6mNj2bua4IC_NALQ-1; Mon, 08 Sep 2025 06:13:02 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3dabec38299so2705404f8f.2 for ; Mon, 08 Sep 2025 03:13:02 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b9bcda91dsm270382705e9.6.2025.09.08.03.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326383; 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=7929tqjr/p/MqUXWGl/GVOXgHyxRWujXMrtUmPUHm9Y=; b=WO457PV+suSFr3jsTBI9eHe/2pba7zorezbpecY/VqnpBf3aYQ6khfWA/cxHX4Df2H6WvH CS7ZelyHOKvWt7FHcMFbW1dieLo01cuyK6Rzj/yDU/7eYaajPA+vPm/8yRIAJc8OIdAUn6 4oIugyZNGgnQYUiTIPCTFCewFnbOcEg= X-MC-Unique: sc1GTG6mNj2bua4IC_NALQ-1 X-Mimecast-MFC-AGG-ID: sc1GTG6mNj2bua4IC_NALQ_1757326381 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326380; x=1757931180; 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=7929tqjr/p/MqUXWGl/GVOXgHyxRWujXMrtUmPUHm9Y=; b=hCflh+VHIP0tfbtBj+yecGRlw8hgaYf1cFrI7qTOaCXd2qgwFvR6Zb0hVTSnborejl C7zZmQCuebp/OsWVjVEqOId53g5nXGqcWQAOPMggCH/kcjplvkAvz0luncPeStrb3XIi JVx8I+HvdRyDAD8Wxv+939uDDD8JeB0ao7nzXh9/l8R44eWRtmrC/1Y5NBBRhtMaks7h Y56lsZkiG7K0Ev6LXjvEL6bCP6TtIDIubiorXI4II2kcafKfRisx0cRf3k0R4drN097u rOmduSzor4DPBsUAP94qymF8ThRNlgG8KskFfxsQea7Lq126N/YJDqv7eTeRPD3gZyIZ 8dhQ== X-Gm-Message-State: AOJu0YxgukNrp2446AIs4xRI0LmeeF4EoKvpqBU032enKxgGRzMWbn4V wUZBZA4A4bviFTkRKmpfjCdcMjonOufOyjHlk/aHWvs1lIaynQQRbdZEUJMA4JvQ6SziiwtwWcn T8OxizGlBtMcg8J8o7feUO12JXuuxl4OIcJkx/gUohA/4YmQBREKSSkMkmc+R3Ynp/5r1GvlGp1 /K6zKUB+JzJ+cx6hIGZnV9GNJJwX8QHhht77C/RB2P X-Gm-Gg: ASbGncvSJP5yAOTYb3JlIj+IGus7FWDOgEM6mrMl+T6YHkb5T2XCZlfknc6SlhoMtU3 dIQ51xzeL+4PP5mQh2JgNXkS4h1i3L4dYY8fUP8zRUEPbGN6Fb2u0LBdC8/TDWzA6PGUGzJNVCb DY9YnFZln6vwGYswXBCWufVWPe/p5StSoiC0shvuSaAOFZocaeRS71JYba6U1fqZZLMiTAP9wtp H6FDq3ylIR+3gXD8V6tr0l67f7dDQ7WsxdsGg4EzV37sDjw8/8Rz1GHWBAgNO9vE6nj4Maw4AD/ LbiG+O4LMk+SM1+sT+FidOEVuktbdbSH2jF8bT2mFVKLQYHxssTK1GfExP7wpBlW1d8/nmrOET4 du4SnhyiYNCowTi/ZF1+7wrGpzcw5GN7vwn8kEZ4Yn0k= X-Received: by 2002:a05:6000:2509:b0:3dc:15d2:b92a with SMTP id ffacd0b85a97d-3e64bde94a4mr4706612f8f.41.1757326379710; Mon, 08 Sep 2025 03:12:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGM7sMBr396NKPBWrdH3NAXZDFZt8x2cZeikGC5wItcU0fa+hOanLW0pAo/ZekQOi0DsZpMIw== X-Received: by 2002:a05:6000:2509:b0:3dc:15d2:b92a with SMTP id ffacd0b85a97d-3e64bde94a4mr4706585f8f.41.1757326379193; Mon, 08 Sep 2025 03:12:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 07/19] cpu-common: use atomic access for interrupt_request Date: Mon, 8 Sep 2025 12:12:29 +0200 Message-ID: <20250908101241.2110068-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326581857124100 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. Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 259cf2a3c36..152abc9024b 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 Sun Sep 28 16:28:00 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=1757326520; cv=none; d=zohomail.com; s=zohoarc; b=nVdncx53M5F0c2CMRWNf3zVDl5/CgLT/WEGB0q8wreuBr/t/g3GBUORS8wDwfVhN/nGMrjJ79Rjr9kZ5ldRLJpVDJmUo5RLmw41kCqjxei1XptJRVFMf9ZnOeT8EvLVuwj6qJtmxSWLZOTgAb5bo/oqsWbjZnMSMChP0UuPaSpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326520; 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=CQOby/BAJBGzsbQkEY5z4jLqdBepsOlgz7xz91bkfdo=; b=i20sTNIv+XHNzcflWtqEy1nyWtmHuHRd77laxCI1UtSaQ3N6VTf1MvDSxgNFYLMKk6tuOqFW+8TRbCQd5PeeuFrrKixhXEWwzmjh9AZa1nZfozgLMuWRLtbhozRSPHkNFsU4ReabwYlc2EpVq16jJxByY84A7E247ufIFYJR2Rs= 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 175732652035772.44632318342417; Mon, 8 Sep 2025 03:15:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsH-0001ny-Ev; Mon, 08 Sep 2025 06:13: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 1uvYsD-0001fC-JK for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:21 -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 1uvYs8-0000vg-UQ for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:21 -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-586-CxJRifP7OpyFDljCJMssrA-1; Mon, 08 Sep 2025 06:13:04 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3df07c967e9so2698809f8f.2 for ; Mon, 08 Sep 2025 03:13:04 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45de229238fsm69845945e9.16.2025.09.08.03.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326385; 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=CQOby/BAJBGzsbQkEY5z4jLqdBepsOlgz7xz91bkfdo=; b=KYdeho8FpXcbvinctSzC61DoMX1vtzBhYMLqyp3BggyLETUxO5NeGsjEovARvMzTFUrNup 2VoQW0ZdGf+m/FFHsyUPsHxt01pOwFbO/ANO346hd8Pk5GT37Uto1a5KmT/ylui/vBExj5 B3QM83AXQEkh2Xu5QfrrAWpQXTan+Hg= X-MC-Unique: CxJRifP7OpyFDljCJMssrA-1 X-Mimecast-MFC-AGG-ID: CxJRifP7OpyFDljCJMssrA_1757326383 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326383; x=1757931183; 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=CQOby/BAJBGzsbQkEY5z4jLqdBepsOlgz7xz91bkfdo=; b=fAU7FMmMbBb/9+7krBGJU5o3vHXs0DhojFffO8hthJb4R3AVhQk3N7ANphFU4PmOpR TDjFIi9Smd04I1PjVkOhFmcUPsEXaGbK94NCwotFrmCnkL7274ZlnQdsgunaUs08NIl5 IRuLCZ5suaOGvglV6Ac9XjpdEvempkHZP3UHGnIznS0TeakgoU4XU2IbYX2cC+QseXDt cI4VBjJDirB9pK+RM9RZ5wqJAfr/uZm9XxMZ0HNOjvboUz5yVzdc8U+N8JnOFQjS9iGp VOlWiDjL8I9mB2ol3yRKc4nQiPEdFrMWEUdcyNBZKiCuQP+4xadrN1hmxMlcu0ZmOsF2 tRPw== X-Gm-Message-State: AOJu0YzIhP2igvcKtoeKFL6ho4S4CHXql6108eGWd3Wy/SJ5sq8SUl/h EMgyaxQxj4DdWSkleSrUo9JNj+4v42k0UjCnPNK4jmcJCDPdeRIvDAj1dShf+sRXJjYIJ3N8gpl J6w2Ls/ywcL/1qKRNnkfWM/1yaodvECb28RPzTBZ7pMMpLjxP8bQCirw5fXCk1vF+9CLiqX9hdR QJ6y0IFjJaM9kED1TVB4LTM564XZkOOlw70u6nMXN4 X-Gm-Gg: ASbGncv/E6Jc6hYz9rmGBYLnbWXZqGpd0Fcy9SHk60kmo+pGSvsD7IB90wsQJpp/9R2 fTWPN+wVilBdpjgGVGNXvMGLAzaSOtCScbWqn8PCETCz19xcZIkXnjHMaH6XFyf7g40+6wcTbIm JKRW4syy53VehpOMmFU86C9nLhSraHOvMsLCna8wxRQoni6j1dcRxXAZD3rAl9k0eVCEaKXskLb Tk/p9mIEiojUCJVBHCl9y42b7rBIVbqvrPWYt6JXLT7V1KZHqbb72UQsc6a/kO1BZAZ8We80EJ9 G9Nw/sBjpXkL6cds0luMOZvQzzFqg7VtPxW+u4EUqdWf6BLXZZgAWjHKhZFsTuu817FQXVD0dYb J7LaklTlwiSYrEdn37QZhEoWwaJfkePhmmEjkRh9hC9k= X-Received: by 2002:a5d:5848:0:b0:3e0:152a:87b7 with SMTP id ffacd0b85a97d-3e643ff65a8mr4987719f8f.41.1757326382813; Mon, 08 Sep 2025 03:13:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAA9NfZEganxwWt8Y+9YLqjd1kdhFvIouXrHLywH52Vt/8tKXZqML4MpviiyuehGFz8A1ikw== X-Received: by 2002:a5d:5848:0:b0:3e0:152a:87b7 with SMTP id ffacd0b85a97d-3e643ff65a8mr4987688f8f.41.1757326382361; Mon, 08 Sep 2025 03:13:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH 08/19] cpus: document that qemu_cpu_kick() can be used for BQL-less operation Date: Mon, 8 Sep 2025 12:12:30 +0200 Message-ID: <20250908101241.2110068-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326521390124100 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757327038; cv=none; d=zohomail.com; s=zohoarc; b=G54+1nrqds7E+3qrABwU35Y/qed1q6tTdnCYtPASOTsOKKYRuv2TkXSNYGsac1ru53GYH0oRFM+c1sLqLe2/y5ORKDuS+ZSNK5yQBMc8G2PquBAxcVRZDlwmhqcaVUanTHLtct63zWtqOxL7UrzVhtf4RoL9rdBaaEozD8g4UcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757327038; 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=2JxL0mu6HG+did++z5AjqHBeKoSZ1/tUC6gKjbxSw7M=; b=aULI5cyPN7+evlG2cNvXEFuS7qgDpJ8cI375KoRXrf0F+jNFqUo0wF2JffwV/+mXL5BqQxKe4tiLM9F78fWoMMpsAHDrPlZCl9g6/MI9YkZ2FXJhpd1QL64RcJhxfwj3Tlmx5rcC2oIqz6hx7yAeWkPr5/TbL63xA/WswUWHWQw= 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 1757327038158847.4749038985889; Mon, 8 Sep 2025 03:23:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsD-0001f6-5O; Mon, 08 Sep 2025 06:13:21 -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 1uvYs9-0001cr-6B for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:17 -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 1uvYs5-0000w6-KP for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:15 -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-655-gZLS2OC4MaaVQmCgoCwNqw-1; Mon, 08 Sep 2025 06:13:08 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45de5fdda1aso3357935e9.1 for ; Mon, 08 Sep 2025 03:13:07 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b9bcda91dsm270386825e9.6.2025.09.08.03.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326389; 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=2JxL0mu6HG+did++z5AjqHBeKoSZ1/tUC6gKjbxSw7M=; b=LLIiPfFl0CJuj74MkZ3AXuyyXYi2UPkgP42Ad6V/7Jtx535pgAs+P6BaycpbciPdPAVPly 3sAppqhXnZbupGlHsmqlboLqrOakk1doGlTOD5jfIv/Z6LrKChEmBq03cgdo+UNCF2ZrjX VOlarkkCOxOeue3aEleu8iiaqrF4c+g= X-MC-Unique: gZLS2OC4MaaVQmCgoCwNqw-1 X-Mimecast-MFC-AGG-ID: gZLS2OC4MaaVQmCgoCwNqw_1757326387 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326386; x=1757931186; 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=2JxL0mu6HG+did++z5AjqHBeKoSZ1/tUC6gKjbxSw7M=; b=cE/pt8thLYjZFqSmskkD86M4atykX0xgI1dlblesN1BqAnBwpUBUOIEHnFtqTx4T01 H0c+eUCrg+WsVX8QxXFjPpoMgJyeILbGtjsOod/RPOGuC+NKwY/LO677XkH5hJROQTyp TQxiIxxKglwrOF8Ip71LS+bBxm2crn+tH68iAYkcfWBCVelDn6Q6+2DotHbhTcVx4VBi bhjgMMcAPogH/EGVRC/Aq2GX4CIlhLIaNra6N9WA9o5cFpv46zHII/tcIKGaKKAs4KMP FEfiEebAbZ0or3RFSD/3vUzvOOjlrX9CnKNr6U7MWz2R+3MM04Ca4VbreDm+NTrh/Scc TYcg== X-Gm-Message-State: AOJu0Yww/3E7ptovhghn/8/lSpbEM4ELenPa3AvkoFmBCJAzDDMJxSn3 BoxHUBLLB5fq7rTp5M56uXQYHg/6QtMZiwqoY/YxFdHT2OWn6p8jfS5QbC8DJnUZpoQX7x9+cR6 kEwRR1FI5qH2CFDJeYebYFhxk3MzwNn6zJvUTMb9wMsP6zvLxPH17HvO321h1YYYnu23yuj1kSM qhhTF0Q1LG4RH8zRI7VNnzIFhTeIor8oNQGgfAbckp X-Gm-Gg: ASbGncsw5e0zHLYsPKalqE6EcuyKnSBPWn1b3M23M1keveDOLeqqXYAJLiTjqEx/DTj UCLxHHe8hhNjOu1rjlEYnduxR2s0aEqWhC6eQuBWmxnCXiaeU75a4WST7oKE6yPy3YqlpNH9K7Y Ubetv6SNFemtmeIl7qRBPBE4BwJaIYOzGMatwZXDcXuXLRsb3SrGqFhsOId57yxw/t3ZuoToaQT 1r3WS5J3ZR8JMETO0Uc0VYx4Djr6y+9JpqcEb3o+Yrh2TrYpUPJy55qs0lW4ziIDCi6RX7ehZhF fkPEfzOQK4KgFJLB3YbP7Lo8M53I7lcqXiTDuIeqL3pEyqgd1CB1mS3GqefNNWB3Y1mAV7E5gC2 q1++lSSQuiWVxorrQcXI5qUyINn7dZ9kzzahkhsyCG9Q= X-Received: by 2002:a05:600c:1d16:b0:459:d780:3604 with SMTP id 5b1f17b1804b1-45ddde89897mr75840615e9.3.1757326385604; Mon, 08 Sep 2025 03:13:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFm0BetqOFBzZk+fzzdNuIQJww8nPT0Oa3fCLgeCEvHKqVxVO3DuAbACXN1ZpglRgXW6XO+g== X-Received: by 2002:a05:600c:1d16:b0:459:d780:3604 with SMTP id 5b1f17b1804b1-45ddde89897mr75840145e9.3.1757326385073; Mon, 08 Sep 2025 03:13:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , Peter Xu , Igor Mammedov Subject: [PATCH 09/19] accel: use store_release/load_acquire for cross-thread exit_request Date: Mon, 8 Sep 2025 12:12:31 +0200 Message-ID: <20250908101241.2110068-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757327040604124100 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 Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 19 +++++++++---------- accel/tcg/cpu-exec.c | 7 +++++-- accel/tcg/tcg-accel-ops-rr.c | 11 +++++++++-- hw/core/cpu-common.c | 3 ++- target/i386/nvmm/nvmm-all.c | 5 ++--- target/i386/whpx/whpx-all.c | 3 ++- 6 files changed, 29 insertions(+), 19 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..e8b0e370a8d 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -242,10 +242,17 @@ static void *rr_cpu_thread_fn(void *arg) cpu =3D first_cpu; } =20 - while (cpu && cpu_work_list_empty(cpu) && !cpu->exit_request) { - /* Store rr_current_cpu before evaluating cpu_can_run(). */ + while (cpu && cpu_work_list_empty(cpu)) { + /* + * Store rr_current_cpu before evaluating cpu->exit_request. + * Pairs with rr_kick_next_cpu(). + */ qatomic_set_mb(&rr_current_cpu, cpu); =20 + /* Pairs with store-release in cpu_exit. */ + if (qatomic_load_acquire(&cpu->exit_request)) { + break; + } current_cpu =3D cpu; =20 qemu_clock_enable(QEMU_CLOCK_VIRTUAL, diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 152abc9024b..42463e6258d 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 Sun Sep 28 16:28:00 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=1757326593; cv=none; d=zohomail.com; s=zohoarc; b=bqf83rvkXrcLuIRWeISZ9kbOBUMQLAHwhujn6lipaKNvw0C639r4JYMV6mkkGnbJpWgNRd8BjilKk9VTURjfDUqXRDNgOhMKEmb5FsoxaTAFJ3CTxpIn6ZwyJvYsG9olHVC6JfoARVyHl+Thh2FNYLLyblzVJHlpfxp7HMXu2po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326593; 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=9F9omlNx3zkAVVgrXaGDIxi/SyKkxZLJobZOnZwp8BQ=; b=nB6+UqrGeFAscgH1Vr03xWXrsNU4OlrLHOjnH56Sy6Hm7ccjS1pUSlHVMyeetATz7zMsqkHqGkKjkkaAAmhHPSHYei3+g3Ss6suh6TmANRgKIce4XOw8s+rX0M080hZoVGKPtIxV5XzgNYgFkyIPf0TTjWdO5/sPpRHsLbc1dO4= 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 1757326593224383.33960140296983; Mon, 8 Sep 2025 03:16:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsN-0001pU-RK; Mon, 08 Sep 2025 06:13: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 1uvYsK-0001oo-Ql for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:29 -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 1uvYsD-0000x6-88 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:27 -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-633-MkwKhkZVP9WCgaQbjLgtug-1; Mon, 08 Sep 2025 06:13:12 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3e3b77972cbso1450135f8f.1 for ; Mon, 08 Sep 2025 03:13:11 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d729a96912sm28665067f8f.8.2025.09.08.03.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326394; 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=9F9omlNx3zkAVVgrXaGDIxi/SyKkxZLJobZOnZwp8BQ=; b=TyFwglgstsuUAICrZFVOUZrww4FPSDfW7czFguUWc9nPm4BzBXrM5SECMijr1Ctr+818wH ynaot6TpTlLJ9Raq6lwP1gUMSzeyUedlLiCtXhbI2qPUbCQvJkEsRKMNewa+mX8rxa7lve +ftIESco114mhkHP6ExSEALE3LGRgDA= X-MC-Unique: MkwKhkZVP9WCgaQbjLgtug-1 X-Mimecast-MFC-AGG-ID: MkwKhkZVP9WCgaQbjLgtug_1757326391 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326388; x=1757931188; 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=9F9omlNx3zkAVVgrXaGDIxi/SyKkxZLJobZOnZwp8BQ=; b=HeZu1ZTYGV4qketcJLJI2If8IXHEJ3Q08iOpIkDMBYDQ55sq31ITtx+OS81gbEcknD 4qagXlCuNPDpOeWFo/yT03iIaTSHEc+6e/+5TFgUob9Vq4CcmQHRiby6bwpl/HJjDoFS nqINVGKGv/akLDnJiUQkmoiCxYKQy2xeHjv/qF/cCIptZvKX7GvzgWQlguEtqXsifR2d wNxOwEWJq2opGL7hJ+YzPeBarMplRFEMLlIwhiKKuo9EPif9fjdIVOWGxKRGq9cXZO6O FyObf4ivrOYWH3i/YHE+wEuyJWaBWoSH+rdFYl1XS1GNs9j+lRzBDlQYS9mTAM2Qw3/A Al2Q== X-Gm-Message-State: AOJu0YzsgvgjCQ/axufWAUepYb18wYdS5lXBbS2iVkvIpBB+fxMu9YVT aVzTBUBxx+abtNZpOxBKd5DtmkwUGRHg/ZLKKiFEyEeG+BPozTNKarnWB5bf6pA6QJ8z9gCqNSN m+c8LkrSG0XlhOfJuYcmPN39anuAm7a3j2JrVjuyDNOYAnTKRSXW34lsJGcTEWo+xb94odkLU89 5orAXJyRMQiYMYJQzR+p227pwlXwZVLLzoUrAn5zk0 X-Gm-Gg: ASbGncuOgn6N/ik8KkZvk4l6TgBSfeDes1Bf2uQ7NdbvBvaXbJwKe2UdIf1uzOebUvn NMgMjoffSU9WjnXSaumkL/rNAIn+SoJ784qQmiSwZb1lQZG5cs7PLGRpYgngaODoJkEm9o1AB6L rH/XfMwGfXeYvfF/+592qQx2U5yo8oE66QdrhKIvqmjMUYnAKPKQKo6VUcQqPriHSLaaYRVIC2B VwIbsKlBZE1f9q6el5/W+ZY8XyYbHXyjBLYY4Bn/BDEnLjhKvM7nVOIEQoFewH1IPnXNCf/yTJP mOtcrOT6W7wv66+JuravRg1/W8vWeI29Eh7nox8WcdQmksiG6llMCgcb5iyIfhXFf9sZ8htydXn 3PD1UwKcX8V16XEC9RajY/BkaDuMDGle/jobNz2wnwyA= X-Received: by 2002:a05:6000:1acd:b0:3e5:50:e070 with SMTP id ffacd0b85a97d-3e64c789650mr4848514f8f.50.1757326388281; Mon, 08 Sep 2025 03:13:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETPYIPWARpMny9jmQtqFuA7IPClj38ZHOG5z7M2vc4aWwgns8nIwsGlIiGgLvABmVep2ujJw== X-Received: by 2002:a05:6000:1acd:b0:3e5:50:e070 with SMTP id ffacd0b85a97d-3e64c789650mr4848477f8f.50.1757326387757; Mon, 08 Sep 2025 03:13:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Igor Mammedov Subject: [PATCH 10/19] accel: use atomic accesses for exit_request Date: Mon, 8 Sep 2025 12:12:32 +0200 Message-ID: <20250908101241.2110068-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1757326594972116600 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 Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- 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 e8b0e370a8d..d13e0d8b44d 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() */ @@ -293,7 +293,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 Sun Sep 28 16:28:00 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=1757326561; cv=none; d=zohomail.com; s=zohoarc; b=lC1yroMDX4iWC9T3LNsdC33k1ZTJPlh9O55oet2pcNfpxQJLfqjGz2Yfeq55WIUBp99y9Ux0sPjqyBmZssWU8goJr4wzGZVtATA6tcdHJPygfGG9H9+VXBAbFQcBASjE+sE5wTFuraMR6a3V6Y/La8qMACX6uO6f51cdRUoX2uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326561; 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=NNOluOBJNIDynOX/SeCHp/9Wa5GX8lq9yKO/uaKZQRg=; b=jFM04vykjCjBakFMhmcEnQn63oW7Dbg1BZsGfrerPVfJ20Te/I6On+lF3AkXvcZnw9f2P0/ln9iIHiJkFRrDhwnoYaOIXt/f6v3hY5LGGYNu6uW6REChibHsNC8XkHwEM1EmFxIv3e2fYatjCg1Oa74Az/oa782ERlTfChEw5Qo= 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 1757326561091480.5031555655695; Mon, 8 Sep 2025 03:16:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsT-0001tZ-Qq; Mon, 08 Sep 2025 06:13: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 1uvYsN-0001pX-2m for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13: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 1uvYsC-0000xB-NT for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:29 -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-618-vCGzS2HuOlixOJ-UQV3QXw-1; Mon, 08 Sep 2025 06:13:13 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3e68a54dac2so384457f8f.1 for ; Mon, 08 Sep 2025 03:13:13 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf34493b8csm40181801f8f.59.2025.09.08.03.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326394; 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=NNOluOBJNIDynOX/SeCHp/9Wa5GX8lq9yKO/uaKZQRg=; b=UhgZg9XB2q018+kkAjIiyIvwxQWAySvxNthXp/sSFgE4T+aO1YT0mGJQz4tihqCxckmxI0 d6K/jTqAHjyVhTVElf8UDKUY81K4hq1RaFv7B2/GLbEn6O8MxD4DzgLGbEGYZBeDzsPUM1 cLSajXrdGoC55J2e+m7fGfGSbWdO1P8= X-MC-Unique: vCGzS2HuOlixOJ-UQV3QXw-1 X-Mimecast-MFC-AGG-ID: vCGzS2HuOlixOJ-UQV3QXw_1757326392 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326391; x=1757931191; 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=NNOluOBJNIDynOX/SeCHp/9Wa5GX8lq9yKO/uaKZQRg=; b=SU1iWqiByYdSSWhekbikKNBcmHAxluFp7oUvUBMvO5ZqVjjakkPVcsNIbfg3a+U844 yzVty8AfzjLud7F/CPiEAlBNObnTF9MAPxbq+i09upOzzaQYRJN2m9sw+dIrXz+CO2J6 66tQVhZQAz7PZqo8OESN2r21PplBA6z9v0QGsM8CZTOqrbR7VBpbonHAp47Sorrk+m2X gFqyEbXnA5R4E2eXh7aJ3G6UAc+tyi/4OKvZvrR5Vgli/z6rN7//1NfjddJJIlRVmwSj gfhMTBjGXaCfA0anaSOtyKsFxRWlmI8kkBWfkLQ5nzOu7uT4hMz6nm4Xp4hVZaj+jfxe I3sg== X-Gm-Message-State: AOJu0YzP8mtUBuTUPhdWyHTKF6BMnat4S+vLgDxV6SuYinXNMfCqRnha wA9LEVy/f93BFcjhsrrufMJC7uFQ9xali+239wuuZqb+j/x9tdfxtw1ZwRv7GiJ2da6L7iLKwGe v9k7nwWMInzV7QqVv+6A8zaMJ6FgmEQPDeDq5xvvNgb/upx1eJ6ZPwtuOfaKf6UM2xtJHhc9QuX MMjcT/WOoX28oG2Y+ZZMd7q1S6ssWbX7jU9RiasIDU X-Gm-Gg: ASbGncvY/CgO8V0tuoosOtf1Vue0S4D8s4YRQvYlYn2KGWWg0IJGQry7R5KZYyiS8vn 6iOcdER7Q2V2q7u5M8z/K31dj+TGyydyk3G1X5HjuQEWTrnzeFM65n3f22dRQBqEkjXdthyAF6Z /Hg5qZ4A3DRg5lOdC+pI4KJv0xKLFLaQXMdhYoS78f/sc7NIaGezvnXFdVe/JR+TxQPVTaT58Di 7WqkUrckfXMBk1+6YVrTPREq1Xax+dsTTOxa449gZRFsyZ3nL1Hv6NlOKdM2H74x9W3WkI28Ub1 t1D6fsE0ng7rKbkXTvZPc3aXnrVyMZCG1HGJ8hv9Zy07PxDE9kdIhCbiulF13oIiOj8X+U54ob7 KhceRFhxwtaUaS7RStb2xA2UmOjakcDnOA8MCxSU9kOI= X-Received: by 2002:a05:6000:1a87:b0:3e2:e851:7f93 with SMTP id ffacd0b85a97d-3e300ae3446mr10075262f8f.7.1757326390674; Mon, 08 Sep 2025 03:13:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2pJGIYWJwE6StkLzHGPEjPIaEYufrfU5jk2BSgO6+GpS2gJl2d1sVD2m5rotGThxWdauADg== X-Received: by 2002:a05:6000:1a87:b0:3e2:e851:7f93 with SMTP id ffacd0b85a97d-3e300ae3446mr10075220f8f.7.1757326390104; Mon, 08 Sep 2025 03:13:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 11/19] accel/tcg: create a thread-kick function for TCG Date: Mon, 8 Sep 2025 12:12:33 +0200 Message-ID: <20250908101241.2110068-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326561823124100 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. Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 d13e0d8b44d..a1d75fd3419 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 9ba69642f50..73aae8c3274 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 7b0ccb6fd60..4ddfc9a619c 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 Sun Sep 28 16:28:00 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=1757326663; cv=none; d=zohomail.com; s=zohoarc; b=FEl8SU6U5McO3tMkdslEticA9/Ox8s2b8E5oqW18b4oyqEIG8H1TYjyGcPliyZFTtK4tUdhEH1eNjBPeR3h+tIZ6EpmKnfU4G4skcs9ICTG/igxVvHRaupUw1fz1OqRKfGPIN7fZ7rys97dDStmdHi+2f8PqcJEtvEJ7W4c/JT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326663; 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=OhCG+WyJrPhBH4S92lRWZ920ib0X1m6ZPw+jICRCIIg=; b=Nd28oQUE54LML735wTMFbViTlXyJ7vKkshuY224IYwGFcG72crz+Db6JQeef/nJLZJ4Aa9fbWFuoeyW8Hos1QeDjSJQGtnVAj8uTL4pesglaQeZhwCIe/dV4LPk4TJw61HS8aCGRmXlDwxBXSP3lPFk//LzKcuokNHKCuvY6alY= 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 1757326663284261.818010442498; Mon, 8 Sep 2025 03:17:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsN-0001pW-SH; Mon, 08 Sep 2025 06:13:38 -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 1uvYsK-0001ow-Aq for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:29 -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 1uvYsC-0000xh-1L for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:28 -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-564-iw2DYDhJMumy2v0CQpXZgw-1; Mon, 08 Sep 2025 06:13:16 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3e5190bcba1so2020220f8f.2 for ; Mon, 08 Sep 2025 03:13:16 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e74b2e0511sm2001540f8f.62.2025.09.08.03.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326397; 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=OhCG+WyJrPhBH4S92lRWZ920ib0X1m6ZPw+jICRCIIg=; b=jGNE7Sky13d10vHjeQWJcjH8GZOI/SukK2gvHDaxmc4ctX9J8UA5Lmctw5IAowEy3Jfkad fRphrGUCXB6Q2g4LfWrJpzpTMvSLAEAdzlYjwZlt2GRQO0eoYNBXEDldoehQ5S324DkCdo 1bY+TpaZK6aepb+Phvd7dwWsRlTz9Ic= X-MC-Unique: iw2DYDhJMumy2v0CQpXZgw-1 X-Mimecast-MFC-AGG-ID: iw2DYDhJMumy2v0CQpXZgw_1757326395 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326394; x=1757931194; 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=OhCG+WyJrPhBH4S92lRWZ920ib0X1m6ZPw+jICRCIIg=; b=ZXNF8C2nw+FX8SQGqBSMq8MP1BKui03hVuzTbegwYem2vqkx0cJsNSf7whyo7A8nmm 4dgWwAkEOb6a12MtooShMloCc2IdSXlmXv1rj5O4gyg79MXf5CPe6RRYgh+2lhNVV1ka EN2HUoxwvpT4yu1Njk8cqPLMepZuQ0MnPpjxO9sjKoTnJSBDN+F4R+u9S8EcUGO8rZ2i vGDarVKAFZwjBkcQRtAqJ07sdBSi37Bdvh0m1BTB0jjRmXOT4QJLHSGNyFh9Hmya3E5C oVqtPS4tGIjYWfye4Qf8QbHKYDtOBYdcuy1gmLKhbfHL/+qoDYMAuXWXVbhe46EEm+c4 0jFw== X-Gm-Message-State: AOJu0Yyrgu9nSkQDpSyVx3+tXgppsLmHMKVmV/r0ltTg6P6jQxjwD+CA U17+kiRhlLjQRahNc09qTR+5Hcwg0ofjBRILyO+h5Jimc6FvVq5H+UmD/t4l02vbqE/XiWCDm4q rnm+iCizk9Lb9saL0E635nKezDhOlzmrPHZELeMwopiU6QKiAWr5cYSPcHOewBq7R2W73JfKiuc r1gFE4sIWSryvKiPhYrihqs5TUBZffs2+ZoglklslU X-Gm-Gg: ASbGncuU96B5H7MPN57rZ2G3NwSeZXfBUpW4vYq27WngkUe4OVVVnUCh25lh2b6/4WQ NeheUxvbSCN4n1OCP1ByDPwV5PsBj/l6OKzoqMRzPciTSPv668lp9pdI/f2igyFXvURCfEByB2+ 83tardLpC6Dn22Uhi8mbq56w7B699RImnZc+BD7j9I1jxkqEaW/NSAcEJDZPVfB7OkrQ73aAaGf Lf0MCavpxAtA06NIJu5Q5wMqLRyptBOx1pAq/AIKDjp2LtdHNi7sHsuj91rOKSvgpNUPVL5ByoA 4WKZ5mD9Dnak6SmyC8u8cGTUX9I0U3rUJfnZDm2EVRZRimmI/rSFVwuX0x/NNM321V3OjdlT9Hp e/234l5DGd/z929OlGKvgQSpwBQTeAlz3OrKZJyU5jNs= X-Received: by 2002:a05:6000:1862:b0:3e7:45c7:828e with SMTP id ffacd0b85a97d-3e745c78359mr3712388f8f.33.1757326394328; Mon, 08 Sep 2025 03:13:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFU5tpEV4AMFi4hXnBISZdBdcMWZfW9rWm4p7JGrFk5S1ueaHFU0CxKzZXpc8jVrrAZqDHijg== X-Received: by 2002:a05:6000:1862:b0:3e7:45c7:828e with SMTP id ffacd0b85a97d-3e745c78359mr3712356f8f.33.1757326393866; Mon, 08 Sep 2025 03:13:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , Richard Henderson Subject: [PATCH 12/19] accel/tcg: inline cpu_exit() Date: Mon, 8 Sep 2025 12:12:34 +0200 Message-ID: <20250908101241.2110068-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326664559124100 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. Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 Sun Sep 28 16:28:00 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=1757326562; cv=none; d=zohomail.com; s=zohoarc; b=XfrhOtnmhHSUnLvssWNXI3jL+8dulZ/9WBboG/fOD7Z6wPVvBc8mh3oGZ+11dgCpe0vSvRRRycrQgU13kfVEk78MkVz7HM32a9YKpiW9Ujm++cBnF8ofW4il35LzSGF6rESiTOFNxVLSMvn21yoHW2/XYnu7sKeTZYcceViZiig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326562; 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=7joNFhlKCq/65i2RHs9pqNw9LGInItxc9SYTL3XBLRM=; b=KYFRhMPj/unN2s/gx5gltTWzIy/NsPg67UwzAvEtt/vRD+eI0JID7+/YtKD9oaJdifBI+H8OILUWhjlHbFyOukmaetShd8oQH7OBK38nxQSydrjZjzAn9qxDfG3H5LUcIYJh/e6KrLTpxE3MDAjl2aRYpb0bG8MZAh5Fq2/FQN8= 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 1757326562660812.3440113545914; Mon, 8 Sep 2025 03:16:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYst-00028q-II; Mon, 08 Sep 2025 06:14:03 -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 1uvYsV-0001uA-T7 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:42 -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 1uvYsK-0000yi-Mr for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:39 -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-22-igiFS-i9MhmzylMlGJqG3A-1; Mon, 08 Sep 2025 06:13:18 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3dbf3054ac4so2451761f8f.3 for ; Mon, 08 Sep 2025 03:13:18 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45dcfc481b5sm88404475e9.0.2025.09.08.03.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326399; 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=7joNFhlKCq/65i2RHs9pqNw9LGInItxc9SYTL3XBLRM=; b=ZlyhELw+54BWda4fTs2NcQD5nkcknU5vggajS/IeH8NxNZUgnJTc3PJ/Fi0jF14DCLhSL7 s1PXAwym7TDSilD1HFe5dl+Lsc3mfeZRW8re3mBU4iEYCfkOF58Nx+kpKIH2DfneZ2lrIi zJtvwu9/lITKpfgOZViBNcbS3qECQiE= X-MC-Unique: igiFS-i9MhmzylMlGJqG3A-1 X-Mimecast-MFC-AGG-ID: igiFS-i9MhmzylMlGJqG3A_1757326397 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326396; x=1757931196; 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=7joNFhlKCq/65i2RHs9pqNw9LGInItxc9SYTL3XBLRM=; b=rw9BDUdJ318CUl2GufsNQHuXM/X2YvfKXMBKiWYZ9j+uYboTpdNGm7tWpvzum0v0Yc iDhyxUql8SLGR/YfIMJKGHNMVXXPF/sdLVfJfO+P5CZCI0mTIhbMQu48h3L9uYFI9q1B +My4GlwMtf2LZC0R9PNOeyH8FRXa+XWUX3UYBhtwGAlcg02hSe+EfWxVgoEOC7kQ70fM bd2SbQBYFXWMM4NdenmltgJqHcI/5QjFLGVtctGGye7KBe9upowbHcMMciUBDiqeFVgW kyXY4il/LsgaUR/QOJEPQVNsMn1uAxV3YOm8x1PDrGxdToGsBjm2mDKXbFubydPIMvbZ 2U3g== X-Gm-Message-State: AOJu0YyDSmwCFWoh00h/meH5lkWFeEjFs25RwrlfHsKZa7NuWhw57Vot ULNxtMrBU4VOXM1nhVeskWXCrvdNccslml7YMfjbHNi6SmgNHa82MOw8nRhOMUi6KK2w4t1o9/n blgke+37pOT4/mB7TzEy5p4e6kkkQvmRbx3XDqBZ57ujO46tnQCjcj7qweCPYyrCLaOSpbDpTw1 rEz67GnsvLimyeonPKCLz/3v2AO5V2ji4C+YQjVmtR X-Gm-Gg: ASbGncuiT6HA9fKKoSiYXXV6CpCZc/7wvnRsT6JfeZ1s8dILPNZXT/8R1hn9dya9r2/ UIMA2cxIYgSLfcRK/f8qqEiYv2xSZWzb9prk64RgXIlVmuMHmT+XxaryPr5jP5iHBjXheHddNbj DPP8hESeVS5nAYpgmnvyxRCFLWdHoRp5wDtnIP2FG2rWYpsGNOe+TaatkQLi9TfFbukALR14L7T nOvufe0oRaLRZlX0c7Q9NCPX4R5DeBxpae7KPyLdbau2rn/PPNVBviJpTdz79Eh9Wy1LelLA+Sv jvgCDVHi8UWfi3zOHEYWm+sYzqi727OtX7HL2UT3MSGzP3rFfr7MUBzNsZ+OuV958rQTcx/TxlJ 8wmKlj8ZTJK3j9STEe9N5SYP+eAFp9Dnd2WCXAaPo7ZY= X-Received: by 2002:a5d:584a:0:b0:3e0:152a:87b8 with SMTP id ffacd0b85a97d-3e636d8fe92mr4845535f8f.8.1757326396447; Mon, 08 Sep 2025 03:13:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6wpkvhjlwFo5OKt5dWh6HWDtHXYSRjcuxnI1ZhwafTs5xV2Yy7275cyqfro4trZUvCxEPAA== X-Received: by 2002:a5d:584a:0:b0:3e0:152a:87b8 with SMTP id ffacd0b85a97d-3e636d8fe92mr4845511f8f.8.1757326395999; Mon, 08 Sep 2025 03:13:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Igor Mammedov Subject: [PATCH 13/19] cpus: remove TCG-ism from cpu_exit() Date: Mon, 8 Sep 2025 12:12:35 +0200 Message-ID: <20250908101241.2110068-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326563645124100 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 Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- 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 42463e6258d..41a339903ca 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 Sun Sep 28 16:28:00 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=1757326667; cv=none; d=zohomail.com; s=zohoarc; b=mCMGmnovlVOzFtXQZ3SxJgKD7j5SBY0SjUt8JCbJM+fIBArX2FxzDsZ/l18o4tWGxWcm0SDTlSK/c16KtCdP0hEe4Hmsigf4is0qEaUjQnBiMUYGc1JNMaj4fhMhByynMPaMo3iOxG8dZaL/j5x65QKQ2Oy4MSUdUfm10j90d98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326667; h=Content-Transfer-Encoding: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:Cc; bh=2FBfbeW/bflO49mLQZHyXRm3QyIf16LzEEIoDWnaeYA=; b=EKfxNbgEQ+MT8eOT9MnUbNUOJ7lq5GM1mde8Vbl6QCN+gP3FvT6rMaIFnCLO1Abr8qxuHfVWHNa9rfegE4sRWsWl/P64mMZNOlWmRHWRFeRFTpSPfjY5no/y0UAajPLa/kWxjD6cQXZSM4yOPJcWbMkCY65aPyYCttRpdjkG2I0= 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 1757326667721608.8078493782104; Mon, 8 Sep 2025 03:17:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsa-0001uq-H3; Mon, 08 Sep 2025 06:13:48 -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 1uvYsV-0001u3-1m for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13: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 1uvYsL-0000zk-5s for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:38 -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-191-Rj8YtlReNKaT1fBNVgNVMg-1; Mon, 08 Sep 2025 06:13:22 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3d3d2472b92so2323191f8f.1 for ; Mon, 08 Sep 2025 03:13:21 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f30fe02sm506873265e9.18.2025.09.08.03.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2FBfbeW/bflO49mLQZHyXRm3QyIf16LzEEIoDWnaeYA=; b=B+8ya+cRz+VpVepFT3Vv9sQu0INP/2F3cHB/q8GxQmQQ4mmUeDelhHAssksioj7w1JgAmP SbRqXci0bsHpW5WOFx6JyfEFRGI3/EbxPpJXXM5LsCMedoMM5LHP5pO2hAemYIDXW1LOyt FR49yjDh799JME5Z7VsgUGzYEQCXX68= X-MC-Unique: Rj8YtlReNKaT1fBNVgNVMg-1 X-Mimecast-MFC-AGG-ID: Rj8YtlReNKaT1fBNVgNVMg_1757326401 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326400; x=1757931200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2FBfbeW/bflO49mLQZHyXRm3QyIf16LzEEIoDWnaeYA=; b=NOCvN/teHIF3LvL3F2swrGdomcgzVCv1Lln1t4myHCFqB7niPgD2Q4VP97k8fTkJkG sOZvy7P56sHAsJph/rD/t4KwspGkAWHVqZncH8XsKP/mx164agQouhA8zKBSB8brxKGA 13dE1LuHReAdJRmgfDFS7Pv7kyOAz5sANFUseG2ocGFay0i+P6EuClfRy1w3KX8s8HaK kjxJDQTarW8GrmjNZYAnMrinBE/CaOMhJpnxfUgEDWLVPKUNjqaKI8CNgHF2CgHFvIxm bDGXRtWSisrSS6px/GrkZeBvK0xUpd2DUa6YxjVFOR1gIgji1LS3CIKlmoeZ/DpAmmQH 1suA== X-Gm-Message-State: AOJu0YzFpP8CtBDSO5GrE026lAVGCTmpY5Ft+Ga35SCoANw1/4MAKIcP lDLtgJroxiXXEdmFvYL8NnynGtdhjaL49WeB2Tez84Hc0sGC7JZ3Ucl9ZbfLJSpiJVKcczNhMHI c1nGGdUsOGkh/hDL4BiJKlOjhjuLQOuYIifFeh1FyA7mwSdoseQtDp29f8UE5NKMXJHUf1rtrPx gyUuC53mg2jvZN55Me/0zNq8mFx1oqOdb00t5QD+rh X-Gm-Gg: ASbGnctSZjmY3JrDCQuivbIuGR2hYPiNpZ+aft1ynTqPyBxSzr5MJbSOrTIwICDqoBS vdadKuU1AkbvsD+yPU2FJJ8rWcwSSYa7AoR3du99JPDh3HdZEZv49IGGDmSt05Pd8fU1E6PCT/9 dCkUDOkodk7QCNgiimI1qAZgOc/DwPloQjz3W8kbzkGFL1FJwXzekrUxUDKGl8EZ4U+WifGfNja ZAAHUzNYwZHmN39hITTVV0wZyQ9EmsV4QFOXv+GCqlyRK/BswdUGA/ieBQKZh/roaBsJUJO5blu L/tT0AEaUO+ZjvAwD6yCz2NiE1XqX+4lS7sTyhhYUTivdTJy4yYw0o6iuzXyK1cTh9ZsZ4tF3PE Uzn17rIR9B5PNxbWoLK/+vjafBYHi3KkMOSbPlvY750o= X-Received: by 2002:a05:6000:40db:b0:3dc:eb5:503b with SMTP id ffacd0b85a97d-3e64cc62ff0mr7321730f8f.56.1757326399757; Mon, 08 Sep 2025 03:13:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrFY3aqEX7kFKEcD2VLRVHo7Gc2EfYAGCOyIc+1my4e3LyXglW+oZG6E7Yzm+WfGwFHt4chA== X-Received: by 2002:a05:6000:40db:b0:3dc:eb5:503b with SMTP id ffacd0b85a97d-3e64cc62ff0mr7321679f8f.56.1757326399130; Mon, 08 Sep 2025 03:13:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/19] cpus: properly kick CPUs out of inner execution loop Date: Mon, 8 Sep 2025 12:12:36 +0200 Message-ID: <20250908101241.2110068-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_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: 1757326669835116601 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 Reviewed-by: Richard Henderson --- 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..9919b46230f 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; send it 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 Sun Sep 28 16:28:00 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=1757326647; cv=none; d=zohomail.com; s=zohoarc; b=VFU5YMKmmXtHYFbkdnajywpBzUjlE5ZF1pUC/IhaukXlSyzTgning1gV8xOPp+u+2tWnoNOhoYku6VFe8Woc+JfLzimUHmxm23Wh0yx9TqcGCri5sp2kwpI568FC2cdM/k75/QP7H2B2Tu7YYce1zoFz3Jxr93vS4dlY7YKVXfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326647; h=Content-Transfer-Encoding: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:Cc; bh=kXQMi8BZDSg1KOQd6AcbPnJhdPXj2cGy9rxZHEZfEC4=; b=jKBjFjz3PKl5O6WG65O4aCnBviOikyW6U9NkvgMLALQP8+3+CxYwdcHiVl31LUtPjPsPb6m23temmC+boVn/BXI1SJWUeYQDZbRTyUSYyd5DK8Kz0sKU/3ZWOkBk7U2xPv+rruX6QgrEPa/URdftbm5dPTvNKU4uUFnqYn1BdeI= 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 1757326647144177.8560076435641; Mon, 8 Sep 2025 03:17:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsY-0001u4-7n; Mon, 08 Sep 2025 06:13: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 1uvYsS-0001tG-U1 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:36 -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 1uvYsL-0000zm-Ks for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:36 -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-142-Sg2bjxReNJKfRL5WoBGUsQ-1; Mon, 08 Sep 2025 06:13:22 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-45dda7c0e5eso23736565e9.0 for ; Mon, 08 Sep 2025 03:13:22 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45ddb779eb6sm120988385e9.8.2025.09.08.03.13.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kXQMi8BZDSg1KOQd6AcbPnJhdPXj2cGy9rxZHEZfEC4=; b=S4uQD0p/NMocJiypctrN8ikN2/l0LhnrBx1BoOzHeAVSkSVBnkbCiRvqTMnNmLYhLKGgmV /BcHGizqqYPrxYhgYzP0JK2RBiU17gXzEUrJYSnR5uXB6Lh5lGpXtWZ1n4cGhRL5B2svnP B1kZWTRvPqc80hkuN1u+Eqyp8i2bnXQ= X-MC-Unique: Sg2bjxReNJKfRL5WoBGUsQ-1 X-Mimecast-MFC-AGG-ID: Sg2bjxReNJKfRL5WoBGUsQ_1757326402 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326401; x=1757931201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kXQMi8BZDSg1KOQd6AcbPnJhdPXj2cGy9rxZHEZfEC4=; b=RvAaZ/AZR6El39uurZrU4uRehB67WOxsm7UtTqfUOZTUEVbpvA247DAajyu86zZP+W JPVHzsljkHTe/iec0D6M6KHJ3JBSacHaVggvby7zsoE6J2pEP21FjmfitXXfzDGNeDOg xv5s/Mb+3g6qc5QGCZ7ol7txaUAuKH9jE3M8LIUY/+WwvNCSiesvinrkkjLAsxcyee9n JE7XsiatCyW9XvicC/jPu9KiwKj0TTSCa8RWtnHNg7SjHSZ8FZ3yX2YOafnXjbyDD9s0 xeV5DpdEEFvhXZCyBcYR4oOR9JcKkOKp84G32YrryZuiu7GWa3wnnXs8GZ3Iie1oIsYM zbMg== X-Gm-Message-State: AOJu0YxYYmYOHBE7yY4G23LUQzFbOBknb1JMXLJKUAo/w23MD1CPwt7U XlTZzmq5YmNGZp3CwIAAkeqYkIUl2WcxlI23e3xZDa50EAIBzydShY4c51BsJ09nkZm2Q/snxZb P4IXwJyXTKIjWX+53sZZ202umfFhkpkSLGnDpF+utLMS6I+ebQul7UOv0BL84Vx8phfQRLqbvj2 Plk/wU02U/Mj7WYBU45HwE4mrFrLggZaMaH4HZ33Nz X-Gm-Gg: ASbGncss7flAGZgU13e5XZKLkeLIEWHchdHsWAums29q6kNzobA+KBw9+ONTfenvLz0 74wrNA0w8cLCImRqX1818uzc5UHO53tR3nnEHXgFjkpEkx2qbklvzGafUIb523/8H3eWWeLsaje dITbHXzE7p9I1LqwCtWRJ+fWITH8xFRbsT9vzMWsDXik1VYQblioMlr2pP/Sz+dji/Jw3eWEXTt dPKddyL0WbQYv+wJfYFv9XzgUCfw8ZkvIQPqPdUwyoE0oWBvQ1wRo44YDP/bg5ojMoe2vsS2eRM CwUq3KA/qFQinA+0f2pHlUnTfp6fsj6zOZO3CXjkG1/GitTkThEZqunbEgSULZgq2nGz34B7ofx GCP++hhNUdFCGxnQ8mC2iD0scOT7g5TTIWUQHInWEr3Q= X-Received: by 2002:a05:600c:45d4:b0:45b:9a76:ebea with SMTP id 5b1f17b1804b1-45dddeeee4cmr60636655e9.20.1757326401129; Mon, 08 Sep 2025 03:13:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDzo6psxOTaiHgTtNyoK037UNzS5vsqOyIa8Y5wxCtBxpqtdUODM6CmRXfGe2jtX0D7XxY0g== X-Received: by 2002:a05:600c:45d4:b0:45b:9a76:ebea with SMTP id 5b1f17b1804b1-45dddeeee4cmr60636265e9.20.1757326400585; Mon, 08 Sep 2025 03:13:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/19] treewide: rename qemu_wait_io_event/qemu_wait_io_event_common Date: Mon, 8 Sep 2025 12:12:37 +0200 Message-ID: <20250908101241.2110068-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326648490124100 Content-Type: text/plain; charset="utf-8" Do so before extending it to the user-mode emulators, where there is no such thing as an "I/O thread". Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 2 +- include/system/cpus.h | 4 ++-- accel/dummy-cpus.c | 2 +- accel/hvf/hvf-accel-ops.c | 2 +- accel/kvm/kvm-accel-ops.c | 2 +- accel/tcg/tcg-accel-ops-mttcg.c | 2 +- accel/tcg/tcg-accel-ops-rr.c | 4 ++-- cpu-common.c | 2 +- system/cpus.c | 6 +++--- target/i386/nvmm/nvmm-accel-ops.c | 2 +- target/i386/whpx/whpx-accel-ops.c | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 338757e5254..6075be0b59f 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -422,7 +422,7 @@ 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(). + * @exit_request: Another thread requests the CPU to call qemu_process_cpu= _events(). * Should be read only by CPU thread with load-acquire, to synchronize w= ith * other threads' store-release operation. * diff --git a/include/system/cpus.h b/include/system/cpus.h index 69be6a77a75..4aebec48705 100644 --- a/include/system/cpus.h +++ b/include/system/cpus.h @@ -17,8 +17,8 @@ bool cpu_work_list_empty(CPUState *cpu); 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 qemu_process_cpu_events_common(CPUState *cpu); +void qemu_process_cpu_events(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/dummy-cpus.c b/accel/dummy-cpus.c index 03cfc0fa01e..225a47c31fd 100644 --- a/accel/dummy-cpus.c +++ b/accel/dummy-cpus.c @@ -57,7 +57,7 @@ static void *dummy_cpu_thread_fn(void *arg) qemu_sem_wait(&cpu->sem); #endif bql_lock(); - qemu_wait_io_event(cpu); + qemu_process_cpu_events(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..7a27bdadb4f 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -198,7 +198,7 @@ static void *hvf_cpu_thread_fn(void *arg) cpu_handle_guest_debug(cpu); } } - qemu_wait_io_event(cpu); + qemu_process_cpu_events(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..65a7f76a69a 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -53,7 +53,7 @@ static void *kvm_vcpu_thread_fn(void *arg) cpu_handle_guest_debug(cpu); } } - qemu_wait_io_event(cpu); + qemu_process_cpu_events(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..342917c5f6e 100644 --- a/accel/tcg/tcg-accel-ops-mttcg.c +++ b/accel/tcg/tcg-accel-ops-mttcg.c @@ -113,7 +113,7 @@ static void *mttcg_cpu_thread_fn(void *arg) } } =20 - qemu_wait_io_event(cpu); + qemu_process_cpu_events(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 a1d75fd3419..813b313859a 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -117,7 +117,7 @@ static void rr_wait_io_event(void) rr_start_kick_timer(); =20 CPU_FOREACH(cpu) { - qemu_wait_io_event_common(cpu); + qemu_process_cpu_events_common(cpu); } } =20 @@ -203,7 +203,7 @@ static void *rr_cpu_thread_fn(void *arg) /* process any pending work */ CPU_FOREACH(cpu) { current_cpu =3D cpu; - qemu_wait_io_event_common(cpu); + qemu_process_cpu_events_common(cpu); } } =20 diff --git a/cpu-common.c b/cpu-common.c index 152661df8e9..0eb5c7b8f24 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -137,7 +137,7 @@ 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 - /* exit the inner loop and reach qemu_wait_io_event_common(). */ + /* exit the inner loop and reach qemu_process_cpu_events_common(). */ cpu_exit(cpu); } =20 diff --git a/system/cpus.c b/system/cpus.c index bb13942cbb7..fd804e07327 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -450,7 +450,7 @@ static void qemu_cpu_stop(CPUState *cpu, bool exit) qemu_cond_broadcast(&qemu_pause_cond); } =20 -void qemu_wait_io_event_common(CPUState *cpu) +void qemu_process_cpu_events_common(CPUState *cpu) { qatomic_set_mb(&cpu->thread_kicked, false); if (cpu->stop) { @@ -459,7 +459,7 @@ void qemu_wait_io_event_common(CPUState *cpu) process_queued_cpu_work(cpu); } =20 -void qemu_wait_io_event(CPUState *cpu) +void qemu_process_cpu_events(CPUState *cpu) { bool slept =3D false; =20 @@ -474,7 +474,7 @@ void qemu_wait_io_event(CPUState *cpu) qemu_plugin_vcpu_resume_cb(cpu); } =20 - qemu_wait_io_event_common(cpu); + qemu_process_cpu_events_common(cpu); } =20 void cpus_kick_thread(CPUState *cpu) diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-acce= l-ops.c index 86869f133e9..d066364b989 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -51,7 +51,7 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg) while (cpu_thread_is_idle(cpu)) { qemu_cond_wait_bql(cpu->halt_cond); } - qemu_wait_io_event_common(cpu); + qemu_process_cpu_events_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..2ca4ee02636 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -51,7 +51,7 @@ static void *whpx_cpu_thread_fn(void *arg) while (cpu_thread_is_idle(cpu)) { qemu_cond_wait_bql(cpu->halt_cond); } - qemu_wait_io_event_common(cpu); + qemu_process_cpu_events_common(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 whpx_destroy_vcpu(cpu); --=20 2.51.0 From nobody Sun Sep 28 16:28:00 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=1757326574; cv=none; d=zohomail.com; s=zohoarc; b=P9ffgvwwVCzOYbU9kZOUgic51TKmnGooXF/nJnLR6eiSny2D9lDx3Qda5IoQtZ6xuy+EPKcJCHNGoLTK78oCEt+8POoxAT0jQsdEOhKEIs+8RiVDXn42V5GKrmopDCizH11nEnRL7dMjTaKLUi1vY1gFmQIUypR81mDIPc5+OLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326574; 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=MLX+lf73T+hkI0mv5GU16nOIJm0KC0+gPanOvDHIci0=; b=j7u54qQwPfHdJSMX2EDm/ucDitGZDQXDBgo/kegwuX6nepuJJ6ow44zUdg0b7Bs7qHa5ZnOjFrHVKxBRijqeG0MRBXQxS2WVWHGY7n4P4WdFQhDcxVWnEC9MhZe6cakyUvm5iXzSqHTvBHe2VMsyoYP4rQHUQMWzCBF10WKD314= 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 1757326574334899.0630941731595; Mon, 8 Sep 2025 03:16:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYt3-0002HU-Ow; Mon, 08 Sep 2025 06:14:13 -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 1uvYsZ-0001ul-RE for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13: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 1uvYsO-00010d-21 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:43 -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-253-ZXHBkzBxNwGgIBuGLPxqgA-1; Mon, 08 Sep 2025 06:13:25 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45de5fdda1aso3359045e9.1 for ; Mon, 08 Sep 2025 03:13:25 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45ddd47b6easm103837175e9.18.2025.09.08.03.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326406; 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=MLX+lf73T+hkI0mv5GU16nOIJm0KC0+gPanOvDHIci0=; b=S1KRk4vnxqajG21dLpOJ8h2sTt3Pzko7mITTBEKbagSLkGMuihB0iOzWOEuChB9h0SsFa7 E3EMqw/t1Ln7efzoDa/oku5Uu7sU1osGN/ZeicVNVf2XgCAqGPklIORU4GHdeoXpYFbpQM yyJRvGW/ZiTBMOJYOPSlWPoAEciKBZ4= X-MC-Unique: ZXHBkzBxNwGgIBuGLPxqgA-1 X-Mimecast-MFC-AGG-ID: ZXHBkzBxNwGgIBuGLPxqgA_1757326404 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326403; x=1757931203; 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=MLX+lf73T+hkI0mv5GU16nOIJm0KC0+gPanOvDHIci0=; b=cIGJAqyGo005s5PHFFHSLXaq582ieBkNRZerwXCd0rcZ9KVZY1psm1drbHaIfqkMiY 5PYHPYZfx/OarShBifDypGmH2CT7m2qzyjxT4IAHpLKiEizeU6ngg3MXg41eHscemJXm YDp/b+/djkfPj9FppM7qyR/AyJem49Xwggfm+cJBUdJS9HX5PLm7H9lKmNUMDj2JMyCk Vlgs6RJYyEK1WfpRGRhlARnhMwZAxp8g34xDCe14abh5ru0DjJ2oUzMURML32crkY59u Kij2vGFUVgW+B0SEi8OG9FhC0Zem0WGmGJWySPB10yV/Hoa/RaCZQiAQTnNEPSAgPfYr caxQ== X-Gm-Message-State: AOJu0YxUVTZpS3Z3Hbu5d9uBUIIvmdPDBW1sQgjb0ib2ZJ3Z+brmsTRj SjsOTnjniuhwtclJRtSMDa8nvrzR9HxT328gJzFZc9UiFo9bN6H+nlFdmG7DEXfVizw6mKHD7k4 3ZRlVT5GX27MS0I70t7S/UaK7/ErsEyfM0bszDqmz+MvYI/lYw3NbVGCfs4yn+WCeHPvFiUlWzn TpUX4tWojFZD8DkHkGJ7wuCbkuQPd6avMfEohpKpIG X-Gm-Gg: ASbGnctJjIXtNIaWOKwc0Q2xr+FPqJn9CSI2i9VgfLQInUJy/6UUuGNtoBBPsMDsygS w7WzrPnmobnM3JF6j2kFEUyHMKfmWuiojyFnZzjlxcv5rBvO+kvNnjQAoZuEhBLMuAvVEpp7eiR z6lCHKds5zo8Y6W2uaDMQ9GBnDYnpAuO8vHIzsgwLyukHQAtplQ8Iu9Sc/c+oEpucxczI/7rs8t booyCmhaaFDpT1H3y5XI/t2Fsyiq9z8u58Vlcq0aJlAyoNCTCOfgWsdTSp8rTG/q6827rnU7l98 UhAEs4Bdb16ydeNwTk8QyU6ioH4qn+cmaOGKoA73IcOddE7hx/Mg/HQ8Uc/vXJ4uelXGQw4eAJm sqA3+oKhtRaf85w1b86DUs/IP0TyvE9RHFJHFoeJeC2g= X-Received: by 2002:a05:600c:4e14:b0:45b:86ee:415f with SMTP id 5b1f17b1804b1-45ddde8a741mr70633085e9.6.1757326403415; Mon, 08 Sep 2025 03:13:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGz0I3vcYp8tMHrTHMmnr/HiIfuhKgszsHhDfHrWJWUdBUpJHffo1GTJAhyOXDEMVMPZjwNeQ== X-Received: by 2002:a05:600c:4e14:b0:45b:86ee:415f with SMTP id 5b1f17b1804b1-45ddde8a741mr70632755e9.6.1757326402909; Mon, 08 Sep 2025 03:13:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 16/19] bsd-user, linux-user: introduce qemu_process_cpu_events Date: Mon, 8 Sep 2025 12:12:38 +0200 Message-ID: <20250908101241.2110068-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326576622116600 Add a user-mode emulation version of the function. More will be added later, for now it is just process_queued_cpu_work. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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..15df84fda21 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_process_cpu_events(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..9a952ef0ff7 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_process_cpu_events(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..f147d5b6f85 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_process_cpu_events(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..ad428d0263d 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_process_cpu_events(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..1fa71d87f12 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_process_cpu_events(cs); =20 switch (trapnr) { case EXCP_SYSCALL: diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 6075be0b59f..fb788ca1107 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_process_cpu_events: + * @cpu: CPU that left the execution loop + * + * Perform accelerator-independent work after the CPU has left + * the inner execution loop. + */ +void qemu_process_cpu_events(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 4aebec48705..508444ccf1c 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_process_cpu_events_common(CPUState *cpu); -void qemu_process_cpu_events(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..65f5da6c506 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_process_cpu_events(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..f6b498c6c43 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_process_cpu_events(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..bb8346b5094 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_process_cpu_events(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..cd89b7d6f5e 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_process_cpu_events(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..1941f4c9c16 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_process_cpu_events(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..356cb48acc3 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_process_cpu_events(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..f3f58576af5 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_process_cpu_events(cs); =20 switch(trapnr) { case 0x80: diff --git a/linux-user/loongarch64/cpu_loop.c b/linux-user/loongarch64/cpu= _loop.c index a0a4cbb7cc3..26a5ce3a936 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_process_cpu_events(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..2c9f628241f 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_process_cpu_events(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..78506ab23d9 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_process_cpu_events(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..2365de1de1a 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_process_cpu_events(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..2167d880d55 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_process_cpu_events(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..b0b0cb14b41 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_process_cpu_events(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..ce542540c28 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_process_cpu_events(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..4929b32e1fc 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_process_cpu_events(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..0c9d7e9c46b 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_process_cpu_events(cs); =20 switch (trapnr) { case 0x160: diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7d30cd1ff22..7391e2add8d 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_process_cpu_events(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..a0ff10eff82 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_process_cpu_events(cs); =20 env->sregs[PS] &=3D ~PS_EXCM; switch (trapnr) { --=20 2.51.0 From nobody Sun Sep 28 16:28:00 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=1757326659; cv=none; d=zohomail.com; s=zohoarc; b=KKeuRw8xVoheK+wmQLjN1b5AvMHEDFTRmwgm96uA3SFrfUfh2QXAXJOiKYyVCembMIlpap2e3iBCEU9T4A14ZrsmbGpuJAOAa75leF5l3x3OYOrN/fJ1xSGyx9xavTabWl8WIpcDZDsprul70K+Lez1yay5RZUqb2HgdRG5trBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326659; 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=qlij/+xB1jeZ/DQJ1zSRVc1BKfDXu58VvWt1lqi6rrQ=; b=C8nJi6UPuT8jB76RMHqNQiuYyUl/vdKL6pPj7IWhn3Aph1V3T1kNYCeMlhrpmFzyZTXYY8y77bcDzgLPNVRBYPM5VT0mzrPpabCapQqZbGYznXyEpF/mU1BRZhzdn9GhwlRjpPXPw+tEdm52Wwxy3i8FDGL1nDqFd2OWaShzMGI= 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 1757326659767466.00753372438453; Mon, 8 Sep 2025 03:17:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsn-00022y-9j; Mon, 08 Sep 2025 06:13:57 -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 1uvYsY-0001uK-NR for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13: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 1uvYsR-00011K-A1 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:41 -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-496-7iAf9qK6NHK5UAJ47bGXtg-1; Mon, 08 Sep 2025 06:13:29 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45de13167aaso12610415e9.1 for ; Mon, 08 Sep 2025 03:13:29 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45dd5098292sm155467125e9.1.2025.09.08.03.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326410; 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=qlij/+xB1jeZ/DQJ1zSRVc1BKfDXu58VvWt1lqi6rrQ=; b=ALBNyI62rwLM/NN00/OGqlS9aJtL8c1fFz5IrVPKSuwtR/QniFkcxZezbQ6ftXS+rYpSrF NhHufvxuw0ykBybykV9Hu3I9SDS/eLfU3vlRB/Ayo8k6CMuXrUJ4NBXeC5pwThuAJS4+1X k/LPUVId4D/GAxgpE0AEmMyNKoSo4Mw= X-MC-Unique: 7iAf9qK6NHK5UAJ47bGXtg-1 X-Mimecast-MFC-AGG-ID: 7iAf9qK6NHK5UAJ47bGXtg_1757326408 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326407; x=1757931207; 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=qlij/+xB1jeZ/DQJ1zSRVc1BKfDXu58VvWt1lqi6rrQ=; b=PxF+HFkkoQp5eZUq8AOTDcbuj2RE4hDwoCE4vXtx3QlVAiVOgIvtTKMiQCzQVU1AMd Rx3c4dy2gr+rDZWOruhcG8p7ZWa7rfsXirm9Tt3SyJ0bXuU/YcpwL8TZkO0gMCjw+tNy 7D3Y6VEzt213dqIix2RfcPnTRFDq1nSQ6qf8thUpVWi73PnkStjU77Ba8/UJdxwyWK0x JI2GoTuOwEuzWolntddPKeDO38stdP+m8be6RSSL/M611yDzBJu0kIOhsAVp8XunpBMS ewXlvTLWe4YUtD/MNBax8VgWUl+UCEqZ6ckxmqAkf+kl3Xz3sXvVJcVtpThIClciHbnR 5JFg== X-Gm-Message-State: AOJu0Yy0RZeLtDdI4/4AIuOaeUmlYkirye6mXGXfxTouY5QzdrdyziOE 8GOTE2efX+MlC6rhcYgZDOlE2h7t1o9jeV071SXdsyz8SKwHkdAsfS1zkeJJrTvcI25vfIGotFo JWDy++6rtzraAdUMHa603fyO/WEkbfSkMWQw45reiQ1XGxsyd6PTRssYO3rxIcv5E72UAnndYxR ZBQIuT/r0lGNtA3aEbToX9NTlaodvmOX5Ox74eiBtf X-Gm-Gg: ASbGncs0KIoo1xqGrHFLzUJQrPYGdnbwjDfpPvqiWNK+iOrGix76yEiS7vPv845fikw MWrbQImDDxuwQE100y4Ti0VHD4zkgPI7d6O+SUgCDQqhTtI0iB1L80gL8VxJIcD2ue3coZnTER4 eg0vIB0WczW4nr+MkVYGWY8j+kKN+q0XVakjdE/EqbX0DHO/UBHxurtd4+2GaJaDDB1rfnYuZOb XkozVSUpSrBxBs0o4M4E1ee5s4AcfFy3gxH0LL7emh/UBJWMmQeD4DgFSN9W8wx7XLxSCDgcIuI 9Y1MJtDJyJlo/KVgmtWspOLC6b+HmKOqpiAWzyrMHP2uPErgY0JQynsgeXeb8q3sg10fYJv09JC CLOkQKtbDh6R79tCkDVuIZ3abcwd60ZUgRcGyQRylfNY= X-Received: by 2002:a05:600c:1991:b0:45b:5f3d:aa3d with SMTP id 5b1f17b1804b1-45dddeee57cmr52195915e9.21.1757326406996; Mon, 08 Sep 2025 03:13:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELSyrvkCLH15zja2lRmA1Dfj1AslSMpN7NT6W5hl3EvNHL9VIGpIwXDWSS+D0DPW6lYdCnvg== X-Received: by 2002:a05:600c:1991:b0:45b:5f3d:aa3d with SMTP id 5b1f17b1804b1-45dddeee57cmr52195575e9.21.1757326406522; Mon, 08 Sep 2025 03:13:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov , Richard Henderson Subject: [PATCH 17/19] cpus: clear exit_request in qemu_process_cpu_events Date: Mon, 8 Sep 2025 12:12:39 +0200 Message-ID: <20250908101241.2110068-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326662654124100 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_process_cpu_events_common= (). So for the common cases where they use qemu_process_cpu_events(), 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). Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 813b313859a..7dbdba7b514 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -293,8 +293,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 65f5da6c506..916f18754f6 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_process_cpu_events(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 fd804e07327..aa7bfcf56e5 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -463,6 +463,7 @@ void qemu_process_cpu_events(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 Sun Sep 28 16:28:00 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=1757326592; cv=none; d=zohomail.com; s=zohoarc; b=MJVbq8791MY41tDGbn8rf+fWf4gJ3r2iF242GNygFkBGA/PUA47W5hFR0ZfgauKIPqHy4UgjyvIEQMNK2HnyyYUb/lI/GfxlfesUHMz3EQeskqBPXhLrDPDIYZu5Q3+npLYaZGxeyarQImHrhwzVyUiHRnnRVL3sIiNXsdu7iHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326592; 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=O9LFx7bmrkJaI6Kk2QaXpZhH5Ca/LoygYTM5U9wxaBM=; b=i8QeQkwC1DieP7+qE+pxrA4zBOTpJQHQ9IRvCWX3Du5NopAkG6Vy2Yn+F2tAd6aM7kMfOxbg5NmI7HBeh/ulRJsT2K1oQrUF+l88OxWRwGfA8m05KXwYf0egrVPfdDPCKxGWlwKd0YKeonVYi2FKi1LVDiV0+vonTGYg11/KRiw= 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 1757326592473495.40510005592387; Mon, 8 Sep 2025 03:16:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsq-00025i-B7; Mon, 08 Sep 2025 06:14:00 -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 1uvYsd-0001vB-Jq for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:51 -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 1uvYsQ-00011R-Vm for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:45 -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-159-ywFpbve1OqCx1lE3z-x63Q-1; Mon, 08 Sep 2025 06:13:31 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45b9a856d58so33675085e9.0 for ; Mon, 08 Sep 2025 03:13:31 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d9f3c36a78sm25449632f8f.48.2025.09.08.03.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326412; 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=O9LFx7bmrkJaI6Kk2QaXpZhH5Ca/LoygYTM5U9wxaBM=; b=duLVoAADkfc9oVMRer8rhQLcM9H0xhHuyH7KdX2UNPrvI3c5NlSBXViEp7dBvMI0tQV6W5 e+OcotQzKGv8vvpYFQDrbnKjH1YkO6sm+owSdoYxQMl4YRxxubay6g75PMVRO5b9utX+M0 0aMZDoSRcNriMkM09VV5B7vxcTGJqHo= X-MC-Unique: ywFpbve1OqCx1lE3z-x63Q-1 X-Mimecast-MFC-AGG-ID: ywFpbve1OqCx1lE3z-x63Q_1757326410 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326409; x=1757931209; 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=O9LFx7bmrkJaI6Kk2QaXpZhH5Ca/LoygYTM5U9wxaBM=; b=C2BIBgv0so58ihAlZ7YU42Sdk+a+KdVtbWiFxto4OxJ9qmYP3rciEvuSpP4bHei7In vzicL9Q8OMIQom89JHjpaXyHyrar7THAxBwM0FB85v9/YJ1pwG/6NE4GQar6xfX8KMi3 Fa3HaTk3oW1xFu3ze1BrlLSMW/qGQ65EGJVggiz2nW/OGhgBRMhsHFEfToNv5vjPJ3QH sjFKTJxXcXqwtq39gdboAwTfFyk++WJvGgKO12QJivmYDlxX3r5CrUffZWO2xaWgGMa/ VU03TL3RK9OHynaH3Ge4DdQ1LvAJyUxf5va2gzvm1+zNhHAn1/5CDSa9u9gVZ+LtppVF l4IQ== X-Gm-Message-State: AOJu0YwPytmDbFD1r/hqDczCyq+dtRAbE5TbK47Ozi25SqY7DpCljLjd JqI3DudvHr9GR8rKQFN5d8AY5gpk4PFTtUlpyE+0E5+oHzx8Ac6K9kZd0buQNkydsaDTGsytY4F tRoVLcieOlommSAzIzgaQ+/lcSbT37D8phj2lFs7jwnc6n0Yn8UYMUdL4WpJCGpfzQSg9YiHBpv NqN/CHeudjCijCirR45XcRMchRFrpwZwn6p5iGO+OM X-Gm-Gg: ASbGnctOQQu/BBuy7PS0Zh/Pr2IVTwrdBHswBEObRsM2LjaKLfU+H7q8JLve+piOxas AoW/1BUCXPAhSO4UaI6sVT/P5x6Zi88LTkgrR4QI3dPwQdFTPwJ9z8S4U9bByeqnv/UJhSXcC2H i5aSIdr5JoLt6nOsXNDxjHmX7nMWH354B5emFAyTkh2oYEUH3uBvNgtqClGxUl265LURdule7kB LSOWgOL4YECYNWWd9BdqArET5rQhWolgN7GV2Zl2tp+r4W14u5/DHcj4/DuYJRwmZ+bdwrmA3ul XHzbCQDUTFr0ph4Gkqr2cB6Z12kI6OMe82fdEnRJvY892QUXldrwbQdV0LmfDyYbWQL46zgAWPI FTnMvQld2py0jRTY4sNYLc+wWGohDJN0Wu8mMwYPZ8Yk= X-Received: by 2002:a05:600c:b8a:b0:456:1c4a:82b2 with SMTP id 5b1f17b1804b1-45ddde82fa8mr59927715e9.10.1757326409379; Mon, 08 Sep 2025 03:13:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETAKVHTV0dmH2DpPyzn8mL0AdWaUtn4nDdigao+vAxMw1V3jtMTRkd+QHHLKIfyQeTsDWaJg== X-Received: by 2002:a05:600c:b8a:b0:456:1c4a:82b2 with SMTP id 5b1f17b1804b1-45ddde82fa8mr59927285e9.10.1757326408856; Mon, 08 Sep 2025 03:13:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH 18/19] accel: make all calls to qemu_process_cpu_events look the same Date: Mon, 8 Sep 2025 12:12:40 +0200 Message-ID: <20250908101241.2110068-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_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: 1757326594940116600 There is no reason for some accelerators to use qemu_process_cpu_events_com= mon (which is separated from qemu_process_cpu_events() specifically for round robin TCG). They can also check for events directly on the first pass thro= ugh the loop, instead of setting cpu->exit_request to true. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- 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 225a47c31fd..5752f6302c8 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_process_cpu_events(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_process_cpu_events(cpu); } while (!cpu->unplug); =20 bql_unlock(); diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 7a27bdadb4f..8b794c2d418 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_process_cpu_events(cpu); if (cpu_can_run(cpu)) { r =3D hvf_vcpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } - qemu_process_cpu_events(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 65a7f76a69a..8ed6945c2f7 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_process_cpu_events(cpu); + if (cpu_can_run(cpu)) { r =3D kvm_cpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } } - qemu_process_cpu_events(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 342917c5f6e..cf1ee7ac258 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_process_cpu_events(cpu); + if (cpu_can_run(cpu)) { int r; bql_unlock(); @@ -112,8 +111,6 @@ static void *mttcg_cpu_thread_fn(void *arg) break; } } - - qemu_process_cpu_events(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 7dbdba7b514..2fb46439971 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(); @@ -292,26 +309,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 d066364b989..dd5d5428b1c 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_process_cpu_events(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_process_cpu_events_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 2ca4ee02636..f75886128d0 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_process_cpu_events(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_process_cpu_events_common(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); =20 whpx_destroy_vcpu(cpu); --=20 2.51.0 From nobody Sun Sep 28 16:28:00 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=1757326572; cv=none; d=zohomail.com; s=zohoarc; b=FSZsL4YToSZ/YKsPwPuL5tztJCrhLdF8rgvlt7GMg/B2niCl6f7QPCTSAalmGioOTDpl2uktboJIgxWRTz93Zw19U4hD/XijX/IqCmTSjzg7QqpR3lXV52goc7048OostI3y6MBgziHeroyCiD7bbsdMnAdjtXoVDXAHFXaNLX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757326572; 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=0nuKa0pQnnRbuWROMsoY7tGerozDA9x5CjuoP23Xwkg=; b=NtgehkkDs7kfY8Nt9OX0RXQDuAzZlP00k52kaIxuGnBxm4Lj3rcGxVFIGO93d3jNWrXvb+m2x2dN5Ub12e3CNXgBtIyYvKbIQGW5Gcj1mMrrUPLrEzbyb6bAiwAOMuHX1EnxLa8X3R69cpizMW4JnmSPlQPI3DPMdxDvpN9Wv08= 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 1757326572091343.83234359331755; Mon, 8 Sep 2025 03:16:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uvYsq-00025q-AO; Mon, 08 Sep 2025 06:14:00 -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 1uvYsk-00022v-17 for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:55 -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 1uvYsa-00011y-OH for qemu-devel@nongnu.org; Mon, 08 Sep 2025 06:13:51 -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-349-pkc1EtrlPQK0liLb-UdwkQ-1; Mon, 08 Sep 2025 06:13:33 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3b9dc5c2ba0so2034822f8f.1 for ; Mon, 08 Sep 2025 03:13:33 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e748171834sm3967668f8f.5.2025.09.08.03.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Sep 2025 03:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757326415; 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=0nuKa0pQnnRbuWROMsoY7tGerozDA9x5CjuoP23Xwkg=; b=H8a7y+8RO8TEwiiBBuHJz/HjeblQ4BhDGP2pcRRQfFafb5zVYbj/JDCsDsiDubjsXJTAt3 6dUIBiPzSVhjGMUugqwz7elvgGIltUEOeV5bfd5s7UoRJ3LdWXCnqryZfLwNPw764AMX5J sCLN+OhjgpF86Fxc8zh4zxymdwl89iE= X-MC-Unique: pkc1EtrlPQK0liLb-UdwkQ-1 X-Mimecast-MFC-AGG-ID: pkc1EtrlPQK0liLb-UdwkQ_1757326413 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757326412; x=1757931212; 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=0nuKa0pQnnRbuWROMsoY7tGerozDA9x5CjuoP23Xwkg=; b=ijmDNY+7n/95AlqtHnUZ9QyyD+8bOf04cIB7zjIGKSWftXecbjzzmQRfIaG7j5xkoL IVQTWt27kMdcnKAlK3Kx2+Ys+61OO858q5Om8ua+4NIOv9NGj0fPLJjCt4LdUsphnBah Z/xxEwO08eMD92NUs2zXz/rshDMDxdK2XpJ9Wl/fvszTkq2UBdjZ4TtfSpV+Edr9ua/g ONqv5rZMdPwH3WPNimbKz/tk9sk6JAzfipDRWwIPb7cCEdN8+rwM4N3T/B+7ulEKE875 t7tbwgKKdYdtnJR5xjaDniyiHhjzkzFs8vmfdhhfTpMS7rDknlD8NxFOWEzEOFaZcEPN 0BEQ== X-Gm-Message-State: AOJu0YyY/QMxerg8USgyjQ/S65KKc/ZFKoAGZHI3+n5NDqen/YPtGXyq JdPzzwqB4fNYNXkjqYUd+REmLSkecQbmK9RRazMQYTTa3bnWCQxvV4NHSBVwE4ZnHDhWh+deXMN WMnVT+HdmDrTT4oWCdILK2DnRbLA2H0SWa5a/cCpNRMW+8/WmIFmwYE67ZC0Sofm/7eYOAwgOAM 3lqYtLjo1rVVYtPj1WCucaeYQt4GyXUsOtabll1XcO X-Gm-Gg: ASbGnctCSbGdoC28Dw8n9wkAl52L8seLB3Rm4N7K2drrC54IwStE8qHiaUtlXNm8rqd dYIwI0DbfZxAr/bPQyQ6+xev7gZmsWzAAsLZyxiTQw4MededRMzURSRenod+yG5fEiOaapCOr14 ZLS7ZtIxr8jgK/0ks4FK2E3POcxmHssoxr1iXGiJdYndQqeKMKSeqjZks9f3CeGFqQJYeHKH2iB HlfL82KTBcNcOwSj8pVkQ185x5EuQv8dHZ4R9SHflFuxeaE2iCZDwuviwDyVZT5h4X+xYhLePOA TUtWUVgOfzJ69EQrsyOtHmHEtG2dMNC5prohhx251woU5U/dqBggZ5KfQYl8ku3Onr4o65/uoUC /5yGH8lnbNf4kdCFpvKYxQGV7eDQ0eIXiUo60ZfaNZlY= X-Received: by 2002:a05:6000:2285:b0:3e7:4334:2afe with SMTP id ffacd0b85a97d-3e743342e6cmr4399706f8f.5.1757326411858; Mon, 08 Sep 2025 03:13:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm9IeoOJnq1GxSimtNLaafTKR2wFYYFuU5wLNExCZ92RuAwuojRAUeUShXld3eyRPwc7mQ8g== X-Received: by 2002:a05:6000:2285:b0:3e7:4334:2afe with SMTP id ffacd0b85a97d-3e743342e6cmr4399672f8f.5.1757326411372; Mon, 08 Sep 2025 03:13:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Igor Mammedov Subject: [PATCH 19/19] tcg/user: do not set exit_request gratuitously Date: Mon, 8 Sep 2025 12:12:41 +0200 Message-ID: <20250908101241.2110068-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908101241.2110068-1-pbonzini@redhat.com> References: <20250908101241.2110068-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: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, 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: 1757326573761124100 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. Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- 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