All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: "open list:RISC-V" <qemu-riscv@nongnu.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Aleksandar Markovic <aleksandar.m.mail@gmail.com>
Subject: Re: [PATCH v7 3/4] linux-user: Support futex_time64
Date: Fri, 13 Mar 2020 15:12:17 -0700	[thread overview]
Message-ID: <CAKmqyKNUqEcueqfWCoO5e1sHtAeDGLGGnSCo-NOzjtHvzLbKAA@mail.gmail.com> (raw)
In-Reply-To: <2043ccc2-c14e-5237-af54-e8f082164ed7@vivier.eu>

On Fri, Mar 13, 2020 at 1:14 AM Laurent Vivier <laurent@vivier.eu> wrote:
>
> Le 12/03/2020 à 23:13, Alistair Francis a écrit :
> > Add support for host and target futex_time64. If futex_time64 exists on
> > the host we try that first before falling back to the standard futux
> > syscall.
> >
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >  linux-user/syscall.c | 144 +++++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 131 insertions(+), 13 deletions(-)
> >
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index 60fd775d9c..9ae7a05e38 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> ...
> > @@ -6890,6 +6905,55 @@ static inline abi_long host_to_target_statx(struct target_statx *host_stx,
> >  }
> >  #endif
> >
> > +static int do_sys_futex(int *uaddr, int op, int val,
> > +                         const struct timespec *timeout, int *uaddr2,
> > +                         int val3)
> > +{
> > +#if HOST_LONG_BITS == 64
> > +#if defined(__NR_futex)
> > +    /* always a 64-bit time_t, it doesn't define _time64 version  */
> > +    return sys_futex(uaddr, op, val, timeout, uaddr2, val3);
> > +
> > +#endif
> > +#else /* HOST_LONG_BITS == 64 */
> > +#if defined(__NR_futex_time64)
> > +    if (sizeof(timeout->tv_sec) == 8) {
> > +        /* _time64 function on 32bit arch */
> > +        return sys_futex_time64(uaddr, op, val, timeout, uaddr2, val3);
> > +    }
> > +#endif
> > +#if defined(__NR_futex)
> > +    /* old function on 32bit arch */
> > +    return sys_futex(uaddr, op, val, timeout, uaddr2, val3);
> > +#endif
> > +#endif /* HOST_LONG_BITS == 64 */
> > +    return -TARGET_ENOSYS;
>
> You cannot return -TARGET_ENOSYS because return value is supposed to be
> a host value as you have direct value from sys_futex().
>
> ...
>
> > @@ -7505,7 +7619,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
> >              ts = cpu->opaque;
> >              if (ts->child_tidptr) {
> >                  put_user_u32(0, ts->child_tidptr);
> > -                sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
> > +                do_sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
> >                            NULL, NULL, 0);
>
> And return value is ignored. Anyway at this point we can't do anything
> if it doesn't work, but it should not happen. So I think the best to do
> is to add a g_assert_not_reached() in place of "return -TARGET_ENOSYS"
> in do_sys_futex() (or "#error" if no futex function is available).

It sounds like you applied this series, so I'm not going to fix this
up. Let me know if you would like me to.

Alistair

>
> Thanks,
> Laurent
>
>


WARNING: multiple messages have this Message-ID (diff)
From: Alistair Francis <alistair23@gmail.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: Alistair Francis <alistair.francis@wdc.com>,
	 "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"open list:RISC-V" <qemu-riscv@nongnu.org>,
	 Aleksandar Markovic <aleksandar.m.mail@gmail.com>,
	Palmer Dabbelt <palmer@dabbelt.com>
Subject: Re: [PATCH v7 3/4] linux-user: Support futex_time64
Date: Fri, 13 Mar 2020 15:12:17 -0700	[thread overview]
Message-ID: <CAKmqyKNUqEcueqfWCoO5e1sHtAeDGLGGnSCo-NOzjtHvzLbKAA@mail.gmail.com> (raw)
In-Reply-To: <2043ccc2-c14e-5237-af54-e8f082164ed7@vivier.eu>

On Fri, Mar 13, 2020 at 1:14 AM Laurent Vivier <laurent@vivier.eu> wrote:
>
> Le 12/03/2020 à 23:13, Alistair Francis a écrit :
> > Add support for host and target futex_time64. If futex_time64 exists on
> > the host we try that first before falling back to the standard futux
> > syscall.
> >
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >  linux-user/syscall.c | 144 +++++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 131 insertions(+), 13 deletions(-)
> >
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index 60fd775d9c..9ae7a05e38 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> ...
> > @@ -6890,6 +6905,55 @@ static inline abi_long host_to_target_statx(struct target_statx *host_stx,
> >  }
> >  #endif
> >
> > +static int do_sys_futex(int *uaddr, int op, int val,
> > +                         const struct timespec *timeout, int *uaddr2,
> > +                         int val3)
> > +{
> > +#if HOST_LONG_BITS == 64
> > +#if defined(__NR_futex)
> > +    /* always a 64-bit time_t, it doesn't define _time64 version  */
> > +    return sys_futex(uaddr, op, val, timeout, uaddr2, val3);
> > +
> > +#endif
> > +#else /* HOST_LONG_BITS == 64 */
> > +#if defined(__NR_futex_time64)
> > +    if (sizeof(timeout->tv_sec) == 8) {
> > +        /* _time64 function on 32bit arch */
> > +        return sys_futex_time64(uaddr, op, val, timeout, uaddr2, val3);
> > +    }
> > +#endif
> > +#if defined(__NR_futex)
> > +    /* old function on 32bit arch */
> > +    return sys_futex(uaddr, op, val, timeout, uaddr2, val3);
> > +#endif
> > +#endif /* HOST_LONG_BITS == 64 */
> > +    return -TARGET_ENOSYS;
>
> You cannot return -TARGET_ENOSYS because return value is supposed to be
> a host value as you have direct value from sys_futex().
>
> ...
>
> > @@ -7505,7 +7619,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
> >              ts = cpu->opaque;
> >              if (ts->child_tidptr) {
> >                  put_user_u32(0, ts->child_tidptr);
> > -                sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
> > +                do_sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
> >                            NULL, NULL, 0);
>
> And return value is ignored. Anyway at this point we can't do anything
> if it doesn't work, but it should not happen. So I think the best to do
> is to add a g_assert_not_reached() in place of "return -TARGET_ENOSYS"
> in do_sys_futex() (or "#error" if no futex function is available).

It sounds like you applied this series, so I'm not going to fix this
up. Let me know if you would like me to.

Alistair

>
> Thanks,
> Laurent
>
>


  reply	other threads:[~2020-03-13 22:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 22:13 [PATCH v7 0/4] linux-user: generate syscall_nr.sh for RISC-V Alistair Francis
2020-03-12 22:13 ` Alistair Francis
2020-03-12 22:13 ` [PATCH v7 1/4] linux-user: Protect more syscalls Alistair Francis
2020-03-12 22:13   ` Alistair Francis
2020-03-13 21:46   ` Laurent Vivier
2020-03-13 21:46     ` Laurent Vivier
2020-03-12 22:13 ` [PATCH v7 2/4] linux-user/syscall: Add support for clock_gettime64/clock_settime64 Alistair Francis
2020-03-12 22:13   ` Alistair Francis
2020-03-13 21:48   ` Laurent Vivier
2020-03-13 21:48     ` Laurent Vivier
2020-03-12 22:13 ` [PATCH v7 3/4] linux-user: Support futex_time64 Alistair Francis
2020-03-12 22:13   ` Alistair Francis
2020-03-13  8:14   ` Laurent Vivier
2020-03-13  8:14     ` Laurent Vivier
2020-03-13 22:12     ` Alistair Francis [this message]
2020-03-13 22:12       ` Alistair Francis
2020-03-13 22:13       ` Alistair Francis
2020-03-13 22:13         ` Alistair Francis
2020-03-13 22:17         ` Laurent Vivier
2020-03-13 22:17           ` Laurent Vivier
2020-03-12 22:14 ` [PATCH v7 4/4] linux-user/riscv: Update the syscall_nr's to the 5.5 kernel Alistair Francis
2020-03-12 22:14   ` Alistair Francis
2020-03-13 21:49   ` Laurent Vivier
2020-03-13 21:49     ` Laurent Vivier
2020-03-13  1:47 ` [PATCH v7 0/4] linux-user: generate syscall_nr.sh for RISC-V no-reply
2020-03-13  1:47   ` no-reply

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=CAKmqyKNUqEcueqfWCoO5e1sHtAeDGLGGnSCo-NOzjtHvzLbKAA@mail.gmail.com \
    --to=alistair23@gmail.com \
    --cc=aleksandar.m.mail@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=laurent@vivier.eu \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.