diff mbox series

[v2] linux-user/syscall: fix target_msqid_ds time fields order

Message ID 20240329223653.155786-1-jcmvbkbc@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] linux-user/syscall: fix target_msqid_ds time fields order | expand

Commit Message

Max Filippov March 29, 2024, 10:36 p.m. UTC
target_msqid_ds::msg_*time field pairs are reversed on 32-bit TARGET_PPC
and TARGET_SPARC and on big-endian TARGET_MIPS and TARGET_XTENSA.
Fix the order to match the kernel definitions.
The issue is spotted by the libc-test http://nsz.repo.hu/git/?p=libc-test
on big-endian xtensa core.

Cc: qemu-stable@nongnu.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
Changes v1->v2:
- split into a separate patch
- add PPC, SPARC and big-endian MIPS

 linux-user/syscall.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d9bfd31c1cad..781ed14bc613 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4113,17 +4113,27 @@  static inline abi_long do_semtimedop(int semid,
 struct target_msqid_ds
 {
     struct target_ipc_perm msg_perm;
-    abi_ulong msg_stime;
 #if TARGET_ABI_BITS == 32
+#if defined(TARGET_PPC) || defined(TARGET_SPARC) || \
+    (TARGET_BIG_ENDIAN && (defined(TARGET_MIPS) || defined(TARGET_XTENSA)))
+    abi_ulong __unused1;
+    abi_ulong msg_stime;
+    abi_ulong __unused2;
+    abi_ulong msg_rtime;
+    abi_ulong __unused3;
+    abi_ulong msg_ctime;
+#else
+    abi_ulong msg_stime;
     abi_ulong __unused1;
-#endif
     abi_ulong msg_rtime;
-#if TARGET_ABI_BITS == 32
     abi_ulong __unused2;
-#endif
     abi_ulong msg_ctime;
-#if TARGET_ABI_BITS == 32
     abi_ulong __unused3;
+#endif
+#else
+    abi_ulong msg_stime;
+    abi_ulong msg_rtime;
+    abi_ulong msg_ctime;
 #endif
     abi_ulong __msg_cbytes;
     abi_ulong msg_qnum;