Skip to contentSkip to conversation

linux-user: Fix strace output for s390x mmap()

PATCH In review Ilya Leoshkevich 4 participants 6 messages Nov 20, 2024 – Nov 22, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user: Fix strace output for s390x mmap()

print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this
pattern: it does not have mmap2(), but mmap() still receives arguments via memory.

Fix by sharing the detection logic between syscall.c and strace.c.

Fixes d971040c2d16 ("linux-user: Fix strace output for old_mmap")

---

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Share the detection logic between syscall.c and strace.c

          (Richard).
 linux-user/strace.c       | 2 +-
 linux-user/syscall.c      | 5 +----
 linux-user/syscall_defs.h | 7 +++++++
 3 files changed, 9 insertions(+), 5 deletions(-)
linux-user/strace.c +1 -1
index b70eadc19ef..9c55f39b095 100644
@@ -3971,7 +3971,7 @@ print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
 {
     return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
                            arg4, arg5,
-#if defined(TARGET_NR_mmap2)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP
                             true
 #else
                             false
linux-user/syscall.c +1 -4
index 0279f235768..1ce4c79784f 100644
@@ -10588,10 +10588,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         return ret;
 #ifdef TARGET_NR_mmap
     case TARGET_NR_mmap:
-#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
-    (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \
-    defined(TARGET_M68K) || defined(TARGET_MICROBLAZE) \
-    || defined(TARGET_S390X)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP
         {
             abi_ulong *v;
             abi_ulong v1, v2, v3, v4, v5, v6;
linux-user/syscall_defs.h +7 -0
index 0e08dfae3e4..faad9147c91 100644
@@ -2766,4 +2766,11 @@ struct target_open_how_ver0 {
 #define RESOLVE_NO_SYMLINKS     0x04
 #endif
 
+#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
+    (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \
+    defined(TARGET_M68K) || defined(TARGET_MICROBLAZE) || \
+    defined(TARGET_S390X)
+#define TARGET_ARCH_WANT_SYS_OLD_MMAP
+#endif
+
 #endif
Signature · 1 line
2.47.0
#1 lore raw
Quoted 27 lines · Ilya Leoshkevich

print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this
pattern: it does not have mmap2(), but mmap() still receives arguments via memory.

Fix by sharing the detection logic between syscall.c and strace.c.

Fixes d971040c2d16 ("linux-user: Fix strace output for old_mmap")

---

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Share the detection logic between syscall.c and strace.c

           (Richard).
  linux-user/strace.c       | 2 +-
  linux-user/syscall.c      | 5 +----
  linux-user/syscall_defs.h | 7 +++++++
  3 files changed, 9 insertions(+), 5 deletions(-)
linux-user/strace.c +0 -0
index b70eadc19ef..9c55f39b095 100644

linux-user/strace.c print_mmap(CPUArchState *cpu_env, const struct syscallname *name, · line 3974

Quoted 5 lines
linux-user/strace.c +1 -1
@@ -3971,7 +3971,7 @@ print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
  {
      return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
                             arg4, arg5,
-#if defined(TARGET_NR_mmap2)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP

We still want to print for mmap2, so:

  #if defined(TARGET_NR_mmap2) || defined(TARGET_ARCH_WANT_SYS_OLD_MMAP)
Quoted 35 lines
linux-user/strace.c +0 -0
                              true
  #else
                              false
linux-user/syscall.c +1 -4
index 0279f235768..1ce4c79784f 100644
@@ -10588,10 +10588,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
          return ret;
  #ifdef TARGET_NR_mmap
      case TARGET_NR_mmap:
-#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
-    (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \
-    defined(TARGET_M68K) || defined(TARGET_MICROBLAZE) \
-    || defined(TARGET_S390X)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP
          {
              abi_ulong *v;
              abi_ulong v1, v2, v3, v4, v5, v6;
linux-user/syscall_defs.h +7 -0
index 0e08dfae3e4..faad9147c91 100644
@@ -2766,4 +2766,11 @@ struct target_open_how_ver0 {
  #define RESOLVE_NO_SYMLINKS     0x04
  #endif
 
+#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
+    (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \
+    defined(TARGET_M68K) || defined(TARGET_MICROBLAZE) || \
+    defined(TARGET_S390X)
+#define TARGET_ARCH_WANT_SYS_OLD_MMAP
+#endif
+
  #endif
#3 lore raw
In reply to iii
Quoted 44 lines · iii
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 27 lines · Ilya Leoshkevich

print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this
pattern: it does not have mmap2(), but mmap() still receives arguments via memory.

Fix by sharing the detection logic between syscall.c and strace.c.

Fixes d971040c2d16 ("linux-user: Fix strace output for old_mmap")

---

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Share the detection logic between syscall.c and strace.c (Richard).

  linux-user/strace.c       | 2 +-
  linux-user/syscall.c      | 5 +----
  linux-user/syscall_defs.h | 7 +++++++

  3 files changed, 9 insertions(+), 5 deletions(-)
linux-user/strace.c +0 -0
index b70eadc19ef..9c55f39b095 100644

linux-user/strace.c print_mmap(CPUArchState *cpu_env, const struct · line 3975

Quoted 6 lines
linux-user/strace.c +1 -1
@@ -3971,7 +3971,7 @@ print_mmap(CPUArchState *cpu_env, const struct 
 syscallname *name,
   {
       return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
                              arg4, arg5,
-#if defined(TARGET_NR_mmap2)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP

We still want to print for mmap2, so:

Quoted 5 lines

  #if defined(TARGET_NR_mmap2) || defined(TARGET_ARCH_WANT_SYS_OLD_MMAP)

Quoted 3 lines

                              true
  #else
                              false

Quoted 8 lines

mmap2() has its own flow from what I can see:

print_mmap2()
  print_mmap_both(..., is_old_mmap=false)

It should not call print_mmap(), which I'm changing here.

[...]

If so, better to clean that in a previous patch.

Cc'ing Helge since I'm a bit confused by commit d971040c2d intent ("linux-user: Fix strace output for old_mmap").

#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 27 lines · Ilya Leoshkevich

print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this
pattern: it does not have mmap2(), but mmap() still receives arguments via memory.

Fix by sharing the detection logic between syscall.c and strace.c.

Fixes d971040c2d16 ("linux-user: Fix strace output for old_mmap")

---

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Share the detection logic between syscall.c and strace.c

           (Richard).
  linux-user/strace.c       | 2 +-
  linux-user/syscall.c      | 5 +----
  linux-user/syscall_defs.h | 7 +++++++
  3 files changed, 9 insertions(+), 5 deletions(-)
linux-user/strace.c +0 -0
index b70eadc19ef..9c55f39b095 100644

linux-user/strace.c print_mmap(CPUArchState *cpu_env, const struct · line 3975

Quoted 6 lines
linux-user/strace.c +1 -1
@@ -3971,7 +3971,7 @@ print_mmap(CPUArchState *cpu_env, const struct 
 syscallname *name,
  {
      return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
                             arg4, arg5,
-#if defined(TARGET_NR_mmap2)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP

We still want to print for mmap2, so:

Quoted 6 lines

#if defined(TARGET_NR_mmap2) ||
defined(TARGET_ARCH_WANT_SYS_OLD_MMAP)

Quoted 3 lines
linux-user/strace.c +0 -0
                              true
  #else

false

mmap2() has its own flow from what I can see:

print_mmap2()
print_mmap_both(..., is_old_mmap=false)

It should not call print_mmap(), which I'm changing here.

[...]

#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 47 lines · Philippe Mathieu-Daudé
Quoted 46 lines · iii
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 27 lines · Ilya Leoshkevich

print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this
pattern: it does not have mmap2(), but mmap() still receives arguments via memory.

Fix by sharing the detection logic between syscall.c and strace.c.

Fixes d971040c2d16 ("linux-user: Fix strace output for old_mmap")

---

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Share the detection logic between syscall.c and strace.c (Richard).

  linux-user/strace.c       | 2 +-
  linux-user/syscall.c      | 5 +----
  linux-user/syscall_defs.h | 7 +++++++

  3 files changed, 9 insertions(+), 5 deletions(-)
linux-user/strace.c +0 -0
index b70eadc19ef..9c55f39b095 100644

linux-user/strace.c print_mmap(CPUArchState *cpu_env, const struct · line 3975

Quoted 6 lines
linux-user/strace.c +1 -1
@@ -3971,7 +3971,7 @@ print_mmap(CPUArchState *cpu_env, const struct 
 syscallname *name,
   {
       return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
                              arg4, arg5,
-#if defined(TARGET_NR_mmap2)
+#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP

We still want to print for mmap2, so:

Quoted 5 lines

  #if defined(TARGET_NR_mmap2) || defined(TARGET_ARCH_WANT_SYS_OLD_MMAP)

Quoted 3 lines

                              true
  #else
                              false

mmap2() has its own flow from what I can see:

Quoted 8 lines
Quoted 6 lines

print_mmap2()
  print_mmap_both(..., is_old_mmap=false)

It should not call print_mmap(), which I'm changing here.

[...]

If so, better to clean that in a previous patch.

Sorry, I'm confused. What previous patch are you referring to?

Quoted 2 lines

Cc'ing Helge since I'm a bit confused by commit d971040c2d intent ("linux-user: Fix strace output for old_mmap").

My understanding of the Helge's idea is that "defined(TARGET_NR_mmap2)" is true if, and only if, mmap() takes arguments via memory.

Reviewed-by on v2 1/1
#5 lore raw
In reply to Ilya Leoshkevich
Quoted 11 lines · Ilya Leoshkevich

print_mmap() assumes that mmap() receives arguments via memory if mmap2() is present. s390x (as opposed to s390) does not fit this
pattern: it does not have mmap2(), but mmap() still receives arguments via memory.

Fix by sharing the detection logic between syscall.c and strace.c.

Fixes d971040c2d16 ("linux-user: Fix strace output for old_mmap")
Quoted 5 lines

---

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Share the detection logic between syscall.c and strace.c

           (Richard).

and queued.

r~