[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/28] linux-user: Add translation for argument of msync()
From: |
Laurent Vivier |
Subject: |
[PULL 12/28] linux-user: Add translation for argument of msync() |
Date: |
Fri, 10 Mar 2023 23:09:11 +0100 |
From: Helge Deller <deller@gmx.de>
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.
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <Y5rMcts4qe15RaVN@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/alpha/target_mman.h | 4 ++++
linux-user/generic/target_mman.h | 13 +++++++++++++
linux-user/hppa/target_mman.h | 4 ++++
linux-user/strace.list | 2 +-
linux-user/syscall.c | 12 +++++++++++-
5 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/linux-user/alpha/target_mman.h b/linux-user/alpha/target_mman.h
index cd6e3d70a604..051544f5abd8 100644
--- a/linux-user/alpha/target_mman.h
+++ b/linux-user/alpha/target_mman.h
@@ -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
diff --git a/linux-user/generic/target_mman.h b/linux-user/generic/target_mman.h
index 1436a3c54308..32bf1a52d07e 100644
--- a/linux-user/generic/target_mman.h
+++ b/linux-user/generic/target_mman.h
@@ -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
diff --git a/linux-user/hppa/target_mman.h b/linux-user/hppa/target_mman.h
index 66dd9f79414e..f9b6b9703255 100644
--- a/linux-user/hppa/target_mman.h
+++ b/linux-user/hppa/target_mman.h
@@ -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
diff --git a/linux-user/strace.list b/linux-user/strace.list
index f776c73fa04c..c7808ea118f9 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -656,7 +656,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 },
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 05c81079e745..dad2c3312032 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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>
@@ -7612,6 +7613,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))
@@ -10128,7 +10137,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.39.2
- [PULL 27/28] linux-user/sparc: Handle tag overflow traps, (continued)
- [PULL 27/28] linux-user/sparc: Handle tag overflow traps, Laurent Vivier, 2023/03/08
- [PULL 19/28] linux-user/sparc: Handle software breakpoint trap, Laurent Vivier, 2023/03/08
- [PULL 16/28] linux-user/sparc: Use TT_TRAP for flush windows, Laurent Vivier, 2023/03/08
- [PULL 20/28] linux-user/sparc: Handle division by zero traps, Laurent Vivier, 2023/03/08
- Re: [PULL 00/28] Linux user for 8.0 patches, Peter Maydell, 2023/03/10
- [PULL 00/28] Linux user for 8.0 patches, Laurent Vivier, 2023/03/10
- [PULL 01/28] linux-user: Fix access to /proc/self/exe, Laurent Vivier, 2023/03/10
- [PULL 08/28] linux-user: Provide print_raw_param64() for 64-bit values, Laurent Vivier, 2023/03/10
- [PULL 07/28] linux-user: Fix brk() to release pages, Laurent Vivier, 2023/03/10
- [PULL 05/28] linux-user: add support for xtensa FDPIC, Laurent Vivier, 2023/03/10
- [PULL 12/28] linux-user: Add translation for argument of msync(),
Laurent Vivier <=
- [PULL 03/28] linux-user: add target to host netlink conversions, Laurent Vivier, 2023/03/10
- [PULL 04/28] linux-user: Fix unaligned memory access in prlimit64 syscall, Laurent Vivier, 2023/03/10
- [PULL 14/28] linux-user/sparc: Tidy syscall trap, Laurent Vivier, 2023/03/10
- [PULL 13/28] linux-user: Emulate CLONE_PIDFD flag in clone(), Laurent Vivier, 2023/03/10
- [PULL 20/28] linux-user/sparc: Handle division by zero traps, Laurent Vivier, 2023/03/10
- [PULL 06/28] linux-user: fill out task state in /proc/self/stat, Laurent Vivier, 2023/03/10
- [PULL 02/28] linux-user: fix timerfd read endianness conversion, Laurent Vivier, 2023/03/10
- [PULL 15/28] linux-user/sparc: Tidy syscall error return, Laurent Vivier, 2023/03/10
- [PULL 17/28] linux-user/sparc: Tidy window spill/fill traps, Laurent Vivier, 2023/03/10
- [PULL 18/28] linux-user/sparc: Fix sparc64_{get, set}_context traps, Laurent Vivier, 2023/03/10