From: Arnd Bergmann <arnd@arndb.de>
To: Laurent Vivier <laurent@vivier.eu>
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 14:47:08 +0200 [thread overview]
Message-ID: <CAK8P3a3XR=C27eYWQ+AxjZ1EEDNBz0HBB_NHh0hbrSDF5ASyqQ@mail.gmail.com> (raw)
In-Reply-To: <74807892-5d59-0a9a-8385-48cce361d842@vivier.eu>
On Fri, Jul 12, 2019 at 2:17 PM Laurent Vivier <laurent@vivier.eu> wrote:
>
> Le 11/07/2019 à 23:05, Arnd Bergmann a écrit :
> > On Thu, Jul 11, 2019 at 7:32 PM Laurent Vivier <laurent@vivier.eu> wrote:
> >
> >>
> >> Notes:
> >> v4: [lv] timeval64 and timespec64 are { long long , long }
> >
> >>
> >> +STRUCT(timeval64, TYPE_LONGLONG, TYPE_LONG)
> >> +
> >> +STRUCT(timespec64, TYPE_LONGLONG, TYPE_LONG)
> >> +
> >
> > This still doesn't look right, see my earlier comment about padding
> > on big-endian architectures.
> >
> > Note that the in-kernel 'timespec64' is different from the uapi
> > '__kernel_timespec' exported by the kernel. I also still think you may
> > need to convert between SIOCGSTAMP_NEW and SIOCGSTAMP_OLD,
> > e.g. when emulating a 32-bit riscv process (which only use
> > SIOCGSTAMP_NEW) on a kernel that only understands
> > SIOCGSTAMP_OLD.
>
> I agree.
> I'm preparing a patch always using SIOCGSTAMP and SIOCGSTAMPNS on the
> host (converting the structure when needed).
That in turn would have the problem of breaking in 2038 when the
timestamp overflows.
> I've added the SH4 variant.
What is special about SH4?
> I've added the sparc64 variant too: does it means sparc64 use the same
> structure internally for the OLD and NEW version?
I had to look it up in the code. Yes, it does, timeval is 64/32/pad32,
timespec is 64/64 in both OLD and NEW for sparc.
> What about sparc 32bit?
sparc32 is like all other 32-bit targets: OLD uses 32/32, and
new uses 64/64.
> For big-endian, I didn't find in the kernel where the difference is
> managed: a byte swapping of the 64bit value is not enough?
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
};
Arnd
next prev parent reply other threads:[~2019-07-12 12:47 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 [this message]
2019-07-12 13:22 ` Laurent Vivier
2019-07-12 13:36 ` Arnd Bergmann
2019-07-12 13:47 ` Laurent Vivier
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='CAK8P3a3XR=C27eYWQ+AxjZ1EEDNBz0HBB_NHh0hbrSDF5ASyqQ@mail.gmail.com' \
--to=arnd@arndb.de \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=christian.ehrhardt@canonical.com \
--cc=gerhard.stenzel@de.ibm.com \
--cc=laurent@vivier.eu \
--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).