From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329212; cv=none; d=zohomail.com; s=zohoarc; b=n4P6wxB1RQ1WsJ/yVRYfMUKRIMrzctlRSVaiXOiSDkpTYU/TbeeJTg5sy/zR27lCxYma4z47bVzKe9WjyFXiotQ4XsH4VrLiyokbXSFaKszIi2FH5D89N1wREtk5nQNb6FJOEIBf3Nc5VQV8vwNqJGrfnG0xa+j/QKVAx8s3MA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329212; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8KJX0LVS8OgRm4BbSc6yg63cQQ7Z2QXdlX7Ny7+uvEQ=; b=bYBPSrtyXwRtBPPXOr8NQVnoVeSj93NYVWlJ/AoxvTvrbSDRyJvkU6y4YCVXeAJ1/m1jLD6PXS7GrV8Jo7bK7El2lqmfpjuLc/bvK7VCHCavc0B+YnRFm5URR4E2Sx/uruCmTJ6Dky55gpcR1EfP9QR2WlWvAm/sKUHXQbnC6X4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329212842434.98583024746677; Fri, 25 Sep 2026 02:40:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2ON-0000NS-GY; Fri, 25 Sep 2026 05:38:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OL-0000N2-8i for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:53 -0400 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OJ-0006DJ-Gi for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:53 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id F3FFC6022F; Fri, 25 Sep 2026 09:38:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C5941F000FF; Fri, 25 Sep 2026 09:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329129; bh=8KJX0LVS8OgRm4BbSc6yg63cQQ7Z2QXdlX7Ny7+uvEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S6a6IK6i1FmNznuLcPObG6FDRnf1fvHWE75W4sg0JRkn0ZJ3PvRUszqIM3SMCmIWh FFgGHjy5pCQKkGEz2F9mPPL/H3rFtshIoe42N141sPTT8+8tLSmiwI8sVpvJkIPItz UnCS/XQB5wCCbGEjEuNBItoXF0MfcKEO3DsvBxM8aRmx9Cyu3+rsi8UuKsPcUQiyUK fsT7VtjFhg8F6xa7Wb6PVC58bN+cZIRHtRI8H3y46bVQtCsAl6TOcTEYi4VDaINez5 RJsWdDhKbXmoOwafC6CfL+yJTixEE7v4O5s1wERAoJq8D6/Ixt7kT6wASPWGOstFbk ar0y1ygk81iyA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 1/8] linux-user/sh4: use the kernel's sigreturn trampoline sequence in the vdso Date: Fri, 25 Sep 2026 11:38:37 +0200 Message-ID: <20260925093844.5685-2-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=172.105.4.254; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329213237158500 Content-Type: text/plain; charset="utf-8" From: Matt Turner With the vdso, default_sigreturn and default_rt_sigreturn point at __kernel_sigreturn and __kernel_rt_sigreturn and setup_sigtramp() is no longer used. The vdso trampolines load the syscall number with mov.l instead of the kernel's mov.w/trapa/or r0,r0 sequence, which undoes commit 9ac5aa7227 ("linux-user/sh4: Fix setup_sigtramp to match Linux kernel trampoline pattern"): libunwind's unw_is_signal_frame() no longer recognizes the signal frame, so unwinding through a signal handler stops there. Use the sequence from the kernel's own vdso, arch/sh/kernel/vsyscall/vsyscall-sigreturn.S. Fixes: 975bd51a88 ("linux-user/sh4: add VDSO support for sh4 and sh4eb") Cc: qemu-stable@nongnu.org Signed-off-by: Matt Turner Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/sh4/vdso-be.so | Bin 2704 -> 2720 bytes linux-user/sh4/vdso-le.so | Bin 2704 -> 2720 bytes linux-user/sh4/vdso.S | 26 ++++++++++++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/linux-user/sh4/vdso-be.so b/linux-user/sh4/vdso-be.so index 4f50143f8284ab63693c1117e68f3efa886155e3..bc1fb37e1089b7aa5612da0039e= 24193b156b3d8 100755 GIT binary patch delta 194 zcmbOrxvYf!19cNfk9yN6UOaK%t{QNljpHmC{1QPETF&*gAC*zEZrCMPE+g;si2C2d~Fmd4B&GMR%*neoSD9WHgo6_Z1_)J119 NFfg<*AOItX2>?A$F(&{3 delta 178 zcmZ1=3DIze=3DTGNZsm6=3D&8L3=3DAwUCgxO#6if>*aPh9(e`{gllH+YV4J~=3D!giQQ#TaZhL zfq{pCfgyu|f#m@M0|UqACyd*fm_-=3DeCeLHB5W38GSb%|(fq|j?GQ(j31_p+;lM@-m zC-bvDV06}1YiU)0VjPgU;qFB diff --git a/linux-user/sh4/vdso-le.so b/linux-user/sh4/vdso-le.so index c41cb5831b9e5883a64564da8b2149a33e199f4f..c1ff560cc165413d7b07aa87322= 5bd92afb8569e 100755 GIT binary patch delta 202 zcmbOrxDb@M{DWM;;Y$*f$;j6Wu8a;Y<}m>kHZ RE-{mxfuRLtBNQ+~834g&GJ*gA delta 184 zcmZ1=3DIze=3DT0;9l0MQ7F*EDQ`UCT3QPl&)2g-L`IF)#Kt%zJj4I-B(^c;xzHc4M8pj z1_mJp9)=3D7C28IVL3=3DABbA2M!dViRFtU|?{YJdeeKpYgK5VNQl}kicbu!)qreGKx>; zVST{(V)9$od{(fY$%$%B9TsVzMQdI^&GViCpRu Qo$L$@Eg<8dfDy_70CGt$_W%F@ diff --git a/linux-user/sh4/vdso.S b/linux-user/sh4/vdso.S index 4fb5ee9d31..1faa665774 100644 --- a/linux-user/sh4/vdso.S +++ b/linux-user/sh4/vdso.S @@ -43,6 +43,22 @@ vdso_syscall __vdso_clock_gettime64, __NR_clock_gettime64 vdso_syscall __vdso_clock_getres, __NR_clock_getres vdso_syscall __vdso_gettimeofday, __NR_gettimeofday =20 +/* + * Same instruction sequence as the kernel's + * arch/sh/kernel/vsyscall/vsyscall-sigreturn.S. libunwind matches these + * bytes to recognize a signal frame. + */ +.macro sigreturn_tramp nr + mov.w 1f, r3 + trapa #0x10 + or r0, r0 + or r0, r0 + or r0, r0 + or r0, r0 + or r0, r0 +1: .word \nr +.endm + /* * Signal return trampolines. * @@ -122,20 +138,14 @@ vdso_syscall __vdso_gettimeofday, __NR_gettimeofday =20 sigreturn_region_start: __kernel_sigreturn: - mov.l 1f, r3 - trapa #0x10 - .align 2 -1: .long __NR_sigreturn + sigreturn_tramp __NR_sigreturn endf __kernel_sigreturn =20 /* Update CFA base for the rt_sigreturn frame layout. */ .cfi_def_cfa_offset RT_SIGFRAME_SC_OFFSET =20 __kernel_rt_sigreturn: - mov.l 2f, r3 - trapa #0x10 - .align 2 -2: .long __NR_rt_sigreturn + sigreturn_tramp __NR_rt_sigreturn endf __kernel_rt_sigreturn sigreturn_region_end: =20 --=20 2.54.0 From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329171; cv=none; d=zohomail.com; s=zohoarc; b=HB9LIspvFvIzu0tdwEgP2EHVfyNHlqUQrRJiD7zmcY4lkMXBPoqSMW2ZqnmqGiTVTQ2sBqvW/+Fd762zTnw8EUoNfISs3p6hOyE8u2rVPHeSPVtqLohwxP+hIOc+TvyB2aHzuuc10HE7cDE3MXD/JREdb/Ye5EmuPfT8Ed4V5NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329171; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GKPRmJ+Lm+CKy/mUbJzqSr1KpZBNcPrYdh01jZ5K3cw=; b=F/juPrQg7BiuLMOUZT5zMU2LB2eJotvJNRcH0bqjxm0tTTY761scK49gYuP5Er6RKLhSZFF4/5ye4CAUnJGja+5ed/8GhkEKkvtqC6xjm7/11IJhv4UI8uZr/Q5QhdKI575kvOKTL3Rc4kWZA2uqPnKXeSEiX5xZI7UOLnT4bho= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329171668322.1205179802507; Fri, 25 Sep 2026 02:39:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2OT-0000OT-2S; Fri, 25 Sep 2026 05:39:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OM-0000NF-Bx for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:54 -0400 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OK-0006DS-LO for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:53 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id EABDD60230; Fri, 25 Sep 2026 09:38:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2395E1F000FF; Fri, 25 Sep 2026 09:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329131; bh=GKPRmJ+Lm+CKy/mUbJzqSr1KpZBNcPrYdh01jZ5K3cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Gv3e1+cJSMcjOojFxAJFLcnNdZVkRv5tWWEqYR8oirTzzTZgjIDTaQR3D8aYOBFlI ZmYY6EGJNfdfSDVrmTVJa3FB0GaqC6XA1Wf8/0NXXojN5F0cJ4LS0ZhxolN57q339h st/Bsg41rM/l6EtW1FDvzAvDT+SUBhHh8k1gGapWvN9Md3B51PaJ+D4oj1/0LhVQVi g5PFF9VsCxcp46d/c+DmJWCRsFeNIyRko0LGXooxKkdy/rhWO8w8bJXDIALZoYiKHK gP0/Px0Xqws832P/vldig13Miuprro9oIBzUSF2LNhc0zVULlZqghSgyPLsINcjf0Z F/RLRijyla8fw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 2/8] linux-user/sh4: fix vdso CFA for rt_sigreturn frames Date: Fri, 25 Sep 2026 11:38:38 +0200 Message-ID: <20260925093844.5685-3-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2600:3c04:e001:324:0:1991:8:25; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329173498158500 Content-Type: text/plain; charset="utf-8" From: Matt Turner The unwinder looks up a return address as IP - 1 (hence the nop before sigreturn_region_start). For a frame returning to __kernel_rt_sigreturn that is the last byte of __kernel_sigreturn, which still has the sigreturn CFA, so the rt_sigreturn frame is unwound with the wrong sigcontext offset. _Unwind_Backtrace() from an SA_SIGINFO handler stops after three frames. Add a nop after .cfi_def_cfa_offset, as linux-user/i386/vdso.S does. Fixes: 975bd51a88 ("linux-user/sh4: add VDSO support for sh4 and sh4eb") Cc: qemu-stable@nongnu.org Signed-off-by: Matt Turner Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/sh4/vdso-be.so | Bin 2720 -> 2720 bytes linux-user/sh4/vdso-le.so | Bin 2720 -> 2720 bytes linux-user/sh4/vdso.S | 3 ++- 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/sh4/vdso-be.so b/linux-user/sh4/vdso-be.so index bc1fb37e1089b7aa5612da0039e24193b156b3d8..df9fa22efab46bffbb9957af078= 199639998ea43 100755 GIT binary patch delta 94 zcmZ1=3Dx##V)FyW-As%sljpE_2{CX^ vW<4yRzzu^8YbPf%icjWeeZcr*@(0#@#ut+l*u2^Nd@N1SlhXr*UW(&mk9@0kI)8X|`P diff --git a/linux-user/sh4/vdso-le.so b/linux-user/sh4/vdso-le.so index c1ff560cc165413d7b07aa873225bd92afb8569e..decd674202260f045b646b318eb= b0b6daf416651 100755 GIT binary patch delta 93 zcmZ1=3Dx#wX*~i%pXz{&>RpZ1Y{l-As&1lV`H{3bIZX uILxg8gKHT$CnqwBPUc~K!1!(QTh@HWXOm;u{Md{ (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179032917187780.33895298131495; Fri, 25 Sep 2026 02:39:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2OV-0000Ov-MH; Fri, 25 Sep 2026 05:39:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OP-0000Nz-1N for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:57 -0400 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2ON-0006Dy-Ea for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:56 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B44B743AA2; Fri, 25 Sep 2026 09:38:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A3901F000FF; Fri, 25 Sep 2026 09:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329133; bh=rukc2QXxQ5m9wxhcv1mTkjBTk1ApN+E5byqZCiijtZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fTXnobhumsXoT/jb8rpe/xF1FvOpG9NJvYya97jWIYdoXXTgMxGY3SWTXA8Pj6pc3 sdakYRCCYbz7Rz/yHbdBZxAcpXHKh9xxc/T4QK8KQNmOpLUua2V++vvc8zeceU3Skz u9M6Nfx0h2PkO92wdkZpiFmgM7Yp/v26fTrJy09xH4CNX9OgRQb0rfo7dl1aT6jjSJ 7kbZmcGP46dHTryPz6HXdrc3AY//xmb10XaQ0zakl4HKTs7wEkCH7LFgGlzi39pyBr hA45VH3Fl1ZcaZ15ldAlSixHJQ/yOn/BN1kM6t4vmaXchPxSz185cImRlWMDG7/St6 /vV91TJXLksaw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 3/8] linux-user/sh4: align the vdso sigreturn trampolines Date: Fri, 25 Sep 2026 11:38:39 +0200 Message-ID: <20260925093844.5685-4-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=172.234.252.31; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329173531158500 From: Matt Turner libunwind's unw_is_signal_frame() reads the trampoline as 32-bit words, but __kernel_sigreturn is only 2-byte aligned. Align both trampolines to 4 bytes, as the kernel's vsyscall-sigreturn.S does (with .balign 32). Signed-off-by: Matt Turner Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/sh4/vdso-be.so | Bin 2720 -> 2724 bytes linux-user/sh4/vdso-le.so | Bin 2720 -> 2724 bytes linux-user/sh4/vdso.S | 2 ++ 3 files changed, 2 insertions(+) diff --git a/linux-user/sh4/vdso-be.so b/linux-user/sh4/vdso-be.so index df9fa22efab46bffbb9957af078199639998ea43..d74a2d78e869d7bc6c531c36d82= d6c2b1315287b 100755 GIT binary patch delta 192 zcmZ1=3DxGNZ~w6=3D&8z3=3DAxPCgxO#9C@_r)US}NFAa~om)?|aoD?HG|JB4F*9C7d zFfa%RF);8jFfe2=3DFtEJY{D5&c6SD?`*W`ID79tFslUWZ7C~(6dLpcNIa~L`HXKSC$QNIAj35dCBc3ya delta 172 zcmZ1?xQ;(|ew7YO+;`jbwinsW|b+b-`;4 z3=3D9H73=3DBLB3=3DA0z3@k4;KVaO=3D#H_;LIe8w7g}`Li!vYH2Fvw6o`4!7gupSTq=3D}`t* zF!>8>KI4nYDQxya2=3DkJY{d_D<{hT*%WlLjb44Ev$rOfzavICbo0;9@AMQ7GOEDQ{PCT3QPWaXVH&gBv-40~8xYBG;6g<=3D1u`xAd$5xl{| zz#zcDz#zoH!;rzi!0=3D}CUB=3Dx^Y#Iy<3=3DCeA=3DdoA_b26|_7C6kU0E6WWoRgojd-y?_bLI+hO95D}vWp z7#IW?7#M^Yco;Gm7#Ln`zRS3qiA{xpfq}tu@;nv`e%8qXhq)DCuzd1MmhWI)5WvHr z%)r3#WAaDVe8v}(6WQ!VkxgVsPA-e^_Xzgiyp=3D7PnK5K?B8Tu~9WDXJACqml)LB=3Ds YF))0b9LOm=3DxrR%CbtXFlLkoxp030MX^8f$< diff --git a/linux-user/sh4/vdso.S b/linux-user/sh4/vdso.S index 290eb498ae..a66cac7439 100644 --- a/linux-user/sh4/vdso.S +++ b/linux-user/sh4/vdso.S @@ -135,6 +135,7 @@ vdso_syscall __vdso_gettimeofday, __NR_gettimeofday .cfi_offset 24, SC_FPSCR =20 nop + .balign 4 =20 sigreturn_region_start: __kernel_sigreturn: @@ -144,6 +145,7 @@ endf __kernel_sigreturn /* rt_sigreturn frame layout; nop for the same reason as above. */ .cfi_def_cfa_offset RT_SIGFRAME_SC_OFFSET nop + .balign 4 =20 __kernel_rt_sigreturn: sigreturn_tramp __NR_rt_sigreturn --=20 2.54.0 From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329192; cv=none; d=zohomail.com; s=zohoarc; b=hqN5VSBzK3jBLRBjn+YHOU7aa09fw6m6RNB5YG30ccunx3SUGRq8olfi4mMpt06EEQUb86FiwVaVXDKqe4h5qki8/zHZu0WrGYTtPRgi0kEDFJ2kiSOsKBUsOYY/L0HGAZWvaISrZQhm3J3KlcCsgxF/PAoDpXfXLrbFomUGg44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329192; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fmt/heT7BOpUd0wmehd5KZosBvTHmqytpQH3KmNzulk=; b=npMY277YIoJMm8G+CWIKkEgSz9JRFH+vbaQcrjeWqR78eFwj1o1bLTC0EJeVaQqN9l9lrBu4cRx2Tun0b1K9lBrnO3RpikUGLPEoE2O3zMvbi+4sY4v+oJipmzy8MLa38oyRZ6rciLd25UWtmiOc2f45q4PcRlPr4FrZSBr2QYE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329192342123.86332224614603; Fri, 25 Sep 2026 02:39:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2OY-0000PE-IG; Fri, 25 Sep 2026 05:39:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OQ-0000OD-V1 for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:59 -0400 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OO-0006E5-Ij for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:57 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id AAA9343802; Fri, 25 Sep 2026 09:38:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 106071F000FF; Fri, 25 Sep 2026 09:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329135; bh=fmt/heT7BOpUd0wmehd5KZosBvTHmqytpQH3KmNzulk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a60iDHHwT1KEjDhRvuOEl3T88tbB88g11i5heMeFWbiPIqIQGll7H/fcQnsoNWEzR 2q4DtD2CaXeqIrpvfkmHPd9GvaoKszWKWZpV4GAvL458AZ8t5jK8A9zW25N0hapck4 dB14Kl54P+VKDDwa/Gl0I54P4jwlwQtI5+FU8mhG5cJm88iXmUI0U2WHByCvs5+ggf jgyhYOesrhkXFNFj22old0J/NqBTCOCFYNGWoeeQkjY7wVsszH+T2O8m+6FK/8JhrD Rw1B17FWNGjqNHRIlTGZfoIezSQdvZKGrfcK12MNLHb6I799Mic2zOHE2G4ZjMj6zQ Pac1RUe3e9FEg== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 4/8] linux-user: report EBADF for setsockopt()/getsockopt() on a bad fd Date: Fri, 25 Sep 2026 11:38:40 +0200 Message-ID: <20260925093844.5685-5-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=172.234.252.31; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329193237158500 Content-Type: text/plain; charset="utf-8" From: Igor Shevlyakov The kernel looks the fd up before validating the rest of the call, so a negative fd is EBADF whatever else is wrong with the arguments. Several arms of do_setsockopt()/do_getsockopt() reject optlen or optname and return without ever reaching the host syscall, so the host never gets to supply that EBADF and the guest sees the argument error instead: setsockopt(-1, SOL_TCP, TCP_NODELAY, ptr, 0) EINVAL, want EBADF setsockopt(-1, 0x4321, 1, ptr, sizeof(int)) ENOPROTOOPT getsockopt(-1, 0x4321, 1, ptr, &len) EOPNOTSUPP Caught by glibc's posix/test-errno. Signed-off-by: Igor Shevlyakov Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/syscall.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9f454502cb..e7c9fb33a3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2119,6 +2119,15 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, abi_long ret; int val; =20 + /* + * The kernel looks the fd up before it validates anything else, so a = bad + * fd is EBADF even when the rest of the call is also wrong. Several = arms + * below reject optlen or optname without ever reaching the host sysca= ll, + * and would report that instead. + */ + if (sockfd < 0) { + return -TARGET_EBADF; + } switch(level) { case SOL_TCP: case SOL_UDP: @@ -2623,6 +2632,10 @@ static abi_long do_getsockopt(int sockfd, int level,= int optname, int len, val; socklen_t lv; =20 + /* EBADF wins over the argument checks below; see do_setsockopt(). */ + if (sockfd < 0) { + return -TARGET_EBADF; + } switch(level) { case TARGET_SOL_SOCKET: level =3D SOL_SOCKET; --=20 2.54.0 From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329178; cv=none; d=zohomail.com; s=zohoarc; b=ctNWr3glQVkm6VdgKt3fu/fOjjuLQPnWrL3/KlxrKRLl+q6mTdfjmkIHk7j2LejfTqjN5LN6QkjD1Ri16fEnWAoLyvUuuh74dxt/yLbkwEqdThEmoei8qPIuM4mM1TkvhFAIJctE3zJGFsc1dmLCzdt9bo7wr80A305aXMZk+aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329178; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k9qQwd9rCS4KUyCxgy57OiSEAHkiyEnMiP8vN0BIMD0=; b=UpQJtzvGTr25J9kTBWW91NpHv7SGzSV9YKe6zOEZvgrSQIjD7s3NU42m7YbdlHM/ctGFMTYUJUDMyMzuH3eDGflXDTkr90obDSpiPOXgkaReh8VgHX8PF8vZpyHW5Dz4OYUCiLNAXKJMGqUX4LDXeelvsuA4/BOc57zhy/B/ut4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329178387977.9886512983904; Fri, 25 Sep 2026 02:39:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2Oa-0000PU-GE; Fri, 25 Sep 2026 05:39:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OS-0000OU-3W for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:00 -0400 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OQ-0006EQ-Nv for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:38:59 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id CD7EA6022E; Fri, 25 Sep 2026 09:38:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 069A41F000FF; Fri, 25 Sep 2026 09:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329137; bh=k9qQwd9rCS4KUyCxgy57OiSEAHkiyEnMiP8vN0BIMD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=byUynqKMH7sq9hXUUFVzi5PbjCf1V59e15v5DggOxVAetSEmnyiYv/FkTL6xpMiS4 hrXQsPdZ/6+a/BskftGJGiufs3m5H5DWXQ9j6tD6GGbkB0oyAUiuuIowUgx+xC3Qo8 kA01Inf+gTWjVhM+ElEZonHkpyHKf6Wwo2UJulxZVYDqTIDHMwK/I7dpHvZcgZuIsO YiBwtdDfBfHdJ/G/3aE4SZqsTu55SZ4b5DdR3xvFSSiTY38+FYFzUI6BwUoHUdcLBd q/+YKaaPjYnoiAXqaxW3LDi6uz6Kh5TB8aNklEAz+tx+r12vGVirs8kDM4OfM6BuQQ usVa+zc5Hhh4g== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 5/8] linux-user: report EINVAL for a misaligned mincore() start Date: Fri, 25 Sep 2026 11:38:41 +0200 Message-ID: <20260925093844.5685-6-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2600:3c04:e001:324:0:1991:8:25; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329179621158500 Content-Type: text/plain; charset="utf-8" From: Igor Shevlyakov mincore(2) rejects a misaligned start address before it looks the range up, so a start that is both misaligned and unmapped is EINVAL. Here lock_user() runs first and fails, and the call reports ENOMEM instead. When the range is mapped this changes nothing -- the host syscall receives the misaligned pointer and answers EINVAL by itself -- which is why only the unmapped case is visibly wrong. Caught by glibc's misc/test-errno-linux. Signed-off-by: Igor Shevlyakov Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/syscall.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e7c9fb33a3..0380691a8b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -13064,7 +13064,17 @@ static abi_long do_syscall1(CPUArchState *cpu_env,= int num, abi_long arg1, #ifdef TARGET_NR_mincore case TARGET_NR_mincore: { - void *a =3D lock_user(VERIFY_NONE, arg1, arg2, 0); + void *a; + + /* + * The kernel rejects a misaligned start before it looks the r= ange + * up, so a start that is both misaligned and unmapped is EINV= AL, + * not the ENOMEM that a failing lock_user() would report. + */ + if (arg1 & ~TARGET_PAGE_MASK) { + return -TARGET_EINVAL; + } + a =3D lock_user(VERIFY_NONE, arg1, arg2, 0); if (!a) { return -TARGET_ENOMEM; } --=20 2.54.0 From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329225; cv=none; d=zohomail.com; s=zohoarc; b=ERO1mf+Q7S1K7woSJOpzjhuTjrgtShEsDFEi9u1e7qhVduZ5bL6IRvtEBmcX1IO1IJIn1xAqxkRcNgxbJAb9uinDpDU1EdNqk0+w++sAf+mfJRFs0hFFEiiqIzw6G9YvCQZWhvPSxy0Q88hyK8cwdbiAnMsSzFXDAIjdDZAKgR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329225; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ECyzsDtcDEjajNrCXxTfs09UvMY1Lp8zlSn++FOVyE4=; b=GXRZn1+P9aYLY3erbhJ25ELs2KVxp+eo0sMxNnlZRQX/rZTGTI405hLtNv6sQqWViPOtUpBopU0FhO/g3CIS2io5RIoxd/fSO3s82EtPCiQQb2Vd/VTJhH4QH4ZKuaBZ5MgQly/RdCNnb+i6HKnlzgw6Kcl+cl5nTBsE/z1rN+c= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329225348523.9368767049319; Fri, 25 Sep 2026 02:40:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2Ob-0000Q2-4M; Fri, 25 Sep 2026 05:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OT-0000Ow-Qa for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:03 -0400 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OS-0006Ef-Eq for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:01 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id C35486022F; Fri, 25 Sep 2026 09:38:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0FBE1F000FF; Fri, 25 Sep 2026 09:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329139; bh=ECyzsDtcDEjajNrCXxTfs09UvMY1Lp8zlSn++FOVyE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JQ4Hg4IUriKQEViNP/Mg8ThD/YBIizn9pebLsh+LLRJRQzdqdHZrh7JcOKVWwUgxO 1MAp70iE4EKrZ8hW+QkAXqGVWebl7Vjjw4VeMXat8KZUdrPP0yBsMe11qGETA8aR8T apXPl1QJ89H1o5Pnikb4tEfSNLQozQUYvoqNV7VQ3OTn9Z1DkD3ZcU2+Mhed449vJw Ab+ky4CEfcXSFlLqE8kkfcIvy/FrtyRtqlhek2FdNn/O7O/uVTDOw9ru+B04PF+PHa XwryZ7XIjqdLlgdoNLeP2AYvQBraMcggjxfBT4nMisNlk9bEUqpopBDnzILwRvM01+ +jyWKQqgYv2zQ== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 6/8] accel/tcg: Set CF_NOIRQ during cpu_exec_step_atomic Date: Fri, 25 Sep 2026 11:38:42 +0200 Message-ID: <20260925093844.5685-7-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=172.105.4.254; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329227283158500 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Do not go through the effort of grabbing the exclusive lock only to check for interrupts and exit without making progress. Cc: qemu-stable@nongnu.org Signed-off-by: Richard Henderson Tested-by: Mikulas Patocka Signed-off-by: Helge Deller --- accel/tcg/cpu-exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 5226cfb765..f4428e9f7b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -566,7 +566,8 @@ void cpu_exec_step_atomic(CPUState *cpu) /* Execute in a serial context. */ s.cflags &=3D ~CF_PARALLEL; /* After 1 insn, return and release the exclusive lock. */ - s.cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | 1; + s.cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | CF_NOIRQ | 1; + /* * No need to check_for_breakpoints here. * We only arrive in cpu_exec_step_atomic after beginning execution --=20 2.54.0 From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329187; cv=none; d=zohomail.com; s=zohoarc; b=c/rsaHXV8GxicFN2i/XRfescbnw1zF+6Y3VyWEQjnNFjntOnkaXL63vbPFK/g0UpQ2QkdPBWItyWkqdPDvL3pdgm4leflqS8sRJqXcDHHpy161brSCb/4SlB5bvUUsgK/gtwA0C6fM22Y2xhvw+m1146D31nk6fZON9twzmw3x8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329187; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HFAMBTvxDYiY7scNthZmqVHclWsFzUZKzfvh58Obg3E=; b=GTvc7Q5hE9siRwbcAT18CQRVqH6FLG1TC0WANiDyysHBR0PVRe928P5WZEiSmbJpV4bnlWLM19RRsnYzlC1vhfGLxGJk+aYEpamZ/iHGbBv1HF+cIAm3YhUu9FXsZigru5WhG6VCJE5hUBtmw78w+wZG+R6S+wDUfZanZiiEGrg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329187444140.89605960202778; Fri, 25 Sep 2026 02:39:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2Oc-0000QM-M5; Fri, 25 Sep 2026 05:39:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OX-0000PK-9U for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:06 -0400 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OV-0006F0-4f for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:05 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 8D48B43802; Fri, 25 Sep 2026 09:39:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E74701F000FF; Fri, 25 Sep 2026 09:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329141; bh=HFAMBTvxDYiY7scNthZmqVHclWsFzUZKzfvh58Obg3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b7alQTylTNfO6M+v9estdWAMYZWSLGH3r2xKL+EjIz+hxL0D7/SWJlKKIBE8CCxxY z/yenDAr6vnUUfNoi+L20U5hVaVBnR8J+o4u90xZKoXpLw9FH5j1ltvXf1pZGzVHG+ jhP/Cc0lahlp4S0t+PyCwPYXzQ2hCbQ9Ad67yBZvFdmKb9yJjcCyWhabuqgWZTt1A8 TnOdTiiH9rWETh6LY+DKd2nwSR7mNF28PKJY3XnVZmnJiYBdmjVR/Nvua7ZSYjMm/W Ssudsa9VV5IGvmKFPpJ9TjmQt/wqbJgEjyj4nboUFQd4ju78K5Vz+/bAc18WFox/MA N3dcEGZnfhLlA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 7/8] target/sh4: Replace TB_FLAG_GUSA_EXCLUSIVE with CF_STEP_ATOMIC Date: Fri, 25 Sep 2026 11:38:43 +0200 Message-ID: <20260925093844.5685-8-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2600:3c0a:e001:78e:0:1991:8:25; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329189272158500 Content-Type: text/plain; charset="utf-8" From: Richard Henderson There was a complex bug with gUSA wherein: * decode_gusa calls gen_restart_exclusive * gen_restart_exclusive generates code that sets TB_FLAG_GUSA_EXCLUSIVE and generates a call to helper_exclusive * when the code is executed, TB_FLAG_GUSA_EXCLUSIVE is set * helper_exclusive calls cpu_loop_exit_atomic, this makes cpu_exec exit with EXCP_ATOMIC * we go to cpu_loop, we execute cpu_exec_step_atomic * suppose that exit request is set, cpu_exec_step_atomic does nothing, it leaves the CPU in the same state as it was before * we go back to cpu_loop * suppose that no signal is delivered, so the gUSA is not rewound * cpu_loop goes to cpu_exec * there is one difference - now, TB_FLAG_GUSA_EXCLUSIVE is set and it was clear before - so cpu_exec will not use the TB that calls helper_exclusive, it will instead use the TB that performs the atomic operation (both of these TBs have the same PC, they only differ in flag= s) * the TB that performs the atomic operation is executed inside cpu_exec =3D> race condition Fix the bug by managing the "are we in cpu_exec_step_atomic" flag from cpu_exec_step_atomic itself, rather from the translator. Cc: qemu-stable@nongnu.org Fixes: 4bfa602bc22 ("target/sh4: Handle user-space atomics") Reported-by: Mikulas Patocka Signed-off-by: Richard Henderson Tested-by: Mikulas Patocka Signed-off-by: Helge Deller --- accel/tcg/cpu-exec.c | 3 ++- include/exec/translation-block.h | 1 + target/sh4/cpu.h | 6 ++---- target/sh4/translate.c | 34 +++++++++++++++++++++++--------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index f4428e9f7b..5b4bca5084 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -566,7 +566,8 @@ void cpu_exec_step_atomic(CPUState *cpu) /* Execute in a serial context. */ s.cflags &=3D ~CF_PARALLEL; /* After 1 insn, return and release the exclusive lock. */ - s.cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | CF_NOIRQ | 1; + s.cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | + CF_NOIRQ | CF_STEP_ATOMIC | 1; =20 /* * No need to check_for_breakpoints here. diff --git a/include/exec/translation-block.h b/include/exec/translation-bl= ock.h index 40cc699031..7c42c57cca 100644 --- a/include/exec/translation-block.h +++ b/include/exec/translation-block.h @@ -84,6 +84,7 @@ struct TranslationBlock { #define CF_NOIRQ 0x00010000 /* Generate an uninterruptible TB */ #define CF_PCREL 0x00020000 /* Opcodes in TB are PC-relative */ #define CF_BP_PAGE 0x00040000 /* Breakpoint present in code page */ +#define CF_STEP_ATOMIC 0x00080000 /* Running in cpu_exec_step_atomic */ #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ #define CF_CLUSTER_SHIFT 24 =20 diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 3302702376..6984bb462f 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -84,8 +84,7 @@ #define TB_FLAG_DELAY_SLOT_RTE (1 << 2) #define TB_FLAG_PENDING_MOVCA (1 << 3) #define TB_FLAG_GUSA_SHIFT 4 /* [11:4] */ -#define TB_FLAG_GUSA_EXCLUSIVE (1 << 12) -#define TB_FLAG_UNALIGN (1 << 13) +#define TB_FLAG_UNALIGN (1 << 12) #define TB_FLAG_SR_FD (1 << SR_FD) /* 15 */ #define TB_FLAG_FPSCR_PR FPSCR_PR /* 19 */ #define TB_FLAG_FPSCR_SZ FPSCR_SZ /* 20 */ @@ -96,8 +95,7 @@ #define TB_FLAG_DELAY_SLOT_MASK (TB_FLAG_DELAY_SLOT | \ TB_FLAG_DELAY_SLOT_COND | \ TB_FLAG_DELAY_SLOT_RTE) -#define TB_FLAG_GUSA_MASK ((0xff << TB_FLAG_GUSA_SHIFT) | \ - TB_FLAG_GUSA_EXCLUSIVE) +#define TB_FLAG_GUSA_MASK (0xff << TB_FLAG_GUSA_SHIFT) #define TB_FLAG_FPSCR_MASK (TB_FLAG_FPSCR_PR | \ TB_FLAG_FPSCR_SZ | \ TB_FLAG_FPSCR_FR) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 373950fd66..c15c0802f7 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -47,6 +47,9 @@ typedef struct DisasContext { uint16_t opcode; =20 bool has_movcal; +#ifdef CONFIG_USER_ONLY + bool in_gusa_exclusive; +#endif } DisasContext; =20 #if defined(CONFIG_USER_ONLY) @@ -220,7 +223,11 @@ static inline void gen_save_cpu_state(DisasContext *ct= x, bool save_pc) =20 static inline bool use_exit_tb(DisasContext *ctx) { - return (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) !=3D 0; +#ifdef CONFIG_USER_ONLY + return ctx->in_gusa_exclusive; +#else + return false; +#endif } =20 static bool use_goto_tb(DisasContext *ctx, vaddr dest) @@ -273,7 +280,8 @@ static void gen_conditional_jump(DisasContext *ctx, vad= dr dest, TCGLabel *l1 =3D gen_new_label(); TCGCond cond_not_taken =3D jump_if_true ? TCG_COND_EQ : TCG_COND_NE; =20 - if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) { +#ifdef CONFIG_USER_ONLY + if (ctx->in_gusa_exclusive) { /* When in an exclusive region, we must continue to the end. Therefore, exit the region on a taken branch, but otherwise fall through to the next instruction. */ @@ -286,6 +294,7 @@ static void gen_conditional_jump(DisasContext *ctx, vad= dr dest, ctx->base.is_jmp =3D DISAS_NEXT; return; } +#endif =20 gen_save_cpu_state(ctx, false); tcg_gen_brcondi_i32(cond_not_taken, cpu_sr_t, 0, l1); @@ -304,7 +313,8 @@ static void gen_delayed_conditional_jump(DisasContext *= ctx) tcg_gen_mov_i32(ds, cpu_delayed_cond); tcg_gen_discard_i32(cpu_delayed_cond); =20 - if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) { +#ifdef CONFIG_USER_ONLY + if (ctx->in_gusa_exclusive) { /* When in an exclusive region, we must continue to the end. Therefore, exit the region on a taken branch, but otherwise fall through to the next instruction. */ @@ -318,6 +328,7 @@ static void gen_delayed_conditional_jump(DisasContext *= ctx) ctx->base.is_jmp =3D DISAS_NEXT; return; } +#endif =20 tcg_gen_brcondi_i32(TCG_COND_NE, ds, 0, l1); gen_goto_tb(ctx, 1, ctx->base.pc_next + 2); @@ -1793,16 +1804,18 @@ static void decode_opc(DisasContext * ctx) /* go out of the delay slot */ ctx->envflags &=3D ~TB_FLAG_DELAY_SLOT_MASK; =20 +#ifdef CONFIG_USER_ONLY /* When in an exclusive region, we must continue to the end for conditional branches. */ - if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE - && old_flags & TB_FLAG_DELAY_SLOT_COND) { + if (ctx->in_gusa_exclusive && old_flags & TB_FLAG_DELAY_SLOT_COND)= { gen_delayed_conditional_jump(ctx); return; } + /* Otherwise this is probably an invalid gUSA region. Drop the GUSA bits so the next TB doesn't see them. */ ctx->envflags &=3D ~TB_FLAG_GUSA_MASK; +#endif =20 tcg_gen_movi_i32(cpu_flags, ctx->envflags); if (old_flags & TB_FLAG_DELAY_SLOT_COND) { @@ -1820,7 +1833,6 @@ static void decode_opc(DisasContext * ctx) */ static void gen_restart_exclusive(DisasContext *ctx) { - ctx->envflags |=3D TB_FLAG_GUSA_EXCLUSIVE; gen_save_cpu_state(ctx, false); gen_helper_exclusive(tcg_env); ctx->base.is_jmp =3D DISAS_NORETURN; @@ -2208,11 +2220,13 @@ static void sh4_tr_init_disas_context(DisasContextB= ase *dcbase, CPUState *cs) int backup =3D sextract32(ctx->tbflags, TB_FLAG_GUSA_SHIFT, 8); int max_insns =3D (pc_end - pc) / 2; =20 + ctx->in_gusa_exclusive =3D ctx->base.tb->cflags & CF_STEP_ATOMIC; + if (pc !=3D pc_end + backup || max_insns < 2) { /* This is a malformed gUSA region. Don't do anything special, since the interpreter is likely to get confused. */ ctx->envflags &=3D ~TB_FLAG_GUSA_MASK; - } else if (tbflags & TB_FLAG_GUSA_EXCLUSIVE) { + } else if (ctx->in_gusa_exclusive) { /* Regardless of single-stepping or the end of the page, we must complete execution of the gUSA region while holding the exclusive lock. */ @@ -2246,7 +2260,7 @@ static void sh4_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) =20 #ifdef CONFIG_USER_ONLY if (unlikely(ctx->envflags & TB_FLAG_GUSA_MASK) - && !(ctx->envflags & TB_FLAG_GUSA_EXCLUSIVE)) { + && !ctx->in_gusa_exclusive) { /* * We're in an gUSA region, and we have not already fallen * back on using an exclusive region. Attempt to parse the @@ -2276,10 +2290,12 @@ static void sh4_tr_tb_stop(DisasContextBase *dcbase= , CPUState *cs) { DisasContext *ctx =3D container_of(dcbase, DisasContext, base); =20 - if (ctx->tbflags & TB_FLAG_GUSA_EXCLUSIVE) { +#ifdef CONFIG_USER_ONLY + if (ctx->in_gusa_exclusive) { /* Ending the region of exclusivity. Clear the bits. */ ctx->envflags &=3D ~TB_FLAG_GUSA_MASK; } +#endif =20 switch (ctx->base.is_jmp) { case DISAS_STOP: --=20 2.54.0 From nobody Sat Sep 26 19:11:54 2026 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1790329207; cv=none; d=zohomail.com; s=zohoarc; b=H1FT4ja1nCMtI+ruEIKn+kRkRe3mR2GAt0SRf3evEiJluejdpsk05hDg3VWF1WVzDEjolYUxX03GTvyMVTWendJz9oAN5tBCDrHShUHH/fW36atyylTHEMa1PN4hTDf4/EDNNe+lFDFRyEgOTMss5Za/jfnMZK7hk/wXt9oZjeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790329207; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tS0YcDzVifwFGi/tdYBQPi2c6igEc0t6JH9tkfzpQIE=; b=mygadMXgEYR6SocWwPItoYKeQBoJRNvy3LDMrZqgdTRsOFnDWeC2Fr1rvJtsEKufrdHfsCzjcfqpXreHfjFBSoXwnQjFXyFaneDxHnzuD1xnBH5Je40L6mfq83IF5inqawhH+eyBaxKLCIRPQx2Y6chEg3jearNKIyLbZAeeK7k= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790329207879204.46534127389293; Fri, 25 Sep 2026 02:40:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xA2Ob-0000QG-Qe; Fri, 25 Sep 2026 05:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OY-0000PM-AP for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:06 -0400 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xA2OW-0006FE-Gb for qemu-devel@nongnu.org; Fri, 25 Sep 2026 05:39:05 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 834B143AA2; Fri, 25 Sep 2026 09:39:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD5C61F000FF; Fri, 25 Sep 2026 09:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790329143; bh=tS0YcDzVifwFGi/tdYBQPi2c6igEc0t6JH9tkfzpQIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LfPnHwxEKNuTdpWrB1jPm4PpaVoOvOVDrO2pdCfi2g7ib5t3O59zyO2Q1an4oQnJm C0jE7UPFrAQghZbVuaWoonEKOY/xgweGnTyxdyp4vWADTozcJ7c+905P+Uq2fpDTCN L9v2w/NZAabfGIUYVPNxJM97rn5FQcsoowbVKdFi3FcgstS9Juuk2T4iTFHW4eKNX2 OuBKXWCD7bTZQEHAFZHot0b82mVTFRTXhDsYRF8L2qBIWs15+8bBtv4SwnEFJp44+J ybeCc/3FAVa8J/HDQ0lZEMyAtsVTuLFPbTHxWh60yc+FmUXozxCcOlgdnONXsQta+5 cpTuu6/IWNQtw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Paolo Bonzini , Yoshinori Sato , Richard Henderson , Helge Deller , Laurent Vivier Subject: [PULL 8/8] target/sh4: Drop use_exit_tb Date: Fri, 25 Sep 2026 11:38:44 +0200 Message-ID: <20260925093844.5685-9-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260925093844.5685-1-deller@kernel.org> References: <20260925093844.5685-1-deller@kernel.org> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2600:3c0a:e001:78e:0:1991:8:25; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: qemu development 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 @kernel.org) X-ZM-MESSAGEID: 1790329209322158500 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Rely on cpu_exec_step_atomic setting CF_NO_GOTO_TB and CF_NO_GOTO_PTR, which will cause exit_tb to be used. Signed-off-by: Richard Henderson Tested-by: Mikulas Patocka Signed-off-by: Helge Deller --- target/sh4/translate.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index c15c0802f7..5729a757f1 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -221,20 +221,8 @@ static inline void gen_save_cpu_state(DisasContext *ct= x, bool save_pc) } } =20 -static inline bool use_exit_tb(DisasContext *ctx) -{ -#ifdef CONFIG_USER_ONLY - return ctx->in_gusa_exclusive; -#else - return false; -#endif -} - static bool use_goto_tb(DisasContext *ctx, vaddr dest) { - if (use_exit_tb(ctx)) { - return false; - } return translator_use_goto_tb(&ctx->base, dest); } =20 @@ -246,11 +234,7 @@ static void gen_goto_tb(DisasContext *ctx, unsigned tb= _slot_idx, vaddr dest) tcg_gen_exit_tb(ctx->base.tb, tb_slot_idx); } else { tcg_gen_movi_i32(cpu_pc, dest); - if (use_exit_tb(ctx)) { - tcg_gen_exit_tb(NULL, 0); - } else { - tcg_gen_lookup_and_goto_ptr(); - } + tcg_gen_lookup_and_goto_ptr(); } ctx->base.is_jmp =3D DISAS_NORETURN; } @@ -262,11 +246,7 @@ static void gen_jump(DisasContext * ctx) delayed jump as immediate jump are conditinal jumps */ tcg_gen_mov_i32(cpu_pc, cpu_delayed_pc); tcg_gen_discard_i32(cpu_delayed_pc); - if (use_exit_tb(ctx)) { - tcg_gen_exit_tb(NULL, 0); - } else { - tcg_gen_lookup_and_goto_ptr(); - } + tcg_gen_lookup_and_goto_ptr(); ctx->base.is_jmp =3D DISAS_NORETURN; } else { gen_goto_tb(ctx, 0, ctx->delayed_pc); --=20 2.54.0