From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Daniel P . Berrangé" <berrange@redhat.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Gerhard Stenzel" <gerhard.stenzel@de.ibm.com>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Laurent Vivier" <laurent@vivier.eu>,
"Christian Ehrhardt" <christian.ehrhardt@canonical.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>
Subject: [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIOCGSTAMP with new kernels
Date: Thu, 11 Jul 2019 19:31:31 +0200 [thread overview]
Message-ID: <20190711173131.6347-1-laurent@vivier.eu> (raw)
From: Daniel P. Berrangé <berrange@redhat.com>
The SIOCGSTAMP symbol was previously defined in the
asm-generic/sockios.h header file. QEMU sees that header
indirectly via sys/socket.h
In linux kernel commit 0768e17073dc527ccd18ed5f96ce85f9985e9115
the asm-generic/sockios.h header no longer defines SIOCGSTAMP.
Instead it provides only SIOCGSTAMP_OLD, which only uses a
32-bit time_t on 32-bit architectures.
The linux/sockios.h header then defines SIOCGSTAMP using
either SIOCGSTAMP_OLD or SIOCGSTAMP_NEW as appropriate. If
SIOCGSTAMP_NEW is used, then the tv_sec field is 64-bit even
on 32-bit architectures
To cope with this we must now define two separate syscalls,
with corresponding old and new sizes, as well as including
the new linux/sockios.h header.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
Notes:
v4: [lv] timeval64 and timespec64 are { long long , long }
v3: [lv] redefine TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMPNS_NEW,
timeval64 and timespec64 to use 0x89 type and abi_llong[2]
v2: [dpb] implement _NEW and _OLD variants
linux-user/ioctls.h | 15 +++++++++++++++
linux-user/syscall.c | 1 +
linux-user/syscall_defs.h | 4 ++++
linux-user/syscall_types.h | 4 ++++
4 files changed, 24 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 5e84dc7c3a77..5a6d6def7e3f 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -222,8 +222,23 @@
IOCTL(SIOCGIWNAME, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_char_ifreq)))
IOCTL(SIOCSPGRP, IOC_W, MK_PTR(TYPE_INT)) /* pid_t */
IOCTL(SIOCGPGRP, IOC_R, MK_PTR(TYPE_INT)) /* pid_t */
+
+#ifdef SIOCGSTAMP_OLD
+ IOCTL(SIOCGSTAMP_OLD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval)))
+#else
IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval)))
+#endif
+#ifdef SIOCGSTAMPNS_OLD
+ IOCTL(SIOCGSTAMPNS_OLD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
+#else
IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
+#endif
+#ifdef SIOCGSTAMP_NEW
+ IOCTL(SIOCGSTAMP_NEW, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval64)))
+#endif
+#ifdef SIOCGSTAMPNS_NEW
+ IOCTL(SIOCGSTAMPNS_NEW, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec64)))
+#endif
IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT))
IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 39a37496fed5..aa18ac4b2389 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -37,6 +37,7 @@
#include <sched.h>
#include <sys/timex.h>
#include <sys/socket.h>
+#include <linux/sockios.h>
#include <sys/un.h>
#include <sys/uio.h>
#include <poll.h>
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index fffa89f2564b..e0326923a018 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -751,6 +751,10 @@ struct target_pollfd {
#define TARGET_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
#define TARGET_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
+#define TARGET_SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */
+#define TARGET_SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */
+#define TARGET_SIOCGSTAMP_NEW TARGET_IOR(0x89, 0x06, abi_llong[2]) /* Get stamp (timeval64) */
+#define TARGET_SIOCGSTAMPNS_NEW TARGET_IOR(0x89, 0x07, abi_llong[2]) /* Get stamp (timespec64) */
/* Networking ioctls */
#define TARGET_SIOCADDRT 0x890B /* add routing table entry */
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index b98a23b0f1b0..de4c5a5b6f5b 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -20,6 +20,10 @@ STRUCT(timeval,
STRUCT(timespec,
MK_ARRAY(TYPE_LONG, 2))
+STRUCT(timeval64, TYPE_LONGLONG, TYPE_LONG)
+
+STRUCT(timespec64, TYPE_LONGLONG, TYPE_LONG)
+
STRUCT(rtentry,
TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr),
TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYPE_PTRVOID,
--
2.21.0
next reply other threads:[~2019-07-11 17:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-11 17:31 Laurent Vivier [this message]
2019-07-11 17:41 ` [Qemu-devel] [PATCH v4] linux-user: fix to handle variably sized SIOCGSTAMP with new kernels 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
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=20190711173131.6347-1-laurent@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).