* [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32
@ 2022-03-20 5:22 WANG Xuerui
2022-03-20 18:03 ` Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: WANG Xuerui @ 2022-03-20 5:22 UTC (permalink / raw)
To: qemu-devel
Cc: WANG Xuerui, Andreas K . Hüttel, Laurent Vivier,
Philippe Mathieu-Daudé
The MIPS n32 ABI is basically n64 with the address space (i.e. pointer
width) shrinked to 32 bits. Meanwhile the current code treats it as
o32-like based on TARGET_ABI_BITS, which causes problems with n32
syscalls utilizing 64-bit offsets, like pread64, affecting most (if not
all) recently built n32 binaries.
This partially solves issue #909 ("qemu-mipsn32(el) user mode emulator
fails to execute any recently built n32 binaries"); with this change
applied, the built qemu-mipsn32el is able to progress beyond the
pread64, and finish _dl_start_user for the "getting ld.so load libc.so"
case. The program later dies with SIGBUS, though, due to _dl_start_user
not maintaining stack alignment after removing ld.so itself from argv,
and qemu-user starting to enforce alignment recently, but that is
orthogonal to the issue here; the more common case of chrooting is
working, verified with my own-built Gentoo n32 sysroot. (Depending on
the exact ISA used, one may have to explicitly specify QEMU_CPU, which
is the case for my chroot.)
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/909
Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Andreas K. Hüttel <dilfridge@gentoo.org>
---
P.S. This patch is done with my Gentoo hat on, so I'm not using my
usual xen0n.name address. I'd like to add a mailmap entry for correct
shortlog display though, but it seems there's no category for "merely
preference" mappings yet. What should I do in this case?
linux-user/user-internals.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
index a8fdd6933b2..ee152ccfaa8 100644
--- a/linux-user/user-internals.h
+++ b/linux-user/user-internals.h
@@ -112,7 +112,7 @@ static inline int is_error(abi_long ret)
return (abi_ulong)ret >= (abi_ulong)(-4096);
}
-#if TARGET_ABI_BITS == 32
+#if (TARGET_ABI_BITS == 32) && !defined(TARGET_ABI_MIPSN32)
static inline uint64_t target_offset64(uint32_t word0, uint32_t word1)
{
#ifdef TARGET_WORDS_BIGENDIAN
@@ -121,7 +121,7 @@ static inline uint64_t target_offset64(uint32_t word0, uint32_t word1)
return ((uint64_t)word1 << 32) | word0;
#endif
}
-#else /* TARGET_ABI_BITS == 32 */
+#else /* TARGET_ABI_BITS == 32 && !defined(TARGET_ABI_MIPSN32) */
static inline uint64_t target_offset64(uint64_t word0, uint64_t word1)
{
return word0;
@@ -136,7 +136,7 @@ static inline int regpairs_aligned(void *cpu_env, int num)
{
return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
}
-#elif defined(TARGET_MIPS) && (TARGET_ABI_BITS == 32)
+#elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32)
static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
/*
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32
2022-03-20 5:22 [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32 WANG Xuerui
@ 2022-03-20 18:03 ` Richard Henderson
2022-03-20 22:08 ` Philippe Mathieu-Daudé
2022-03-20 22:20 ` Laurent Vivier
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2022-03-20 18:03 UTC (permalink / raw)
To: WANG Xuerui, qemu-devel
Cc: Andreas K . Hüttel, Laurent Vivier,
Philippe Mathieu-Daudé
On 3/19/22 22:22, WANG Xuerui wrote:
> The MIPS n32 ABI is basically n64 with the address space (i.e. pointer
> width) shrinked to 32 bits. Meanwhile the current code treats it as
> o32-like based on TARGET_ABI_BITS, which causes problems with n32
> syscalls utilizing 64-bit offsets, like pread64, affecting most (if not
> all) recently built n32 binaries.
>
> This partially solves issue #909 ("qemu-mipsn32(el) user mode emulator
> fails to execute any recently built n32 binaries"); with this change
> applied, the built qemu-mipsn32el is able to progress beyond the
> pread64, and finish _dl_start_user for the "getting ld.so load libc.so"
> case. The program later dies with SIGBUS, though, due to _dl_start_user
> not maintaining stack alignment after removing ld.so itself from argv,
> and qemu-user starting to enforce alignment recently, but that is
> orthogonal to the issue here; the more common case of chrooting is
> working, verified with my own-built Gentoo n32 sysroot. (Depending on
> the exact ISA used, one may have to explicitly specify QEMU_CPU, which
> is the case for my chroot.)
>
> Buglink:https://gitlab.com/qemu-project/qemu/-/issues/909
> Signed-off-by: WANG Xuerui<xen0n@gentoo.org>
> Cc: Laurent Vivier<laurent@vivier.eu>
> Cc: Philippe Mathieu-Daudé<f4bug@amsat.org>
> Cc: Jiaxun Yang<jiaxun.yang@flygoat.com>
> Cc: Andreas K. Hüttel<dilfridge@gentoo.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32
2022-03-20 5:22 [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32 WANG Xuerui
2022-03-20 18:03 ` Richard Henderson
@ 2022-03-20 22:08 ` Philippe Mathieu-Daudé
2022-03-20 22:20 ` Laurent Vivier
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-03-20 22:08 UTC (permalink / raw)
To: WANG Xuerui, qemu-devel
Cc: Andreas K . Hüttel, Laurent Vivier,
Philippe Mathieu-Daudé
On 20/3/22 06:22, WANG Xuerui wrote:
> The MIPS n32 ABI is basically n64 with the address space (i.e. pointer
> width) shrinked to 32 bits. Meanwhile the current code treats it as
> o32-like based on TARGET_ABI_BITS, which causes problems with n32
> syscalls utilizing 64-bit offsets, like pread64, affecting most (if not
> all) recently built n32 binaries.
>
> This partially solves issue #909 ("qemu-mipsn32(el) user mode emulator
> fails to execute any recently built n32 binaries"); with this change
> applied, the built qemu-mipsn32el is able to progress beyond the
> pread64, and finish _dl_start_user for the "getting ld.so load libc.so"
> case. The program later dies with SIGBUS, though, due to _dl_start_user
> not maintaining stack alignment after removing ld.so itself from argv,
> and qemu-user starting to enforce alignment recently, but that is
> orthogonal to the issue here; the more common case of chrooting is
> working, verified with my own-built Gentoo n32 sysroot. (Depending on
> the exact ISA used, one may have to explicitly specify QEMU_CPU, which
> is the case for my chroot.)
>
> Buglink: https://gitlab.com/qemu-project/qemu/-/issues/909
Very nice analysis there!
"Buglink" doesn't seem to match GitLab autoclose regexp:
https://docs.gitlab.com/ee/administration/issue_closing_pattern.html#change-the-issue-closing-pattern
> Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Andreas K. Hüttel <dilfridge@gentoo.org>
> ---
>
> P.S. This patch is done with my Gentoo hat on, so I'm not using my
> usual xen0n.name address. I'd like to add a mailmap entry for correct
> shortlog display though, but it seems there's no category for "merely
> preference" mappings yet. What should I do in this case?
The last section seems to match your case:
# Also list preferred name forms where people have changed their
# git author config, or had utf8/latin1 encoding issues.
> linux-user/user-internals.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32
2022-03-20 5:22 [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32 WANG Xuerui
2022-03-20 18:03 ` Richard Henderson
2022-03-20 22:08 ` Philippe Mathieu-Daudé
@ 2022-03-20 22:20 ` Laurent Vivier
2 siblings, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2022-03-20 22:20 UTC (permalink / raw)
To: WANG Xuerui, qemu-devel
Cc: Andreas K . Hüttel, Philippe Mathieu-Daudé
Le 20/03/2022 à 06:22, WANG Xuerui a écrit :
> The MIPS n32 ABI is basically n64 with the address space (i.e. pointer
> width) shrinked to 32 bits. Meanwhile the current code treats it as
> o32-like based on TARGET_ABI_BITS, which causes problems with n32
> syscalls utilizing 64-bit offsets, like pread64, affecting most (if not
> all) recently built n32 binaries.
>
> This partially solves issue #909 ("qemu-mipsn32(el) user mode emulator
> fails to execute any recently built n32 binaries"); with this change
> applied, the built qemu-mipsn32el is able to progress beyond the
> pread64, and finish _dl_start_user for the "getting ld.so load libc.so"
> case. The program later dies with SIGBUS, though, due to _dl_start_user
> not maintaining stack alignment after removing ld.so itself from argv,
> and qemu-user starting to enforce alignment recently, but that is
> orthogonal to the issue here; the more common case of chrooting is
> working, verified with my own-built Gentoo n32 sysroot. (Depending on
> the exact ISA used, one may have to explicitly specify QEMU_CPU, which
> is the case for my chroot.)
>
> Buglink: https://gitlab.com/qemu-project/qemu/-/issues/909
> Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Andreas K. Hüttel <dilfridge@gentoo.org>
> ---
>
> P.S. This patch is done with my Gentoo hat on, so I'm not using my
> usual xen0n.name address. I'd like to add a mailmap entry for correct
> shortlog display though, but it seems there's no category for "merely
> preference" mappings yet. What should I do in this case?
>
> linux-user/user-internals.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
Applied to my linux-user-for-7.0 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-20 22:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-20 5:22 [PATCH for-7.0] linux-user: Fix syscall parameter handling for MIPS n32 WANG Xuerui
2022-03-20 18:03 ` Richard Henderson
2022-03-20 22:08 ` Philippe Mathieu-Daudé
2022-03-20 22:20 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).