Byte-swapping issue on qemu-user for sparc64 guest

John Paul Adrian Glaubitz posted 1 patch 1 year, 2 months ago
Failed in applying to current master (apply log)
Byte-swapping issue on qemu-user for sparc64 guest
Posted by John Paul Adrian Glaubitz 1 year, 2 months ago
Hi!

There is an unaddressed issue in qemu-user [1] which results in getresuid()
returning an incorrect UID due to a byte-swapping issue on sparc64.

This issue is fixed by the patch below which was suggested by Phillippe
Mathieu-Daudé, but the corresponding line [2] has not been patched yet.

Could anyone step up and fix the bug?

Thanks,
Adrian

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 77864de57f..4d4b4a22e8 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -61,7 +61,7 @@
  
  #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
      || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
-     || defined(TARGET_SPARC) \
+     || (defined(TARGET_SPARC) && defined(TARGET_ABI32)) \
      || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
      /* 16 bit uid wrappers emulation */
  #define USE_UID16

> [1] https://gitlab.com/qemu-project/qemu/-/issues/1394
> [2] https://gitlab.com/qemu-project/qemu/-/blob/master/linux-user/syscall_defs.h#L64

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Re: Byte-swapping issue on qemu-user for sparc64 guest
Posted by Thomas Huth 1 year, 2 months ago
On 10/02/2023 16.23, John Paul Adrian Glaubitz wrote:
> Hi!
> 
> There is an unaddressed issue in qemu-user [1] which results in getresuid()
> returning an incorrect UID due to a byte-swapping issue on sparc64.

Oh, there are still people out there using qemu-user on sparc64 hosts? ... 
that reminds me of another outstanding issue which might occur there:

  https://mail.gnu.org/archive/html/qemu-devel/2021-02/msg04240.html

... in case someone has time for fixing this ... (I unfortunately never 
found enough spare time again to revisit the issue).

  Thomas
Re: Byte-swapping issue on qemu-user for sparc64 guest
Posted by John Paul Adrian Glaubitz 1 year, 2 months ago
Hi Thomas!

On Fri, 2023-02-10 at 16:52 +0100, Thomas Huth wrote:
> On 10/02/2023 16.23, John Paul Adrian Glaubitz wrote:
> > Hi!
> > 
> > There is an unaddressed issue in qemu-user [1] which results in getresuid()
> > returning an incorrect UID due to a byte-swapping issue on sparc64.
> 
> Oh, there are still people out there using qemu-user on sparc64 hosts? ... 

This is about running sparc64 binaries on x86_64.

> that reminds me of another outstanding issue which might occur there:
> 
>   https://mail.gnu.org/archive/html/qemu-devel/2021-02/msg04240.html
> 
> ... in case someone has time for fixing this ... (I unfortunately never 
> found enough spare time again to revisit the issue).

We're still maintaining a sparc64 port in Debian, FWIW.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Re: Byte-swapping issue on qemu-user for sparc64 guest
Posted by Philippe Mathieu-Daudé 1 year, 2 months ago
On 10/2/23 16:23, John Paul Adrian Glaubitz wrote:
> Hi!
> 
> There is an unaddressed issue in qemu-user [1] which results in getresuid()
> returning an incorrect UID due to a byte-swapping issue on sparc64.
> 
> This issue is fixed by the patch below which was suggested by Phillippe
> Mathieu-Daudé, but the corresponding line [2] has not been patched yet.
> 
> Could anyone step up and fix the bug?

Sorry Adrian, this is in my TODO list, but I couldn't find the time to
write a good commit description to this fix yet :~(

> Thanks,
> Adrian
> 
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 77864de57f..4d4b4a22e8 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -61,7 +61,7 @@
>    
>    #if (defined(TARGET_I386) && defined(TARGET_ABI32)) \
>        || (defined(TARGET_ARM) && defined(TARGET_ABI32)) \
> -     || defined(TARGET_SPARC) \
> +     || (defined(TARGET_SPARC) && defined(TARGET_ABI32)) \
>        || defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
>        /* 16 bit uid wrappers emulation */
>    #define USE_UID16
> 
>> [1] https://gitlab.com/qemu-project/qemu/-/issues/1394
>> [2] https://gitlab.com/qemu-project/qemu/-/blob/master/linux-user/syscall_defs.h#L64
>