From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964309605647.2863296384282; Sat, 27 Sep 2025 02:11:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2QqQ-00041U-S1; Sat, 27 Sep 2025 05:03:56 -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 1v2QqJ-000415-Kx; Sat, 27 Sep 2025 05:03:48 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qps-0006nr-IR; Sat, 27 Sep 2025 05:03:45 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 19760158556; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id EBF8A291573; Sat, 27 Sep 2025 12:03:04 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, David Hubbard , Peter Maydell , Michael Tokarev Subject: [Stable-7.2.21 01/16] hw/usb/hcd-ohci: Fix #1510, #303: pid not IN or OUT Date: Sat, 27 Sep 2025 12:02:45 +0300 Message-ID: <20250927090304.2901324-1-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964310432116600 Content-Type: text/plain; charset="utf-8" From: David Hubbard This changes the ohci validation to not assert if invalid data is fed to the ohci controller. The poc in https://bugs.launchpad.net/qemu/+bug/1907042 and migrated to bug #303 does the following to feed it a SETUP pid (valid) at an EndPt of 1 (invalid - all SETUP pids must be addressed to EndPt 0): uint32_t MaxPacket =3D 64; uint32_t TDFormat =3D 0; uint32_t Skip =3D 0; uint32_t Speed =3D 0; uint32_t Direction =3D 0; /* #define OHCI_TD_DIR_SETUP 0 */ uint32_t EndPt =3D 1; uint32_t FuncAddress =3D 0; ed->attr =3D (MaxPacket << 16) | (TDFormat << 15) | (Skip << 14) | (Speed << 13) | (Direction << 11) | (EndPt << 7) | FuncAddress; ed->tailp =3D /*TDQTailPntr=3D */ 0; ed->headp =3D ((/*TDQHeadPntr=3D */ &td[0]) & 0xfffffff0) | (/* ToggleCarry=3D */ 0 << 1); ed->next_ed =3D (/* NextED=3D */ 0 & 0xfffffff0) qemu-fuzz also caught the same issue in #1510. They are both fixed by this patch. With a tiny OS[1] that boots and executes the poc the repro shows the issue: * OS that sends USB requests to a USB mass storage device but sends a SETUP with EndPt =3D 1 * qemu 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.19) * qemu HEAD (4e66a0854) * Actual OHCI controller (hardware) Command line: qemu-system-x86_64 -m 20 \ -device pci-ohci,id=3Dohci \ -drive if=3Dnone,format=3Draw,id=3Dd,file=3Dtestmbr.raw \ -device usb-storage,bus=3Dohci.0,drive=3Dd \ --trace "usb_*" --trace "ohci_*" -D qemu.log Results are: qemu 6.2.0 | qemu HEAD | actual HW Reviewed-by: Peter Maydell ------------+-----------+---------------- assertion | assertion | sets stall bit The assertion message is: > qemu-system-x86_64: ../../hw/usb/core.c:744: usb_ep_get: Assertion `pid = =3D=3D USB_TOKEN_IN || pid =3D=3D USB_TOKEN_OUT' failed. > Aborted (core dumped) Tip: if the flags "-serial pty -serial stdio" are added to the command line the poc outputs its USB requests like this: > Free mem 2M ohci port0 conn FS > setup { 80 6 0 1 0 0 8 0 } > ED info=3D80000 { mps=3D8 en=3D0 d=3D0 } tail=3Dc20920 > td0 c20880 nxt=3Dc20960 f2000000 setup cbp=3Dc20900 be=3Dc20907 c= bp=3D0 be=3Dc20907 > td1 c20960 nxt=3Dc20980 f3140000 in cbp=3Dc20908 be=3Dc2090f c= bp=3D0 be=3Dc2090f > td2 c20980 nxt=3Dc20920 f3080000 out cbp=3D0 be=3D0 c= bp=3D0 be=3D0 > rx { 12 1 0 2 0 0 0 8 } > setup { 0 5 1 0 0 0 0 0 } tx {} > ED info=3D80000 { mps=3D8 en=3D0 d=3D0 } tail=3Dc20880 > td0 c20920 nxt=3Dc20960 f2000000 setup cbp=3Dc20900 be=3Dc20907 c= bp=3D0 be=3Dc20907 > td1 c20960 nxt=3Dc20880 f3100000 in cbp=3D0 be=3D0 c= bp=3D0 be=3D0 > setup { 80 6 0 1 0 0 12 0 } > ED info=3D80081 { mps=3D8 en=3D0 d=3D1 } tail=3Dc20960 > td0 c20880 nxt=3Dc209c0 f2000000 setup cbp=3Dc20920 be=3Dc20927 > td1 c209c0 nxt=3Dc209e0 f3140000 in cbp=3Dc20928 be=3Dc20939 > td2 c209e0 nxt=3Dc20960 f3080000 out cbp=3D0 be=3D0qemu-system-x86_64= : ../../hw/usb/core.c:744: usb_ep_get: Assertion `pid =3D=3D USB_TOKEN_IN |= | pid =3D=3D USB_TOKEN_OUT' failed. > Aborted (core dumped) [1] The OS disk image has been emailed to philmd@linaro.org, mjt@tls.msk.ru, and kraxel@redhat.com: * testBadSetup.img.xz * sha256: 045b43f4396de02b149518358bf8025d5ba11091e86458875339fc649e6e5ac6 Signed-off-by: David Hubbard Reviewed-by: Peter Maydell [PMM: authorship and signed-off-by tag names fixed up as per on-list agreement] Signed-off-by: Peter Maydell (cherry picked from commit 3c3c233677d4f2fe5f35c5d6d6e9b53df48054f4) Signed-off-by: Michael Tokarev diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index c3ab762f54..0ec786dd6a 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -904,6 +904,11 @@ static int ohci_service_td(OHCIState *ohci, struct ohc= i_ed *ed) case OHCI_TD_DIR_SETUP: str =3D "setup"; pid =3D USB_TOKEN_SETUP; + if (OHCI_BM(ed->flags, ED_EN) > 0) { /* setup only allowed to ep = 0 */ + trace_usb_ohci_td_bad_pid(str, ed->flags, td.flags); + ohci_die(ohci); + return 1; + } break; default: trace_usb_ohci_td_bad_direction(dir); diff --git a/hw/usb/trace-events b/hw/usb/trace-events index b65269892c..743308c75d 100644 --- a/hw/usb/trace-events +++ b/hw/usb/trace-events @@ -28,6 +28,7 @@ usb_ohci_iso_td_data_overrun(int ret, ssize_t len) "DataO= verrun %d > %zu" usb_ohci_iso_td_data_underrun(int ret) "DataUnderrun %d" usb_ohci_iso_td_nak(int ret) "got NAK/STALL %d" usb_ohci_iso_td_bad_response(int ret) "Bad device response %d" +usb_ohci_td_bad_pid(const char *s, uint32_t edf, uint32_t tdf) "Bad pid %s= : ed.flags 0x%x td.flags 0x%x" usb_ohci_port_attach(int index) "port #%d" usb_ohci_port_detach(int index) "port #%d" usb_ohci_port_wakeup(int index) "port #%d" --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175896395033846.20711856761068; Sat, 27 Sep 2025 02:05:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qqh-00044o-Dj; Sat, 27 Sep 2025 05:04:11 -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 1v2QqX-00042n-Bk; Sat, 27 Sep 2025 05:04:02 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2QqN-0006pz-Iy; Sat, 27 Sep 2025 05:04:01 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 2E9AA158557; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 0B02B291574; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.21 02/16] .gitmodules: move u-boot mirrors to qemu-project-mirrors Date: Sat, 27 Sep 2025 12:02:46 +0300 Message-ID: <20250927090304.2901324-2-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZM-MESSAGEID: 1758963953446116600 From: Alex Benn=C3=A9e To continue our GitLab Open Source Program license we need to pass an automated license check for all repos under qemu-project. While U-Boot is clearly GPLv2 rather than fight with the automated validation script just move the mirror across to a separate project. Signed-off-by: Alex Benn=C3=A9e Suggested-by: Daniel P. Berrang=C3=A9 Cc: qemu-stable@nongnu.org Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Richard Henderson Message-ID: <20250908141911.2546063-1-alex.bennee@linaro.org> Signed-off-by: Richard Henderson (cherry picked from commit a11d1847d5ef8a7db58e6d4e44f36fec708f0981) (Mjt: adjust context for 7.2.x) Signed-off-by: Michael Tokarev diff --git a/.gitmodules b/.gitmodules index 24cffa87d4..570d895aa1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -21,7 +21,7 @@ url =3D https://gitlab.com/qemu-project/dtc.git [submodule "roms/u-boot"] path =3D roms/u-boot - url =3D https://gitlab.com/qemu-project/u-boot.git + url =3D https://gitlab.com/qemu-project-mirrors/u-boot.git [submodule "roms/skiboot"] path =3D roms/skiboot url =3D https://gitlab.com/qemu-project/skiboot.git @@ -36,7 +36,7 @@ url =3D https://gitlab.com/qemu-project/seabios-hppa.git [submodule "roms/u-boot-sam460ex"] path =3D roms/u-boot-sam460ex - url =3D https://gitlab.com/qemu-project/u-boot-sam460ex.git + url =3D https://gitlab.com/qemu-project-mirrors/u-boot-sam460ex.git [submodule "tests/fp/berkeley-testfloat-3"] path =3D tests/fp/berkeley-testfloat-3 url =3D https://gitlab.com/qemu-project/berkeley-testfloat-3.git --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758963938760436.62655752116575; Sat, 27 Sep 2025 02:05:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qqk-000453-Fg; Sat, 27 Sep 2025 05:04:14 -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 1v2Qqe-00043S-AF; Sat, 27 Sep 2025 05:04:08 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2QqR-0006qB-Ja; Sat, 27 Sep 2025 05:04:07 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 4A095158558; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 1ECBC291575; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Paolo Bonzini , Thomas Huth , Michael Tokarev Subject: [Stable-7.2.21 03/16] tests: vhost-user-test: release mutex on protocol violation Date: Sat, 27 Sep 2025 12:02:47 +0300 Message-ID: <20250927090304.2901324-3-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZM-MESSAGEID: 1758963941216116600 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini chr_read() is printing an error message and returning with s->data_mutex ta= ken. This can potentially cause a hang. Reported by Coverity. Signed-off-by: Paolo Bonzini Message-Id: <20230427125423.103536-1-pbonzini@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth (cherry picked from commit 3ee7f21ed292966f5cd3eb71aa06f8ffc0e5ae41) (Mjt: pick this trivial focused change up for 7.2.x so that subsequent fixe= s in this area applies cleanly) Signed-off-by: Michael Tokarev diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index bf9f7c4248..e4f95b2858 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -351,7 +351,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) if (size !=3D msg.size) { qos_printf("%s: Wrong message size received %d !=3D %d\n", __func__, size, msg.size); - return; + goto out; } } =20 @@ -509,6 +509,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) break; } =20 +out: g_mutex_unlock(&s->data_mutex); } =20 --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758963939932776.116089949965; Sat, 27 Sep 2025 02:05:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qqo-00045z-OV; Sat, 27 Sep 2025 05:04:19 -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 1v2Qqi-000454-V5; Sat, 27 Sep 2025 05:04:12 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qqe-0006rO-EV; Sat, 27 Sep 2025 05:04:12 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 5BE05158559; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 3AC8E291576; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Yuxue Liu , "Michael S. Tsirkin" , Michael Tokarev Subject: [Stable-7.2.21 04/16] vhost-user-test: no set non-blocking for cal fd less than 0. Date: Sat, 27 Sep 2025 12:02:48 +0300 Message-ID: <20250927090304.2901324-4-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758963941293116600 Content-Type: text/plain; charset="utf-8" From: Yuxue Liu In the scenario where vhost-user sets eventfd to -1, qemu_chr_fe_get_msgfds retrieves fd as -1. When vhost_user_read receives, it does not perform blocking operations on the descriptor with fd=3D-1, so non-blocking operations should not be performed here either.This is a normal use case. Calling g_unix_set_fd_nonblocking at this point will cause the test to interrupt. When vhost_user_write sets the call fd to -1, it sets the number of fds to 0, so the fds obtained by qemu_chr_fe_get_msgfds will also be 0. Signed-off-by: Yuxue Liu Message-Id: <20240411073555.1357-1-yuxue.liu@jaguarmicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit f72fc16910c8f44edf052f52672e0e63bbbc773c) (Mjt: pick this trivial focused change up for 7.2.x so that subsequent chan= ge(s) in this area apply cleanly) Signed-off-by: Michael Tokarev diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index e4f95b2858..6d9e53ff07 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -456,7 +456,10 @@ static void chr_read(void *opaque, const uint8_t *buf,= int size) case VHOST_USER_SET_VRING_KICK: case VHOST_USER_SET_VRING_CALL: /* consume the fd */ - qemu_chr_fe_get_msgfds(chr, &fd, 1); + if (!qemu_chr_fe_get_msgfds(chr, &fd, 1) && fd < 0) { + qos_printf("call fd: %d, do not set non-blocking\n", fd); + break; + } /* * This is a non-blocking eventfd. * The receive function forces it to be blocking, --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964302768214.9399657569894; Sat, 27 Sep 2025 02:11:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qr2-00047z-2D; Sat, 27 Sep 2025 05:04:32 -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 1v2Qqy-000479-AE; Sat, 27 Sep 2025 05:04:28 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qql-0006sS-03; Sat, 27 Sep 2025 05:04:27 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 6BDD415855A; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 4C751291577; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Markus Armbruster , Michael Tokarev Subject: [Stable-7.2.21 05/16] Revert "tests/qtest: use qos_printf instead of g_test_message" Date: Sat, 27 Sep 2025 12:02:49 +0300 Message-ID: <20250927090304.2901324-5-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964304465116600 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster This reverts commit 30ea13e9d97dcbd4ea541ddf9e8857fa1d5cb30f. Also rewrites qos_printf() calls added later. "make check" prints many lines like stdout: 138: UNKNOWN: # # qos_test running single test in subprocess stdout: 139: UNKNOWN: # # set_protocol_features: 0x42 stdout: 140: UNKNOWN: # # set_owner: start of session stdout: 141: UNKNOWN: # # vhost-user: un-handled message: 14 stdout: 142: UNKNOWN: # # vhost-user: un-handled message: 14 stdout: 143: UNKNOWN: # # set_vring(0)=3Denabled stdout: 144: UNKNOWN: # # set_vring(1)=3Denabled stdout: 145: UNKNOWN: # # set_vring(0)=3Denabled stdout: 146: UNKNOWN: # # set_vring(1)=3Denabled stdout: 147: UNKNOWN: # # set_vring(0)=3Denabled stdout: 148: UNKNOWN: # # set_vring(1)=3Denabled stdout: 149: UNKNOWN: # # set_vring(0)=3Denabled stdout: 150: UNKNOWN: # # set_vring(1)=3Denabled stdout: 151: UNKNOWN: # # set_vring(0)=3Denabled stdout: 152: UNKNOWN: # # set_vring(1)=3Denabled stdout: 153: UNKNOWN: # # set_vring_num: 0/256 stdout: 154: UNKNOWN: # # set_vring_addr: 0x7f9060000000/0x7f905fff= f000/0x7f9060001000 Turns out this is qos-test, and the culprit is a commit meant to ease debugging. Revert it until a better solution is found. Signed-off-by: Markus Armbruster Message-ID: <20250728145747.3165315-1-armbru@redhat.com> [Commit message clarified] (cherry picked from commit c9a1ea9c52e6462ad5c7814f3abd65baa69dc4ce) Signed-off-by: Michael Tokarev diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 5da4091ec3..566cb3b00b 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -321,11 +321,6 @@ static void walk_path(QOSGraphNode *orig_path, int len) int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); - - if (g_test_subprocess()) { - qos_printf("qos_test running single test in subprocess\n"); - } - if (g_test_verbose()) { qos_printf("ENVIRONMENT VARIABLES: {\n"); for (char **env =3D envp; *env !=3D 0; env++) { diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 6d9e53ff07..9bfd7f7217 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -26,7 +26,6 @@ #include "libqos/virtio-pci.h" =20 #include "libqos/malloc-pc.h" -#include "libqos/qgraph_internal.h" #include "hw/virtio/virtio-net.h" =20 #include "standard-headers/linux/vhost_types.h" @@ -338,7 +337,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) } =20 if (size !=3D VHOST_USER_HDR_SIZE) { - qos_printf("%s: Wrong message size received %d\n", __func__, size); + g_test_message("Wrong message size received %d", size); return; } =20 @@ -349,8 +348,8 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) p +=3D VHOST_USER_HDR_SIZE; size =3D qemu_chr_fe_read_all(chr, p, msg.size); if (size !=3D msg.size) { - qos_printf("%s: Wrong message size received %d !=3D %d\n", - __func__, size, msg.size); + g_test_message("Wrong message size received %d !=3D %d", + size, msg.size); goto out; } } @@ -386,7 +385,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) * We don't need to do anything here, the remote is just * letting us know it is in charge. Just log it. */ - qos_printf("set_owner: start of session\n"); + g_test_message("set_owner: start of session\n"); break; =20 case VHOST_USER_GET_PROTOCOL_FEATURES: @@ -412,7 +411,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) * the remote end to send this. There is no handshake reply so * just log the details for debugging. */ - qos_printf("set_protocol_features: 0x%"PRIx64 "\n", msg.payload.u6= 4); + g_test_message("set_protocol_features: 0x%"PRIx64 "\n", msg.payloa= d.u64); break; =20 /* @@ -420,11 +419,11 @@ static void chr_read(void *opaque, const uint8_t *buf= , int size) * address of the vrings but we can simply report them. */ case VHOST_USER_SET_VRING_NUM: - qos_printf("set_vring_num: %d/%d\n", + g_test_message("set_vring_num: %d/%d\n", msg.payload.state.index, msg.payload.state.num); break; case VHOST_USER_SET_VRING_ADDR: - qos_printf("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64"\n", + g_test_message("set_vring_addr: 0x%"PRIx64"/0x%"PRIx64"/0x%"PRIx64= "\n", msg.payload.addr.avail_user_addr, msg.payload.addr.desc_user_addr, msg.payload.addr.used_user_addr); @@ -457,7 +456,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) case VHOST_USER_SET_VRING_CALL: /* consume the fd */ if (!qemu_chr_fe_get_msgfds(chr, &fd, 1) && fd < 0) { - qos_printf("call fd: %d, do not set non-blocking\n", fd); + g_test_message("call fd: %d, do not set non-blocking\n", fd); break; } /* @@ -503,12 +502,12 @@ static void chr_read(void *opaque, const uint8_t *buf= , int size) * fully functioning vhost-user we would enable/disable the * vring monitoring. */ - qos_printf("set_vring(%d)=3D%s\n", msg.payload.state.index, + g_test_message("set_vring(%d)=3D%s\n", msg.payload.state.index, msg.payload.state.num ? "enabled" : "disabled"); break; =20 default: - qos_printf("vhost-user: un-handled message: %d\n", msg.request); + g_test_message("vhost-user: un-handled message: %d\n", msg.request= ); break; } =20 @@ -532,7 +531,7 @@ static const char *init_hugepagefs(void) } =20 if (access(path, R_OK | W_OK | X_OK)) { - qos_printf("access on path (%s): %s", path, strerror(errno)); + g_test_message("access on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } @@ -542,13 +541,13 @@ static const char *init_hugepagefs(void) } while (ret !=3D 0 && errno =3D=3D EINTR); =20 if (ret !=3D 0) { - qos_printf("statfs on path (%s): %s", path, strerror(errno)); + g_test_message("statfs on path (%s): %s", path, strerror(errno)); g_test_fail(); return NULL; } =20 if (fs.f_type !=3D HUGETLBFS_MAGIC) { - qos_printf("Warning: path not on HugeTLBFS: %s", path); + g_test_message("Warning: path not on HugeTLBFS: %s", path); g_test_fail(); return NULL; } --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964176319836.4930657864941; Sat, 27 Sep 2025 02:09:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qqv-00046Z-73; Sat, 27 Sep 2025 05:04: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 1v2Qqu-00046L-8e; Sat, 27 Sep 2025 05:04:24 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qqp-0006t5-3s; Sat, 27 Sep 2025 05:04:24 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 868FD15855B; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 5C24A291578; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Fabiano Rosas , Thomas Huth , Michael Tokarev Subject: [Stable-7.2.21 06/16] tests/qtest: Do not run lsi53c895a test if device is not present Date: Sat, 27 Sep 2025 12:02:50 +0300 Message-ID: <20250927090304.2901324-6-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964177067116600 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas The tests are built once for all the targets, so as long as one QEMU binary is built with CONFIG_LSI_SCSI_PCI=3Dy, this test will run. However some binaries might not include the device. So check this again in runtime. Signed-off-by: Fabiano Rosas Message-Id: <20230208194700.11035-3-farosas@suse.de> Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth (cherry picked from commit dee66bc9691a0d5e8337c24b5cf303f46293df76) (Mjt: pick this trivial focused fix up for 7.2.x so that subsequent change(= s) in this area apply cleanly) Signed-off-by: Michael Tokarev diff --git a/tests/qtest/fuzz-lsi53c895a-test.c b/tests/qtest/fuzz-lsi53c89= 5a-test.c index 9b007def26..8afbfdd274 100644 --- a/tests/qtest/fuzz-lsi53c895a-test.c +++ b/tests/qtest/fuzz-lsi53c895a-test.c @@ -142,6 +142,10 @@ static void test_lsi_do_dma_empty_queue(void) =20 int main(int argc, char **argv) { + if (!qtest_has_device("lsi53c895a")) { + return 0; + } + g_test_init(&argc, &argv, NULL); =20 qtest_add_func("fuzz/lsi53c895a/lsi_do_dma_empty_queue", --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758963938924308.92836264823256; Sat, 27 Sep 2025 02:05:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2QrF-0004Df-LX; Sat, 27 Sep 2025 05:04:45 -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 1v2QrC-0004Bz-Sl; Sat, 27 Sep 2025 05:04:42 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qr0-0006us-M3; Sat, 27 Sep 2025 05:04:41 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 9E9FF15855C; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 76A59291579; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, "Richard W.M. Jones" , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexander Bulekov , Darren Kenny , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Michael Tokarev Subject: [Stable-7.2.21 07/16] tests: Ensure TAP version is printed before other messages Date: Sat, 27 Sep 2025 12:02:51 +0300 Message-ID: <20250927090304.2901324-7-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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-ZM-MESSAGEID: 1758963941247116600 From: "Richard W.M. Jones" These two tests were failing with this error: stderr: TAP parsing error: version number must be on the first line [...] Unknown TAP version. The first line MUST be `TAP version `. Assuming= version 12. This can be fixed by ensuring we always call g_test_init first in the body of main. Thanks: Daniel Berrange, for diagnosing the problem Signed-off-by: Richard W.M. Jones Reviewed-by: Daniel P. Berrang=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-Id: <20230227174019.1164205-1-rjones@redhat.com> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Thomas Huth Message-Id: <20230228190653.1602033-17-alex.bennee@linaro.org> (cherry picked from commit ae4b01b3497934849278b49f3dfd28420f75e300) (Mjt: this fixes rtl3129 testing failure on 7.2.x) Signed-off-by: Michael Tokarev diff --git a/tests/qtest/fuzz-lsi53c895a-test.c b/tests/qtest/fuzz-lsi53c89= 5a-test.c index 8afbfdd274..1b55928b9f 100644 --- a/tests/qtest/fuzz-lsi53c895a-test.c +++ b/tests/qtest/fuzz-lsi53c895a-test.c @@ -142,12 +142,12 @@ static void test_lsi_do_dma_empty_queue(void) =20 int main(int argc, char **argv) { + g_test_init(&argc, &argv, NULL); + if (!qtest_has_device("lsi53c895a")) { return 0; } =20 - g_test_init(&argc, &argv, NULL); - qtest_add_func("fuzz/lsi53c895a/lsi_do_dma_empty_queue", test_lsi_do_dma_empty_queue); =20 diff --git a/tests/qtest/rtl8139-test.c b/tests/qtest/rtl8139-test.c index 8fa3313cc3..90bb616974 100644 --- a/tests/qtest/rtl8139-test.c +++ b/tests/qtest/rtl8139-test.c @@ -196,9 +196,10 @@ int main(int argc, char **argv) { int ret; =20 + g_test_init(&argc, &argv, NULL); + qtest_start("-device rtl8139"); =20 - g_test_init(&argc, &argv, NULL); qtest_add_func("/rtl8139/nop", nop); qtest_add_func("/rtl8139/timer", test_init); =20 --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964300263601.6293731804637; Sat, 27 Sep 2025 02:11:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2QrI-0004EQ-4H; Sat, 27 Sep 2025 05:04: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 1v2QrD-0004Be-Al; Sat, 27 Sep 2025 05:04:43 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qr1-0006vB-HB; Sat, 27 Sep 2025 05:04:40 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id AE9BF15855D; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 8DC1E29157A; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?St=C3=A9phane=20Graber?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Peter Maydell , Michael Tokarev Subject: [Stable-7.2.21 08/16] hw/usb/network: Remove hardcoded 0x40 prefix in STRING_ETHADDR response Date: Sat, 27 Sep 2025 12:02:52 +0300 Message-ID: <20250927090304.2901324-8-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964302320116600 From: St=C3=A9phane Graber USB NICs have a "40:" prefix hardcoded for all MAC addresses when we return the guest the MAC address if it queries the STRING_ETHADDR USB string property. This doesn't match what we use for the OID_802_3_PERMANENT_ADDRESS or OID_802_3_CURRENT_ADDRESS OIDs for NDIS, or the MAC address we actually use in the QEMU networking code to send/receive packets for this device, or the NIC info string we print for users. In all those other places we directly use s->conf.macaddr.a, which is the full thing the user asks for. This overrides user-provided configuration and leads to an inconsistent experience. I couldn't find any documented reason (comment or git commits) for this behavior. It seems like everyone is just expecting the MAC address to be fully passed through to the guest, but it isn't. This may have been a debugging hack that accidentally made it through to the accepted patch: it has been in the code since it was originally added back in 2008. This is also particularly problematic as the "40:" prefix isn't a reserved prefix for MAC addresses (IEEE OUI). There are a number of valid allocations out there which use this prefix, meaning that QEMU may be causing MAC address conflicts. Cc: qemu-stable@nongnu.org Fixes: 6c9f886ceae5b ("Add CDC-Ethernet usb NIC (original patch from Thomas= Sailer)" Signed-off-by: St=C3=A9phane Graber Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2951 Reviewed-by: Daniel P. Berrang=C3=A9 [PMM: beef up commit message based on mailing list discussion] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit aaf042299acf83919862c7d7dd5fc36acf4e0671) Signed-off-by: Michael Tokarev diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 2c33e36cad..1b6004c902 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1391,7 +1391,7 @@ static void usb_net_realize(USBDevice *dev, Error **e= rrp) qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); snprintf(s->usbstring_mac, sizeof(s->usbstring_mac), "%02x%02x%02x%02x%02x%02x", - 0x40, + s->conf.macaddr.a[0], s->conf.macaddr.a[1], s->conf.macaddr.a[2], s->conf.macaddr.a[3], --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964200721268.4217541883304; Sat, 27 Sep 2025 02:10:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2QrV-0004Jz-QI; Sat, 27 Sep 2025 05:05:02 -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 1v2QrU-0004IL-8X; Sat, 27 Sep 2025 05:05:00 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2QrJ-0006vx-5P; Sat, 27 Sep 2025 05:04:57 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id C8E2315855E; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 9E6D529157B; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Michael Tokarev , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [Stable-7.2.21 09/16] use fedora:37 for python container instead of :latest Date: Sat, 27 Sep 2025 12:02:53 +0300 Message-ID: <20250927090304.2901324-9-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964201285116600 More recent fedora does not have our minimum python versions anymore. Stick with the most common fedora version used in 7.2.x in other places, which is 37. This way, python tests works again. This is a 7.2-specific change, not aimed for the master branch. Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Michael Tokarev diff --git a/tests/docker/dockerfiles/python.docker b/tests/docker/dockerfi= les/python.docker index 175c10a34e..8cc5d3567e 100644 --- a/tests/docker/dockerfiles/python.docker +++ b/tests/docker/dockerfiles/python.docker @@ -1,6 +1,6 @@ # Python library testing environment =20 -FROM fedora:latest +FROM fedora:37 MAINTAINER John Snow =20 # Please keep this list sorted alphabetically --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964361648457.6398707032573; Sat, 27 Sep 2025 02:12:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qra-0004Mw-VC; Sat, 27 Sep 2025 05:05:07 -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 1v2QrZ-0004Kz-EQ; Sat, 27 Sep 2025 05:05:05 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2QrJ-0006w2-J3; Sat, 27 Sep 2025 05:05:03 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id DD86415855F; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id B9B3529157C; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Delevoryas , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Michael Tokarev Subject: [Stable-7.2.21 10/16] python/machine: Fix AF_UNIX path too long on macOS Date: Sat, 27 Sep 2025 12:02:54 +0300 Message-ID: <20250927090304.2901324-10-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964362927116600 From: Peter Delevoryas On macOS, private $TMPDIR's are the default. These $TMPDIR's are generated from a user's unix UID and UUID [1], which can create a relatively long path: /var/folders/d7/rz20f6hd709c1ty8f6_6y_z40000gn/T/ QEMU's avocado tests create a temporary directory prefixed by "avo_qemu_sock_", and create QMP sockets within _that_ as well. The QMP socket is unnecessarily long, because a temporary directory is created for every QEMUMachine object. /avo_qemu_sock_uh3w_dgc/qemu-37331-10bacf110-monitor.sock The path limit for unix sockets on macOS is 104: [2] /* * [XSI] Definitions for UNIX IPC domain. */ struct sockaddr_un { unsigned char sun_len; /* sockaddr len including null */ sa_family_t sun_family; /* [XSI] AF_UNIX */ char sun_path[104]; /* [XSI] path name (gag) */ }; This results in avocado tests failing on macOS because the QMP unix socket can't be created, because the path is too long: ERROR| Failed to establish connection: OSError: AF_UNIX path too long This change resolves by reducing the size of the socket directory prefix and the suffix on the QMP and console socket names. The result is paths like this: pdel@pdel-mbp:/var/folders/d7/rz20f6hd709c1ty8f6_6y_z40000gn/T $ tree qemu* qemu_df4evjeq qemu_jbxel3gy qemu_ml9s_gg7 qemu_oc7h7f3u qemu_oqb1yf97 =E2=94=9C=E2=94=80=E2=94=80 10a004050.con =E2=94=94=E2=94=80=E2=94=80 10a004050.qmp [1] https://apple.stackexchange.com/questions/353832/why-is-mac-osx-temp-di= rectory-in-weird-path [2] /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/sys= /un.h Signed-off-by: Peter Delevoryas Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20230110082930.42129-2-peter@pjd.dev Signed-off-by: John Snow (cherry picked from commit f9922937d173f50fe59fd1b20fadc445fb6b2564) (Mjt: pick this simple fix for 7.2.x so subsequent changes applies cleanly) Signed-off-by: Michael Tokarev diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 37191f433b..5df210c810 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -157,7 +157,7 @@ def __init__(self, self._wrapper =3D wrapper self._qmp_timer =3D qmp_timer =20 - self._name =3D name or f"qemu-{os.getpid()}-{id(self):02x}" + self._name =3D name or f"{id(self):x}" self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir self._sock_dir =3D sock_dir @@ -167,7 +167,7 @@ def __init__(self, self._monitor_address =3D monitor_address else: self._monitor_address =3D os.path.join( - self.sock_dir, f"{self._name}-monitor.sock" + self.sock_dir, f"{self._name}.qmp" ) =20 self._console_log_path =3D console_log @@ -192,7 +192,7 @@ def __init__(self, self._console_set =3D False self._console_device_type: Optional[str] =3D None self._console_address =3D os.path.join( - self.sock_dir, f"{self._name}-console.sock" + self.sock_dir, f"{self._name}.con" ) self._console_socket: Optional[socket.socket] =3D None self._remove_files: List[str] =3D [] diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado= _qemu/__init__.py index 910f3ba1ea..25a546842f 100644 --- a/tests/avocado/avocado_qemu/__init__.py +++ b/tests/avocado/avocado_qemu/__init__.py @@ -306,7 +306,7 @@ def require_netdev(self, netdevname): self.cancel('no support for user networking') =20 def _new_vm(self, name, *args): - self._sd =3D tempfile.TemporaryDirectory(prefix=3D"avo_qemu_sock_") + self._sd =3D tempfile.TemporaryDirectory(prefix=3D"qemu_") vm =3D QEMUMachine(self.qemu_bin, base_temp_dir=3Dself.workdir, sock_dir=3Dself._sd.name, log_dir=3Dself.logdir) self.log.debug('QEMUMachine "%s" created', name) --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964053741237.21735528400984; Sat, 27 Sep 2025 02:07:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qrl-0004RX-27; Sat, 27 Sep 2025 05:05: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 1v2Qrk-0004RK-0r; Sat, 27 Sep 2025 05:05:16 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2QrZ-0006x2-9u; Sat, 27 Sep 2025 05:05:14 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id F01F5158560; Sat, 27 Sep 2025 12:03:02 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id CDFFC29157D; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Michael Tokarev Subject: [Stable-7.2.21 11/16] python/qmp/protocol: add open_with_socket() Date: Sat, 27 Sep 2025 12:02:55 +0300 Message-ID: <20250927090304.2901324-11-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964055763116600 From: Marc-Andr=C3=A9 Lureau Instead of listening for incoming connections with a SocketAddr, add a new method open_with_socket() that accepts an existing socket. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20230111080101.969151-2-marcandre.lureau@redhat.com Signed-off-by: John Snow (cherry picked from commit a3cfea92e2030926e00a2519d299384ea648e36e) Signed-off-by: Michael Tokarev diff --git a/python/qemu/qmp/protocol.py b/python/qemu/qmp/protocol.py index 6ea86650ad..4710a57f91 100644 --- a/python/qemu/qmp/protocol.py +++ b/python/qemu/qmp/protocol.py @@ -18,6 +18,7 @@ from enum import Enum from functools import wraps import logging +import socket from ssl import SSLContext from typing import ( Any, @@ -296,6 +297,19 @@ async def start_server_and_accept( await self.accept() assert self.runstate =3D=3D Runstate.RUNNING =20 + @upper_half + @require(Runstate.IDLE) + async def open_with_socket(self, sock: socket.socket) -> None: + """ + Start connection with given socket. + + :param sock: A socket. + + :raise StateError: When the `Runstate` is not `IDLE`. + """ + self._reader, self._writer =3D await asyncio.open_connection(sock= =3Dsock) + self._set_state(Runstate.CONNECTING) + @upper_half @require(Runstate.IDLE) async def start_server(self, address: SocketAddrT, @@ -343,11 +357,12 @@ async def accept(self) -> None: protocol-level failure occurs while establishing a new session, the wrapped error may also be an `QMPError`. """ - if self._accepted is None: - raise QMPError("Cannot call accept() before start_server().") - await self._session_guard( - self._do_accept(), - 'Failed to establish connection') + if not self._reader: + if self._accepted is None: + raise QMPError("Cannot call accept() before start_server()= .") + await self._session_guard( + self._do_accept(), + 'Failed to establish connection') await self._session_guard( self._establish_session(), 'Failed to establish session') --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964048761604.0227373305644; Sat, 27 Sep 2025 02:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qrh-0004Qf-Cj; Sat, 27 Sep 2025 05:05:14 -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 1v2Qrf-0004QJ-Nt; Sat, 27 Sep 2025 05:05:11 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qrd-00077m-A8; Sat, 27 Sep 2025 05:05:11 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0E109158561; Sat, 27 Sep 2025 12:03:03 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id E010D29157E; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Michael Tokarev Subject: [Stable-7.2.21 12/16] python/qmp/legacy: make QEMUMonitorProtocol accept a socket Date: Sat, 27 Sep 2025 12:02:56 +0300 Message-ID: <20250927090304.2901324-12-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964049662116600 From: Marc-Andr=C3=A9 Lureau Teach QEMUMonitorProtocol to accept an exisiting socket. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20230111080101.969151-3-marcandre.lureau@redhat.com Signed-off-by: John Snow (cherry picked from commit 603a3bad4b9a95b524dc8d6a41b1be4d5c5cacdf) Signed-off-by: Michael Tokarev diff --git a/python/qemu/qmp/legacy.py b/python/qemu/qmp/legacy.py index 1951754455..8b09ee7dbb 100644 --- a/python/qemu/qmp/legacy.py +++ b/python/qemu/qmp/legacy.py @@ -22,6 +22,7 @@ # =20 import asyncio +import socket from types import TracebackType from typing import ( Any, @@ -69,22 +70,32 @@ class QEMUMonitorProtocol: =20 :param address: QEMU address, can be either a unix socket path (strin= g) or a tuple in the form ( address, port ) for a TCP - connection + connection or None + :param sock: a socket or None :param server: Act as the socket server. (See 'accept') :param nickname: Optional nickname used for logging. """ =20 - def __init__(self, address: SocketAddrT, + def __init__(self, + address: Optional[SocketAddrT] =3D None, + sock: Optional[socket.socket] =3D None, server: bool =3D False, nickname: Optional[str] =3D None): =20 + assert address or sock self._qmp =3D QMPClient(nickname) self._aloop =3D asyncio.get_event_loop() self._address =3D address + self._sock =3D sock self._timeout: Optional[float] =3D None =20 if server: - self._sync(self._qmp.start_server(self._address)) + if sock: + assert self._sock is not None + self._sync(self._qmp.open_with_socket(self._sock)) + else: + assert self._address is not None + self._sync(self._qmp.start_server(self._address)) =20 _T =3D TypeVar('_T') =20 @@ -139,6 +150,7 @@ def connect(self, negotiate: bool =3D True) -> Optional= [QMPMessage]: :return: QMP greeting dict, or None if negotiate is false :raise ConnectError: on connection errors """ + assert self._address is not None self._qmp.await_greeting =3D negotiate self._qmp.negotiate =3D negotiate =20 --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964263265372.6894924190244; Sat, 27 Sep 2025 02:11:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qs8-0004cQ-DT; Sat, 27 Sep 2025 05:05:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qrx-0004VP-4o; Sat, 27 Sep 2025 05:05:32 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qrk-0007AB-Py; Sat, 27 Sep 2025 05:05:27 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 207EA158562; Sat, 27 Sep 2025 12:03:03 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id F22D229157F; Sat, 27 Sep 2025 12:03:05 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , John Snow , Michael Tokarev Subject: [Stable-7.2.21 13/16] python/qemu/machine: use socketpair() for QMP by default Date: Sat, 27 Sep 2025 12:02:57 +0300 Message-ID: <20250927090304.2901324-13-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964264018116600 From: Marc-Andr=C3=A9 Lureau When no monitor address is given, establish the QMP communication through a socketpair() (API is also supported on Windows since Python 3.5) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-id: 20230111080101.969151-4-marcandre.lureau@redhat.com [Resolved conflicts, fixed typing error. --js] Signed-off-by: John Snow (cherry picked from commit bd4c0ef409140bd1be393407c04005ac077d4574) (Mjt: this fixes quite a few qemu iotests which was probably racing somewhe= re) Signed-off-by: Michael Tokarev diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 5df210c810..b6cb366584 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -158,17 +158,13 @@ def __init__(self, self._qmp_timer =3D qmp_timer =20 self._name =3D name or f"{id(self):x}" + self._sock_pair: Optional[Tuple[socket.socket, socket.socket]] =3D= None self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir self._sock_dir =3D sock_dir self._log_dir =3D log_dir =20 - if monitor_address is not None: - self._monitor_address =3D monitor_address - else: - self._monitor_address =3D os.path.join( - self.sock_dir, f"{self._name}.qmp" - ) + self._monitor_address =3D monitor_address =20 self._console_log_path =3D console_log if self._console_log_path: @@ -303,7 +299,11 @@ def _base_args(self) -> List[str]: args =3D ['-display', 'none', '-vga', 'none'] =20 if self._qmp_set: - if isinstance(self._monitor_address, tuple): + if self._sock_pair: + fd =3D self._sock_pair[0].fileno() + os.set_inheritable(fd, True) + moncdev =3D f"socket,id=3Dmon,fd=3D{fd}" + elif isinstance(self._monitor_address, tuple): moncdev =3D "socket,id=3Dmon,host=3D{},port=3D{}".format( *self._monitor_address ) @@ -337,10 +337,17 @@ def _pre_launch(self) -> None: self._remove_files.append(self._console_address) =20 if self._qmp_set: + monitor_address =3D None + sock =3D None + if self._monitor_address is None: + self._sock_pair =3D socket.socketpair() + sock =3D self._sock_pair[1] if isinstance(self._monitor_address, str): self._remove_files.append(self._monitor_address) + monitor_address =3D self._monitor_address self._qmp_connection =3D QEMUMonitorProtocol( - self._monitor_address, + address=3Dmonitor_address, + sock=3Dsock, server=3DTrue, nickname=3Dself._name ) @@ -360,6 +367,8 @@ def _pre_launch(self) -> None: )) =20 def _post_launch(self) -> None: + if self._sock_pair: + self._sock_pair[0].close() if self._qmp_connection: self._qmp.accept(self._qmp_timer) =20 --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175896427106215.469604776831375; Sat, 27 Sep 2025 02:11:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2Qs8-0004eU-E0; Sat, 27 Sep 2025 05:05:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qry-0004VU-CO; Sat, 27 Sep 2025 05:05:32 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qro-0007Am-7C; Sat, 27 Sep 2025 05:05:29 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 33D74158563; Sat, 27 Sep 2025 12:03:03 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 1150B291580; Sat, 27 Sep 2025 12:03:06 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Xiaoyao Li , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , Michael Tokarev Subject: [Stable-7.2.21 14/16] multiboot: Fix the split lock Date: Sat, 27 Sep 2025 12:02:58 +0300 Message-ID: <20250927090304.2901324-14-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964272081116600 From: Xiaoyao Li While running the kvm-unit-tests on Intel platforms with "split lock disable" feature, every test triggers a kernel warning of x86/split lock detection: #AC: qemu-system-x86_64/373232 took a split_loc= k trap at address: 0x1e3 Hack KVM by exiting to QEMU on split lock #AC, we get KVM: exception 17 exit (error code 0x0) EAX=3D00000001 EBX=3D00000000 ECX=3D00000014 EDX=3D0001fb80 ESI=3D00000000 EDI=3D000000a8 EBP=3D00000000 ESP=3D00006f10 EIP=3D000001e3 EFL=3D00010002 [-------] CPL=3D0 II=3D0 A20=3D1 SMM=3D0 HLT= =3D0 ES =3D0900 00009000 0000ffff 00009300 DPL=3D0 DS16 [-WA] CS =3Dc000 000c0000 0000ffff 00009b00 DPL=3D0 CS16 [-RA] SS =3D0000 00000000 0000ffff 00009300 DPL=3D0 DS16 [-WA] DS =3Dc000 000c0000 0000ffff 00009300 DPL=3D0 DS16 [-WA] FS =3D0950 00009500 0000ffff 00009300 DPL=3D0 DS16 [-WA] GS =3D06f2 00006f20 0000ffff 00009300 DPL=3D0 DS16 [-WA] LDT=3D0000 00000000 0000ffff 00008200 DPL=3D0 LDT TR =3D0000 00000000 0000ffff 00008b00 DPL=3D0 TSS32-busy GDT=3D 000c02b4 00000027 IDT=3D 00000000 000003ff CR0=3D00000011 CR2=3D00000000 CR3=3D00000000 CR4=3D00000000 DR0=3D0000000000000000 DR1=3D0000000000000000 DR2=3D0000000000000000 DR3=3D= 0000000000000000 DR6=3D00000000ffff0ff0 DR7=3D0000000000000400 EFER=3D0000000000000000 Code=3D89 16 08 00 65 66 0f 01 16 06 00 66 b8 01 00 00 00 0f 22 c0 <65> 66 = ff 2e 00 00 b8 10 00 00 00 8e d0 8e d8 8e c0 8e e0 8e e8 66 b8 08 00 66 ba = 10 05 66 And it matches with what disassembled from multiboo_dma.bin: #objdump -b binary -m i386 -D pc-bios/multiboot_dma.bin 1d1: 08 00 or %al,(%eax) 1d3: 65 66 0f 01 16 lgdtw %gs:(%esi) 1d8: 06 push %es 1d9: 00 66 b8 add %ah,-0x48(%esi) 1dc: 01 00 add %eax,(%eax) 1de: 00 00 add %al,(%eax) 1e0: 0f 22 c0 mov %eax,%cr0 > 1e3: 65 66 ff 2e ljmpw *%gs:(%esi) 1e7: 00 00 add %al,(%eax) 1e9: b8 10 00 00 00 mov $0x10,%eax 1ee: 8e d0 mov %eax,%ss 1f0: 8e d8 mov %eax,%ds 1f2: 8e c0 mov %eax,%es 1f4: 8e e0 mov %eax,%fs 1f6: 8e e8 mov %eax,%gs 1f8: 66 b8 08 00 mov $0x8,%ax 1fc: 66 ba 10 05 mov $0x510,%dx We can see that the instruction at 0x1e3 is a far jmp through the GDT. However, the GDT is not 8 byte aligned, the base is 0xc02b4. Intel processors follow the LOCK semantics to set the accessed flag of the segment descriptor when loading a segment descriptor. If the the segment descriptor crosses two cache line, it causes split lock. Fix it by aligning the GDT on 8 bytes, so that segment descriptor cannot span two cache lines. Signed-off-by: Xiaoyao Li Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/r/20250808035027.2194673-1-xiaoyao.li@intel.c= om Signed-off-by: Paolo Bonzini (cherry picked from commit 4c8f69b94839f72314c69902312068d0b9b05a34) Signed-off-by: Michael Tokarev diff --git a/pc-bios/multiboot_dma.bin b/pc-bios/multiboot_dma.bin index c0e2c3102a..e6d0c97093 100644 Binary files a/pc-bios/multiboot_dma.bin and b/pc-bios/multiboot_dma.bin di= ffer diff --git a/pc-bios/optionrom/multiboot.S b/pc-bios/optionrom/multiboot.S index 181a4b03a3..c95e35c9cb 100644 --- a/pc-bios/optionrom/multiboot.S +++ b/pc-bios/optionrom/multiboot.S @@ -208,7 +208,7 @@ ljmp2: prot_jump: .long prot_mode .short 8 =20 -.align 4, 0 +.align 8, 0 gdt: /* 0x00 */ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758964317442908.347894904875; Sat, 27 Sep 2025 02:11:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2QsL-0004yN-TC; Sat, 27 Sep 2025 05:05:56 -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 1v2QsC-0004jz-F7; Sat, 27 Sep 2025 05:05:45 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qs2-0007Bz-65; Sat, 27 Sep 2025 05:05:43 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 4633A158564; Sat, 27 Sep 2025 12:03:03 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 23F5A291581; Sat, 27 Sep 2025 12:03:06 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , =?UTF-8?q?=E6=9D=8E=E5=A8=81=E5=A8=81?= , Anton Johansson , Michael Tokarev Subject: [Stable-7.2.21 15/16] accel/tcg: Properly unlink a TB linked to itself Date: Sat, 27 Sep 2025 12:02:59 +0300 Message-ID: <20250927090304.2901324-15-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758964318484116600 From: Richard Henderson When we remove dest from orig's links, we lose the link that we rely on later to reset links. This can lead to failure to release from spinlock with self-modifying code. Cc: qemu-stable@nongnu.org Reported-by: =E6=9D=8E=E5=A8=81=E5=A8=81 Signed-off-by: Richard Henderson Reviewed-by: Anton Johansson Tested-by: Anton Johansson (cherry picked from commit 03fe6659803f83690b8587d01f8ee56bb4be4b90) Signed-off-by: Michael Tokarev diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 9d9f651c78..077265172e 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -186,6 +186,14 @@ static inline void tb_remove_from_jmp_list(Translation= Block *orig, int n_orig) * We first acquired the lock, and since the destination pointer match= es, * we know for sure that @orig is in the jmp list. */ + if (dest =3D=3D orig) { + /* + * In the case of a TB that links to itself, removing the entry + * from the list means that it won't be present later during + * tb_jmp_unlink -- unlink now. + */ + tb_reset_jump(orig, n_orig); + } pprev =3D &dest->jmp_list_head; TB_FOR_EACH_JMP(dest, tb, n) { if (tb =3D=3D orig && n =3D=3D n_orig) { --=20 2.47.3 From nobody Sun Sep 28 15:26:55 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758963985780892.8897039546491; Sat, 27 Sep 2025 02:06:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v2QsC-0004hx-1S; Sat, 27 Sep 2025 05:05:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qs7-0004ex-Pi; Sat, 27 Sep 2025 05:05:40 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v2Qs2-0007CL-CS; Sat, 27 Sep 2025 05:05:39 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 54D90158565; Sat, 27 Sep 2025 12:03:03 +0300 (MSK) Received: from think4mjt.origo (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 36024291582; Sat, 27 Sep 2025 12:03:06 +0300 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Michael Tokarev Subject: [Stable-7.2.21 16/16] tests/tcg/multiarch: Add tb-link test Date: Sat, 27 Sep 2025 12:03:00 +0300 Message-ID: <20250927090304.2901324-16-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1758963989178116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson (cherry picked from commit e13e1195db8af18e149065a59351ea85215645bb) (Mjt: resolve context conflict in tests/tcg/multiarch/Makefile.target) Signed-off-by: Michael Tokarev diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index 5f0fee1aad..2fdec1f05f 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -39,6 +39,8 @@ signals: LDFLAGS+=3D-lrt -lpthread munmap-pthread: CFLAGS+=3D-pthread munmap-pthread: LDFLAGS+=3D-pthread =20 +tb-link: LDFLAGS+=3D-lpthread + # We define the runner for test-mmap after the individual # architectures have defined their supported pages sizes. If no # additional page sizes are defined we only run the default test. diff --git a/tests/tcg/multiarch/tb-link.c b/tests/tcg/multiarch/tb-link.c new file mode 100644 index 0000000000..4e40306fa1 --- /dev/null +++ b/tests/tcg/multiarch/tb-link.c @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Verify that a single TB spin-loop is properly invalidated, + * releasing the thread from the spin-loop. + */ + +#include +#include +#include +#include +#include +#include +#include + + +#ifdef __x86_64__ +#define READY 0x000047c6 /* movb $0,0(%rdi) */ +#define LOOP 0xfceb9090 /* 1: nop*2; jmp 1b */ +#define RETURN 0x909090c3 /* ret; nop*3 */ +#define NOP 0x90909090 /* nop*4 */ +#elif defined(__aarch64__) +#define READY 0x3900001f /* strb wzr,[x0] */ +#define LOOP 0x14000000 /* b . */ +#define RETURN 0xd65f03c0 /* ret */ +#define NOP 0xd503201f /* nop */ +#elif defined(__riscv) +#define READY 0x00050023 /* sb zero, (a0) */ +#define LOOP 0x0000006f /* jal zero, #0 */ +#define RETURN 0x00008067 /* jalr zero, ra, 0 */ +#define NOP 0x00000013 /* nop */ +#endif + + +int main() +{ +#ifdef READY + int tmp; + pthread_t thread_id; + bool hold =3D true; + uint32_t *buf; + + buf =3D mmap(NULL, 3 * sizeof(uint32_t), + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + assert(buf !=3D MAP_FAILED); + + buf[0] =3D READY; + buf[1] =3D LOOP; + buf[2] =3D RETURN; + + alarm(2); + + tmp =3D pthread_create(&thread_id, NULL, (void *(*)(void *))buf, &hold= ); + assert(tmp =3D=3D 0); + + while (hold) { + sched_yield(); + } + + buf[1] =3D NOP; + __builtin___clear_cache(&buf[1], &buf[2]); + + tmp =3D pthread_join(thread_id, NULL); + assert(tmp =3D=3D 0); +#endif + return 0; +} --=20 2.47.3