Skip to contentSkip to conversation

linux-user: Add translation for argument of msync()

PATCH Applied Helge Deller 4 participants 8 messages Dec 15, 2022 – Mar 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Add translation for argument of msync()

msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ between platforms, specifcally on alpha and hppa.

Add a target to host translation for those and wire up a nicer strace output.

This fixes the testsuite of the macaulay2 debian package with a hppa-linux guest on a x86-64 host.

linux-user/alpha/target_mman.h +4 -0
index cd6e3d70a6..051544f5ab 100644
@@ -3,6 +3,10 @@
 
 #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
 #include "../generic/target_mman.h"
 
 #endif
linux-user/generic/target_mman.h +13 -0
index 1436a3c543..32bf1a52d0 100644
@@ -89,4 +89,17 @@
 #define TARGET_MADV_DONTNEED_LOCKED 24
 #endif
 
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1
+#endif
+
+#ifndef TARGET_MS_INVALIDATE
+#define TARGET_MS_INVALIDATE 2
+#endif
+
+#ifndef TARGET_MS_SYNC
+#define TARGET_MS_SYNC 4
+#endif
+
 #endif
linux-user/hppa/target_mman.h +4 -0
index 66dd9f7941..f9b6b97032 100644
@@ -10,6 +10,10 @@
 #define TARGET_MADV_WIPEONFORK 71
 #define TARGET_MADV_KEEPONFORK 72
 
+#define TARGET_MS_SYNC 1
+#define TARGET_MS_ASYNC 2
+#define TARGET_MS_INVALIDATE 4
+
 #include "../generic/target_mman.h"
 
 #endif
linux-user/strace.list +1 -1
index a75101fca1..ac8f872371 100644
@@ -650,7 +650,7 @@
 { TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_msync
-{ TARGET_NR_msync, "msync" , NULL, NULL, NULL },
+{ TARGET_NR_msync, "msync" , "%s(%p,%u,%d)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_multiplexer
 { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL },
linux-user/syscall.c +11 -1
index d58e9b8d10..e541fbe09a 100644
@@ -22,6 +22,7 @@
 #include "qemu/path.h"
 #include "qemu/memfd.h"
 #include "qemu/queue.h"
+#include "target_mman.h"
 #include <elf.h>
 #include <endian.h>
 #include <grp.h>
@@ -7667,6 +7668,14 @@ static inline int target_to_host_mlockall_arg(int arg)
 }
 #endif
 
+static inline int target_to_host_msync_arg(abi_long arg)
+{
+    return ((arg & TARGET_MS_ASYNC) ? MS_ASYNC : 0) |
+           ((arg & TARGET_MS_INVALIDATE) ? MS_INVALIDATE : 0) |
+           ((arg & TARGET_MS_SYNC) ? MS_SYNC : 0) |
+           (arg & ~(TARGET_MS_ASYNC | TARGET_MS_INVALIDATE | TARGET_MS_SYNC));
+}
+
 #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) ||     \
      defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) ||  \
      defined(TARGET_NR_newfstatat))
@@ -10163,7 +10172,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         /* ??? msync/mlock/munlock are broken for softmmu.  */
 #ifdef TARGET_NR_msync
     case TARGET_NR_msync:
-        return get_errno(msync(g2h(cpu, arg1), arg2, arg3));
+        return get_errno(msync(g2h(cpu, arg1), arg2,
+                               target_to_host_msync_arg(arg3)));
 #endif
 #ifdef TARGET_NR_mlock
     case TARGET_NR_mlock:
#1 lore raw
Quoted 31 lines · Helge Deller

msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ between platforms, specifcally on alpha and hppa.

Add a target to host translation for those and wire up a nicer strace output.

This fixes the testsuite of the macaulay2 debian package with a hppa-linux guest on a x86-64 host.

linux-user/alpha/target_mman.h +4 -0
index cd6e3d70a6..051544f5ab 100644
@@ -3,6 +3,10 @@
 
  #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/generic/target_mman.h +0 -0
index 1436a3c543..32bf1a52d0 100644

linux-user/generic/target_mman.h line 94

Quoted 6 lines
linux-user/generic/target_mman.h +3 -0
@@ -89,4 +89,17 @@
  #define TARGET_MADV_DONTNEED_LOCKED 24
  #endif
 
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1

Hmm don't we want to keep the host flag instead?

   #define TARGET_MS_ASYNC MS_ASYNC

