qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 4/8] linux-user: Split out preadv, pwritev, readv, writev, pread64, pwrite64
Date: Thu, 10 Jan 2019 16:17:21 +0100	[thread overview]
Message-ID: <4e89a2dd-47fb-29ac-aff2-5d506e3deebb@vivier.eu> (raw)
In-Reply-To: <20181219042113.7364-5-richard.henderson@linaro.org>

On 19/12/2018 05:21, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall-defs.h     |  14 ++++
>  linux-user/syscall-file.inc.c | 124 ++++++++++++++++++++++++++++++++++
>  linux-user/syscall.c          |  93 -------------------------
>  linux-user/strace.list        |  18 -----
>  4 files changed, 138 insertions(+), 111 deletions(-)
> 
...
> diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c
> index 11e75044c1..410a763eee 100644
> --- a/linux-user/syscall-file.inc.c
> +++ b/linux-user/syscall-file.inc.c
> @@ -315,6 +315,104 @@ SYSCALL_IMPL(openat)
...
> +
> +/*
> + * Both preadv and pwritev merge args 4/5 into a 64-bit offset.
> + * Moreover, the parts are *always* in little-endian order.
> + */
> +#if TARGET_ABI_BITS == 32
> +SYSCALL_ARGS(preadv_pwritev)
> +{
> +    /* We have already assigned out[0-2].  */
> +    abi_ulong lo = in[3], hi = in[4];
> +    out[3] = ((hi << (TARGET_ABI_BITS - 1)) << 1) | lo;
> +    return def;
> +}
> +#else
> +#define args_preadv_pwritev NULL
> +#endif
> +
> +/* Perform the inverse operation for the host.  */
> +static inline void host_offset64_low_high(unsigned long *l, unsigned long *h,
> +                                          uint64_t off)
> +{
> +    *l = off;
> +    *h = (off >> (HOST_LONG_BITS - 1)) >> 1;
> +}


I have an error with preadv() on a 32bit target (powerpc, LTP test preadv02).

It works if I use:

static inline void host_offset64_low_high(unsigned long *hlow,
                                          unsigned long *hhigh,
                                          abi_ulong tlow,
                                          abi_ulong thigh)
{
    uint64_t off = tlow |
                   ((unsigned long long)thigh << TARGET_LONG_BITS / 2) <<
                   TARGET_LONG_BITS / 2;
    
    *hlow = off;
    *hhigh = (off >> HOST_LONG_BITS / 2) >> HOST_LONG_BITS / 2;
}



> +
> +SYSCALL_IMPL(preadv)
> +{
> +    struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
> +    unsigned long lo, hi;
> +    abi_long ret;
> +
> +    if (vec == NULL) {
> +        return -host_to_target_errno(errno);
> +    }
> +
> +    host_offset64_low_high(&lo, &hi, arg4);
> +    ret = get_errno(safe_preadv(arg1, vec, arg3, lo, hi));
> +    unlock_iovec(vec, arg2, arg3, 1);
> +    return ret;
> +}
> +
> +SYSCALL_IMPL(pwritev)
> +{
> +    struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
> +    unsigned long lo, hi;
> +    abi_long ret;
> +
> +    if (vec == NULL) {
> +        ret = -host_to_target_errno(errno);

           return -host_to_target_errno(errno);

> +    }
> +
> +    host_offset64_low_high(&lo, &hi, arg4);
> +    ret = get_errno(safe_pwritev(arg1, vec, arg3, lo, hi));
> +    unlock_iovec(vec, arg2, arg3, 0);
> +    return ret;
> +}
> +
>  SYSCALL_IMPL(read)
>  {
>      abi_long ret;

  reply	other threads:[~2019-01-10 15:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19  4:21 [Qemu-devel] [PATCH v5 0/8] linux-user: Split do_syscall Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 1/8] linux-user: Setup split syscall infrastructure Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 2/8] linux-user: Split out some simple file syscalls Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 3/8] linux-user: Reduce regpairs_aligned & target_offset64 ifdefs Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 4/8] linux-user: Split out preadv, pwritev, readv, writev, pread64, pwrite64 Richard Henderson
2019-01-10 15:17   ` Laurent Vivier [this message]
2019-01-11 21:31     ` Richard Henderson
2019-01-14 11:04       ` Laurent Vivier
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 5/8] linux-user: Split out name_to_handle_at, open_by_handle_at Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 6/8] linux-user: Split out ipc syscalls Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 7/8] linux-user: Split out memory syscalls Richard Henderson
2018-12-19  4:21 ` [Qemu-devel] [PATCH v5 8/8] linux-user: Split out some process syscalls Richard Henderson
2019-01-10 14:17   ` Laurent Vivier
2018-12-25  3:19 ` [Qemu-devel] [PATCH v5 0/8] linux-user: Split do_syscall no-reply
2019-01-09  9:50 ` 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=4e89a2dd-47fb-29ac-aff2-5d506e3deebb@vivier.eu \
    --to=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).