qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Daniel P . Berrangé" <berrange@redhat.com>,
	"Gerhard Stenzel" <gerhard.stenzel@de.ibm.com>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	qemu-devel@nongnu.org,
	"Christian Ehrhardt" <christian.ehrhardt@canonical.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIOCGSTAMP with new kernels
Date: Fri, 12 Jul 2019 15:47:26 +0200	[thread overview]
Message-ID: <db82d6a2-8ca7-5bbb-0cf9-feecc8b2adfb@vivier.eu> (raw)
In-Reply-To: <CAK8P3a3fZgcSR7V=NAjDa37-5j8L+n-cF1CVPiWjteV6hfHSLg@mail.gmail.com>

Le 12/07/2019 à 15:36, Arnd Bergmann a écrit :
> On Fri, Jul 12, 2019 at 3:23 PM Laurent Vivier <laurent@vivier.eu> wrote:
>>
>> Le 12/07/2019 à 14:47, Arnd Bergmann a écrit :
...
>>> No, you don't need to swap. The difference is only in the padding.
>>> Since the kernel uses a 64/64 structure here, and user space
>>> may have use 'long tv_nsec', you need to add the padding on
>>> the correct side, like
>>>
>>> struct timeval64 {
>>>    long long tv_sec;
>>> #if 32bit && big-endian
>>>    long :32; /* anonymous padding */
>>> #endif
>>>    suseconds_t tv_usec;
>>> #if (32bit && little-endian) || sparc64
>>>    long :32;
>>> #endif
>>> };
>>
>> 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.

Thanks,
Laurent


  reply	other threads:[~2019-07-12 13:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-11 17:31 [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIOCGSTAMP with new kernels Laurent Vivier
2019-07-11 17:41 ` no-reply
2019-07-11 21:05 ` Arnd Bergmann
2019-07-12 12:17   ` Laurent Vivier
2019-07-12 12:47     ` Arnd Bergmann
2019-07-12 13:22       ` Laurent Vivier
2019-07-12 13:36         ` Arnd Bergmann
2019-07-12 13:47           ` Laurent Vivier [this message]
2019-07-12 13:55             ` Arnd Bergmann
2019-07-14 10:41               ` Richard Henderson
2019-07-14 11:33                 ` Arnd Bergmann
2019-07-14 13:31                   ` Laurent Vivier
2019-07-12 15:12 ` 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=db82d6a2-8ca7-5bbb-0cf9-feecc8b2adfb@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=arnd@arndb.de \
    --cc=berrange@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=christian.ehrhardt@canonical.com \
    --cc=gerhard.stenzel@de.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).