linux-user/generic/target_mman.h line 98

Quoted 4 lines
linux-user/generic/target_mman.h +4 -0
+#endif
+
+#ifndef TARGET_MS_INVALIDATE
+#define TARGET_MS_INVALIDATE 2

Ditto,

linux-user/generic/target_mman.h line 102

Quoted 4 lines
linux-user/generic/target_mman.h +4 -0
+#endif
+
+#ifndef TARGET_MS_SYNC
+#define TARGET_MS_SYNC 4

ditto.

LGTM otherwise.

Quoted 69 lines
linux-user/generic/target_mman.h +2 -0
+#endif
+
  #endif
linux-user/hppa/target_mman.h +4 -0
index 66dd9f7941..f9b6b97032 100644
@@ -10,6 +10,10 @@
  #define TARGET_MADV_WIPEONFORK 71
  #define TARGET_MADV_KEEPONFORK 72
 
+#define TARGET_MS_SYNC 1
+#define TARGET_MS_ASYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/strace.list +1 -1
index a75101fca1..ac8f872371 100644
@@ -650,7 +650,7 @@
  { TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_msync
-{ TARGET_NR_msync, "msync" , NULL, NULL, NULL },
+{ TARGET_NR_msync, "msync" , "%s(%p,%u,%d)", NULL, NULL },
  #endif
  #ifdef TARGET_NR_multiplexer
  { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL },
linux-user/syscall.c +11 -1
index d58e9b8d10..e541fbe09a 100644
@@ -22,6 +22,7 @@
  #include "qemu/path.h"
  #include "qemu/memfd.h"
  #include "qemu/queue.h"
+#include "target_mman.h"
  #include <elf.h>
  #include <endian.h>
  #include <grp.h>
@@ -7667,6 +7668,14 @@ static inline int target_to_host_mlockall_arg(int arg)
  }
  #endif
 
+static inline int target_to_host_msync_arg(abi_long arg)
+{
+    return ((arg & TARGET_MS_ASYNC) ? MS_ASYNC : 0) |
+           ((arg & TARGET_MS_INVALIDATE) ? MS_INVALIDATE : 0) |
+           ((arg & TARGET_MS_SYNC) ? MS_SYNC : 0) |
+           (arg & ~(TARGET_MS_ASYNC | TARGET_MS_INVALIDATE | TARGET_MS_SYNC));
+}
+
  #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) ||     \
       defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) ||  \
       defined(TARGET_NR_newfstatat))
@@ -10163,7 +10172,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
          /* ??? msync/mlock/munlock are broken for softmmu.  */
  #ifdef TARGET_NR_msync
      case TARGET_NR_msync:
-        return get_errno(msync(g2h(cpu, arg1), arg2, arg3));
+        return get_errno(msync(g2h(cpu, arg1), arg2,
+                               target_to_host_msync_arg(arg3)));
  #endif
  #ifdef TARGET_NR_mlock
      case TARGET_NR_mlock:
#2 lore raw
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Helge Deller

msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ between platforms, specifcally on alpha and hppa.

Add a target to host translation for those and wire up a nicer strace output.

This fixes the testsuite of the macaulay2 debian package with a hppa-linux guest on a x86-64 host.

linux-user/alpha/target_mman.h +4 -0
index cd6e3d70a6..051544f5ab 100644
@@ -3,6 +3,10 @@
 
   #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
   #include "../generic/target_mman.h"
 
   #endif
linux-user/generic/target_mman.h +0 -0
index 1436a3c543..32bf1a52d0 100644
@@ -89,4 +89,17 @@
   #define TARGET_MADV_DONTNEED_LOCKED 24
   #endif
 
Quoted 7 lines

linux-user/generic/target_mman.h line 94

Quoted 3 lines
linux-user/generic/target_mman.h +3 -0
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1

Hmm don't we want to keep the host flag instead?

   #define TARGET_MS_ASYNC MS_ASYNC

