qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIO


From: Arnd Bergmann
Subject: Re: [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIOCGSTAMP with new kernels
Date: Fri, 12 Jul 2019 15:55:29 +0200

On Fri, Jul 12, 2019 at 3:50 PM Laurent Vivier <address@hidden> wrote:
> Le 12/07/2019 à 15:36, Arnd Bergmann a écrit :
> >> We don't do memcopy() but we set each field one by one, so the padding 
> >> doesn't
> >> seem needed if we define correctly the user structure:
> >>
> >> struct target_timeval64 {
> >>     abi_llong tv_sec;
> >>     abi_long tv_usec;
> >> };
> >>
> >> and do something like:
> >>
> >>     struct target_timeval64 *target_tv;
> >>     struct timeval *host_tv;
> >> ...
> >>     __put_user(host_tv->tv_sec, &target_tv->tv_sec);
> >>     __put_user(host_tv->tv_usec, &target_tv->tv_usec);
> >> ...
> >
> > That still seems wrong. The user application has a definition
> > of 'timeval' that contains the padding, so your definition has
> > to match that.
>
> I don't find this definition with the padding. Where it is defined?
>
> We are at the syscall level, so structures are the ones provided by the
> target to the syscall, and they can be converted by the libc if the one
> from the user space differs.

glibc will have to create a definition that matches the kernel, which uses

struct __kernel_timespec {
    __s64 tv_sec;
    __s64 tv_nsec;
};

As posix requires tv_nsec to be 'long', you need padding between
tv_sec and tv_nsec to have a libc definition matching the kernel's
binary layout.

      Arnd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]