qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Helge Deller <deller@gmx.de>, Laurent Vivier <laurent@vivier.eu>,
	Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, Ilya Leoshkevich <iii@linux.ibm.com>
Subject: Re: [PATCH] linux-user: Add translation for argument of msync()
Date: Thu, 15 Dec 2022 08:58:50 +0100	[thread overview]
Message-ID: <165fbdfe-8e72-0ab7-727e-0f54df9957b3@linaro.org> (raw)
In-Reply-To: <Y5rMcts4qe15RaVN@p100>

On 15/12/22 08:27, Helge Deller wrote:
> 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>
> 
> diff --git a/linux-user/alpha/target_mman.h b/linux-user/alpha/target_mman.h
> index cd6e3d70a6..051544f5ab 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 1436a3c543..32bf1a52d0 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

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

    #define TARGET_MS_ASYNC MS_ASYNC

> +#endif
> +
> +#ifndef TARGET_MS_INVALIDATE
> +#define TARGET_MS_INVALIDATE 2

Ditto,

> +#endif
> +
> +#ifndef TARGET_MS_SYNC
> +#define TARGET_MS_SYNC 4

ditto.

LGTM otherwise.

> +#endif
> +
>   #endif
> diff --git a/linux-user/hppa/target_mman.h b/linux-user/hppa/target_mman.h
> index 66dd9f7941..f9b6b97032 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 a75101fca1..ac8f872371 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -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 },
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index d58e9b8d10..e541fbe09a 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>
> @@ -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:
> 



  reply	other threads:[~2022-12-15  7:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15  7:27 [PATCH] linux-user: Add translation for argument of msync() Helge Deller
2022-12-15  7:58 ` Philippe Mathieu-Daudé [this message]
2022-12-15  8:15   ` Helge Deller
2022-12-15 15:58   ` Richard Henderson
2022-12-15 20:58     ` Philippe Mathieu-Daudé
2022-12-15 23:23       ` Richard Henderson
2023-03-07 16:19 ` Laurent Vivier
2023-03-07 16:21 ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=165fbdfe-8e72-0ab7-727e-0f54df9957b3@linaro.org \
    --to=philmd@linaro.org \
    --cc=deller@gmx.de \
    --cc=iii@linux.ibm.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).