Yes, that would be possible, but the value is the same. In the <arch>/*h files you usually want to have numerical values which makes it easier to search for conversion bugs.

I'd prefer to keep it as is, it's done for the other files/values like that.

Helge

Quoted 87 lines

linux-user/generic/target_mman.h line 98

Quoted 5 lines
linux-user/generic/target_mman.h +4 -0
+#endif
+
+#ifndef TARGET_MS_INVALIDATE
+#define TARGET_MS_INVALIDATE 2

Ditto,

linux-user/generic/target_mman.h line 102

Quoted 4 lines
linux-user/generic/target_mman.h +4 -0
+#endif
+
+#ifndef TARGET_MS_SYNC
+#define TARGET_MS_SYNC 4

ditto.

LGTM otherwise.

Quoted 69 lines
linux-user/generic/target_mman.h +2 -0
+#endif
+
   #endif
linux-user/hppa/target_mman.h +4 -0
index 66dd9f7941..f9b6b97032 100644
@@ -10,6 +10,10 @@
   #define TARGET_MADV_WIPEONFORK 71
   #define TARGET_MADV_KEEPONFORK 72
 
+#define TARGET_MS_SYNC 1
+#define TARGET_MS_ASYNC 2
+#define TARGET_MS_INVALIDATE 4
+
   #include "../generic/target_mman.h"
 
   #endif
linux-user/strace.list +1 -1
index a75101fca1..ac8f872371 100644
@@ -650,7 +650,7 @@
   { TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL },
   #endif
   #ifdef TARGET_NR_msync
-{ TARGET_NR_msync, "msync" , NULL, NULL, NULL },
+{ TARGET_NR_msync, "msync" , "%s(%p,%u,%d)", NULL, NULL },
   #endif
   #ifdef TARGET_NR_multiplexer
   { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL },
linux-user/syscall.c +9 -0
index d58e9b8d10..e541fbe09a 100644
@@ -22,6 +22,7 @@
   #include "qemu/path.h"
   #include "qemu/memfd.h"
   #include "qemu/queue.h"
+#include "target_mman.h"
   #include <elf.h>
   #include <endian.h>
   #include <grp.h>
@@ -7667,6 +7668,14 @@ static inline int target_to_host_mlockall_arg(int arg)
   }
   #endif
 
+static inline int target_to_host_msync_arg(abi_long arg)
+{
+    return ((arg & TARGET_MS_ASYNC) ? MS_ASYNC : 0) |
+           ((arg & TARGET_MS_INVALIDATE) ? MS_INVALIDATE : 0) |
+           ((arg & TARGET_MS_SYNC) ? MS_SYNC : 0) |
+           (arg & ~(TARGET_MS_ASYNC | TARGET_MS_INVALIDATE | TARGET_MS_SYNC));
+}
+
   #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) ||     \
        defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) ||  \
        defined(TARGET_NR_newfstatat))
@@ -10163,7 +10172,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
           /* ??? msync/mlock/munlock are broken for softmmu.  */
   #ifdef TARGET_NR_msync

      case TARGET_NR_msync:
-        return get_errno(msync(g2h(cpu, arg1), arg2, arg3)); +        return get_errno(msync(g2h(cpu, arg1), arg2,
+                               target_to_host_msync_arg(arg3))); #endif
  #ifdef TARGET_NR_mlock
      case TARGET_NR_mlock:

#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 21 lines
linux-user/alpha/target_mman.h +4 -0
@@ -3,6 +3,10 @@
 
   #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
   #include "../generic/target_mman.h"
 
   #endif
linux-user/generic/target_mman.h +0 -0
index 1436a3c543..32bf1a52d0 100644
@@ -89,4 +89,17 @@
   #define TARGET_MADV_DONTNEED_LOCKED 24
   #endif
 
Quoted 7 lines

linux-user/generic/target_mman.h line 94

Quoted 3 lines
linux-user/generic/target_mman.h +3 -0
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1

Hmm don't we want to keep the host flag instead?

   #define TARGET_MS_ASYNC MS_ASYNC

No. What if the host has an odd value, like Alpha.

r~

#4 lore raw
Quoted 28 lines · Richard Henderson
Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 18 lines
linux-user/alpha/target_mman.h +4 -0
@@ -3,6 +3,10 @@
 
   #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
   #include "../generic/target_mman.h"
 
   #endif
linux-user/generic/target_mman.h +0 -0
index 1436a3c543..32bf1a52d0 100644

linux-user/generic/target_mman.h line 94

Quoted 6 lines
linux-user/generic/target_mman.h +3 -0
@@ -89,4 +89,17 @@
   #define TARGET_MADV_DONTNEED_LOCKED 24
   #endif
 
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1

Hmm don't we want to keep the host flag instead?

Quoted 3 lines
Quoted 1 line

    #define TARGET_MS_ASYNC MS_ASYNC

No.  What if the host has an odd value, like Alpha.

