From nobody Tue Feb 10 14:41:30 2026 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; dmarc=fail(p=none dis=none) header.from=gentoo.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665050835206982.6531313572582; Thu, 6 Oct 2022 03:07:15 -0700 (PDT) Received: from localhost ([::1]:60126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogNmb-0004ij-PK for importer@patchew.org; Thu, 06 Oct 2022 06:07:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogMf8-0001Cy-Lz for qemu-devel@nongnu.org; Thu, 06 Oct 2022 04:55:26 -0400 Received: from woodpecker.gentoo.org ([140.211.166.183]:48064 helo=smtp.gentoo.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1ogMf6-0000bI-3F for qemu-devel@nongnu.org; Thu, 06 Oct 2022 04:55:25 -0400 From: WANG Xuerui To: qemu-devel@nongnu.org Cc: WANG Xuerui , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jiaxun Yang , =?UTF-8?q?Andreas=20K=20=2E=20H=C3=BCttel?= , Joshua Kinard Subject: [PATCH] linux-user: Fix more MIPS n32 syscall ABI issues Date: Thu, 6 Oct 2022 16:55:00 +0800 Message-Id: <20221006085500.290341-1-xen0n@gentoo.org> X-Mailer: git-send-email 2.38.0 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=140.211.166.183; envelope-from=xen0n@gentoo.org; helo=smtp.gentoo.org X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1665050837491100001 In commit 80f0fe3a85 ("linux-user: Fix syscall parameter handling for MIPS n32") the ABI problem regarding offset64 on MIPS n32 was fixed, but still some cases remain where the n32 is incorrectly treated as any other 32-bit ABI that passes 64-bit arguments in pairs of GPRs. Fix by excluding TARGET_ABI_MIPSN32 from various TARGET_ABI_BITS =3D=3D 32 checks. Closes: https://gitlab.com/qemu-project/qemu/-/issues/1238 Signed-off-by: WANG Xuerui Cc: Philippe Mathieu-Daud=C3=A9 Cc: Jiaxun Yang Cc: Andreas K. H=C3=BCttel Cc: Joshua Kinard Reviewed-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Andreas K. Huettel Tested-by: Jiaxun Yang --- Note: I can't reproduce the crash with neither MIPS n32 sysroot at my hand (a self-built one for Loongson-2F, and stage3-mips64_n32-openrc-20221001T17= 0527Z), so I can only verify by looking at the (host and qemu) strace outputs, and would have to ask you to review/test this harder. Thanks. linux-user/syscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2e954d8dbd..8b2d39fe73 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11793,7 +11793,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return -host_to_target_errno(ret); #endif =20 -#if TARGET_ABI_BITS =3D=3D 32 +#if TARGET_ABI_BITS =3D=3D 32 && !defined(TARGET_ABI_MIPSN32) =20 #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: @@ -11920,7 +11920,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, return get_errno(sys_gettid()); #ifdef TARGET_NR_readahead case TARGET_NR_readahead: -#if TARGET_ABI_BITS =3D=3D 32 +#if TARGET_ABI_BITS =3D=3D 32 && !defined(TARGET_ABI_MIPSN32) if (regpairs_aligned(cpu_env, num)) { arg2 =3D arg3; arg3 =3D arg4; @@ -12612,7 +12612,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, #endif /* CONFIG_EVENTFD */ #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate) case TARGET_NR_fallocate: -#if TARGET_ABI_BITS =3D=3D 32 +#if TARGET_ABI_BITS =3D=3D 32 && !defined(TARGET_ABI_MIPSN32) ret =3D get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4= ), target_offset64(arg5, arg6))); #else @@ -12623,7 +12623,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, #if defined(CONFIG_SYNC_FILE_RANGE) #if defined(TARGET_NR_sync_file_range) case TARGET_NR_sync_file_range: -#if TARGET_ABI_BITS =3D=3D 32 +#if TARGET_ABI_BITS =3D=3D 32 && !defined(TARGET_ABI_MIPSN32) #if defined(TARGET_MIPS) ret =3D get_errno(sync_file_range(arg1, target_offset64(arg3, arg4= ), target_offset64(arg5, arg6), arg7)= ); @@ -12645,7 +12645,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, = int num, abi_long arg1, case TARGET_NR_arm_sync_file_range: #endif /* This is like sync_file_range but the arguments are reordered */ -#if TARGET_ABI_BITS =3D=3D 32 +#if TARGET_ABI_BITS =3D=3D 32 && !defined(TARGET_ABI_MIPSN32) ret =3D get_errno(sync_file_range(arg1, target_offset64(arg3, arg4= ), target_offset64(arg5, arg6), arg2)= ); #else --=20 2.38.0