Skip to contentSkip to conversation

linux-user/syscall: fix target_msqid_ds time fields order

PATCH In review Max Filippov 3 participants 3 messages Mar 29, 2024 – Aug 8

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user/syscall: fix target_msqid_ds time fields order

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.

---
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(-)
linux-user/syscall.c +15 -5
index d9bfd31c1cad..781ed14bc613 100644
@@ -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;
Signature · 1 line
2.39.2
#1 lore raw
Quoted 8 lines · Max Filippov

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.

Just come across this old patch, is it not needed anymore or has it been lost? (I realize the current code uses target_time64_t instead of abi_ulong, so probably not needed now)

Thanks,

/mjt

Quoted 44 lines

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(-)
linux-user/syscall.c +15 -5
index d9bfd31c1cad..781ed14bc613 100644
@@ -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;
#2 lore raw
Quoted 11 lines · Michael Tokarev
Quoted 8 lines · Max Filippov

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.

Just come across this old patch, is it not needed anymore or has it been lost?

Yes, seems to have been lost.

Quoted 2 lines

(I realize the current code uses target_time64_t instead of abi_ulong, so probably not needed now)

Right. Unless we have an alignment problem with target_time64_t on 32-bit (which seems ok).

Helge

Quoted 46 lines
Quoted 44 lines

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(-)
linux-user/syscall.c +0 -0
index d9bfd31c1cad..781ed14bc613 100644
@@ -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

linux-user/syscall.c +10 -0
+#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;

linux-user/syscall.c +5 -0
+#endif
+#else
+    abi_ulong msg_stime;
+    abi_ulong msg_rtime;
+    abi_ulong msg_ctime;

  #endif
      abi_ulong __msg_cbytes;
      abi_ulong msg_qnum;