But TARGET_MS_ASYNC would be defined in linux-user/alpha/target_mman.h so this path won't apply... What am I missing?

#5 lore raw

Host!

r~

Quoted 37 lines · On Thu, 15 Dec 2022, 12:58 Philippe Mathieu-Daudé, <[email protected]> wrote:
Quoted 29 lines · Richard Henderson
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 19 lines
linux-user/alpha/target_mman.h +4 -0
@@ -3,6 +3,10 @@
 
  #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/generic/target_mman.h +0 -0
index 1436a3c543..32bf1a52d0 100644

linux-user/generic/target_mman.h line 94

Quoted 6 lines
linux-user/generic/target_mman.h +3 -0
@@ -89,4 +89,17 @@
  #define TARGET_MADV_DONTNEED_LOCKED 24
  #endif
 
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1

Hmm don't we want to keep the host flag instead?

Quoted 3 lines
Quoted 1 line
    #define TARGET_MS_ASYNC MS_ASYNC

No. What if the host has an odd value, like Alpha.

But TARGET_MS_ASYNC would be defined in linux-user/alpha/target_mman.h so this path won't apply... What am I missing?

Reviewed-by on v1 1/1
#6 lore raw
In reply to Helge Deller

Le 15/12/2022 à 08:27, Helge Deller a écrit :

Quoted 105 lines

msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ between platforms, specifcally on alpha and hppa.

Add a target to host translation for those and wire up a nicer strace output.

This fixes the testsuite of the macaulay2 debian package with a hppa-linux guest on a x86-64 host.

linux-user/alpha/target_mman.h +4 -0
index cd6e3d70a6..051544f5ab 100644
@@ -3,6 +3,10 @@
 
  #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/generic/target_mman.h +13 -0
index 1436a3c543..32bf1a52d0 100644
@@ -89,4 +89,17 @@
  #define TARGET_MADV_DONTNEED_LOCKED 24
  #endif
 
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1
+#endif
+
+#ifndef TARGET_MS_INVALIDATE
+#define TARGET_MS_INVALIDATE 2
+#endif
+
+#ifndef TARGET_MS_SYNC
+#define TARGET_MS_SYNC 4
+#endif
+
  #endif
linux-user/hppa/target_mman.h +4 -0
index 66dd9f7941..f9b6b97032 100644
@@ -10,6 +10,10 @@
  #define TARGET_MADV_WIPEONFORK 71
  #define TARGET_MADV_KEEPONFORK 72
 
+#define TARGET_MS_SYNC 1
+#define TARGET_MS_ASYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/strace.list +1 -1
index a75101fca1..ac8f872371 100644
@@ -650,7 +650,7 @@
  { TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_msync
-{ TARGET_NR_msync, "msync" , NULL, NULL, NULL },
+{ TARGET_NR_msync, "msync" , "%s(%p,%u,%d)", NULL, NULL },
  #endif
  #ifdef TARGET_NR_multiplexer
  { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL },
linux-user/syscall.c +9 -0
index d58e9b8d10..e541fbe09a 100644
@@ -22,6 +22,7 @@
  #include "qemu/path.h"
  #include "qemu/memfd.h"
  #include "qemu/queue.h"
+#include "target_mman.h"
  #include <elf.h>
  #include <endian.h>
  #include <grp.h>
@@ -7667,6 +7668,14 @@ static inline int target_to_host_mlockall_arg(int arg)
  }
  #endif
 
+static inline int target_to_host_msync_arg(abi_long arg)
+{
+    return ((arg & TARGET_MS_ASYNC) ? MS_ASYNC : 0) |
+           ((arg & TARGET_MS_INVALIDATE) ? MS_INVALIDATE : 0) |
+           ((arg & TARGET_MS_SYNC) ? MS_SYNC : 0) |
+           (arg & ~(TARGET_MS_ASYNC | TARGET_MS_INVALIDATE | TARGET_MS_SYNC));
+}
+
  #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) ||     \
       defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) ||  \
       defined(TARGET_NR_newfstatat))

linux-user/syscall.c static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, · line 10179

Quoted 9 lines
linux-user/syscall.c +2 -1
@@ -10163,7 +10172,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
          /* ??? msync/mlock/munlock are broken for softmmu.  */
  #ifdef TARGET_NR_msync
      case TARGET_NR_msync:
-        return get_errno(msync(g2h(cpu, arg1), arg2, arg3));
+        return get_errno(msync(g2h(cpu, arg1), arg2,
+                               target_to_host_msync_arg(arg3)));
  #endif
  #ifdef TARGET_NR_mlock
      case TARGET_NR_mlock:
#7 lore raw
In reply to Helge Deller

Le 15/12/2022 à 08:27, Helge Deller a écrit :

Quoted 105 lines

msync() uses the flags MS_ASYNC, MS_INVALIDATE and MS_SYNC, which differ between platforms, specifcally on alpha and hppa.

Add a target to host translation for those and wire up a nicer strace output.

This fixes the testsuite of the macaulay2 debian package with a hppa-linux guest on a x86-64 host.

linux-user/alpha/target_mman.h +4 -0
index cd6e3d70a6..051544f5ab 100644
@@ -3,6 +3,10 @@
 
  #define TARGET_MADV_DONTNEED 6
 
+#define TARGET_MS_ASYNC 1
+#define TARGET_MS_SYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/generic/target_mman.h +13 -0
index 1436a3c543..32bf1a52d0 100644
@@ -89,4 +89,17 @@
  #define TARGET_MADV_DONTNEED_LOCKED 24
  #endif
 
+
+#ifndef TARGET_MS_ASYNC
+#define TARGET_MS_ASYNC 1
+#endif
+
+#ifndef TARGET_MS_INVALIDATE
+#define TARGET_MS_INVALIDATE 2
+#endif
+
+#ifndef TARGET_MS_SYNC
+#define TARGET_MS_SYNC 4
+#endif
+
  #endif
linux-user/hppa/target_mman.h +4 -0
index 66dd9f7941..f9b6b97032 100644
@@ -10,6 +10,10 @@
  #define TARGET_MADV_WIPEONFORK 71
  #define TARGET_MADV_KEEPONFORK 72
 
+#define TARGET_MS_SYNC 1
+#define TARGET_MS_ASYNC 2
+#define TARGET_MS_INVALIDATE 4
+
  #include "../generic/target_mman.h"
 
  #endif
linux-user/strace.list +1 -1
index a75101fca1..ac8f872371 100644
@@ -650,7 +650,7 @@
  { TARGET_NR_msgsnd, "msgsnd" , NULL, NULL, NULL },
  #endif
  #ifdef TARGET_NR_msync
-{ TARGET_NR_msync, "msync" , NULL, NULL, NULL },
+{ TARGET_NR_msync, "msync" , "%s(%p,%u,%d)", NULL, NULL },
  #endif
  #ifdef TARGET_NR_multiplexer
  { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL },
linux-user/syscall.c +9 -0
index d58e9b8d10..e541fbe09a 100644
@@ -22,6 +22,7 @@
  #include "qemu/path.h"
  #include "qemu/memfd.h"
  #include "qemu/queue.h"
+#include "target_mman.h"
  #include <elf.h>
  #include <endian.h>
  #include <grp.h>
@@ -7667,6 +7668,14 @@ static inline int target_to_host_mlockall_arg(int arg)
  }
  #endif
 
+static inline int target_to_host_msync_arg(abi_long arg)
+{
+    return ((arg & TARGET_MS_ASYNC) ? MS_ASYNC : 0) |
+           ((arg & TARGET_MS_INVALIDATE) ? MS_INVALIDATE : 0) |
+           ((arg & TARGET_MS_SYNC) ? MS_SYNC : 0) |
+           (arg & ~(TARGET_MS_ASYNC | TARGET_MS_INVALIDATE | TARGET_MS_SYNC));
+}
+
  #if (defined(TARGET_NR_stat64) || defined(TARGET_NR_lstat64) ||     \
       defined(TARGET_NR_fstat64) || defined(TARGET_NR_fstatat64) ||  \
       defined(TARGET_NR_newfstatat))

linux-user/syscall.c static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, · line 10179

Quoted 9 lines
linux-user/syscall.c +2 -1
@@ -10163,7 +10172,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
          /* ??? msync/mlock/munlock are broken for softmmu.  */
  #ifdef TARGET_NR_msync
      case TARGET_NR_msync:
-        return get_errno(msync(g2h(cpu, arg1), arg2, arg3));
+        return get_errno(msync(g2h(cpu, arg1), arg2,
+                               target_to_host_msync_arg(arg3)));
  #endif
  #ifdef TARGET_NR_mlock
      case TARGET_NR_mlock:

Applied to my linux-user-for-8.0 branch.

Thanks,
Laurent