qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS

Socket ioctls SIOCGSTAMP and SIOCGSTAMPNS, used for timestamping the socket
connection, are defined in file "ioctls.h" differently from other ioctls.
The reason for this difference is explained in the comments above their definition.
These ioctls didn't have defined thunk argument types before changes from this
patch. They have special handling functions ("do_ioctl_SIOCGSTAMP" and
"do_ioctl_SIOCGSTAMPNS") that take care of setting values for approppriate argument
types (struct timeval and struct timespec) and thus no thunk argument types were
needed for their implementation. But this patch adds those argument type definitions
in file "syscall_types.h" and "ioctls.h" as it is needed for printing arguments
of these ioctls with strace.

Implementation notes:

There are two variants of these ioctls: SIOCGSTAMP_OLD/SIOCGSTAM_NEW and
SIOCGSTAMPNS_OLD/SIOCGSTAMPNS_NEW. One is the old existing definition and the
other is the 2038 safe variant used for 32-bit architectures. Corresponding
structure definitions STRUCT_timespec/STRUCT__kernel_timespec and
STRUCT_timeval/STRUCT__kernel_sock_timeval were added for these variants.
STRUCT_timeval definition was already inside the file as it is used by
another implemented ioctl. Two cases were added for definitions
STRUCT_timeval/STRUCT__kernel_sock_timeval to manage the case when the
"u_sec" field of the timeval structure is of type int.

Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-2-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>

authored by

Filip Bozuta and committed by
Laurent Vivier
a20a7c26 f4d92c5e

+30 -4
+8 -4
linux-user/ioctls.h
··· 279 279 * FIXME: create a macro to define this kind of entry 280 280 */ 281 281 { TARGET_SIOCGSTAMP_OLD, TARGET_SIOCGSTAMP_OLD, 282 - "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP }, 282 + "SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP, 283 + { MK_PTR(MK_STRUCT(STRUCT_timeval)) } }, 283 284 { TARGET_SIOCGSTAMPNS_OLD, TARGET_SIOCGSTAMPNS_OLD, 284 - "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS }, 285 + "SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS, 286 + { MK_PTR(MK_STRUCT(STRUCT_timespec)) } }, 285 287 { TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMP_NEW, 286 - "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP }, 288 + "SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP, 289 + { MK_PTR(MK_STRUCT(STRUCT__kernel_sock_timeval)) } }, 287 290 { TARGET_SIOCGSTAMPNS_NEW, TARGET_SIOCGSTAMPNS_NEW, 288 - "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS }, 291 + "SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS, 292 + { MK_PTR(MK_STRUCT(STRUCT__kernel_timespec)) } }, 289 293 290 294 IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT)) 291 295 IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT))
+22
linux-user/syscall_types.h
··· 137 137 TYPE_INT, /* filter */ 138 138 MK_ARRAY(TYPE_CHAR, 60)) /* reserved */ 139 139 140 + #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) 141 + STRUCT(timeval, 142 + TYPE_LONG, /* tv_sec */ 143 + TYPE_INT) /* tv_usec */ 144 + 145 + STRUCT(_kernel_sock_timeval, 146 + TYPE_LONG, /* tv_sec */ 147 + TYPE_INT) /* tv_usec */ 148 + #else 149 + STRUCT(timeval, 150 + TYPE_LONG, /* tv_sec */ 151 + TYPE_LONG) /* tv_usec */ 152 + 153 + STRUCT(_kernel_sock_timeval, 154 + TYPE_LONGLONG, /* tv_sec */ 155 + TYPE_LONGLONG) /* tv_usec */ 156 + #endif 157 + 140 158 STRUCT(timespec, 141 159 TYPE_LONG, /* tv_sec */ 142 160 TYPE_LONG) /* tv_nsec */ 161 + 162 + STRUCT(_kernel_timespec, 163 + TYPE_LONGLONG, /* tv_sec */ 164 + TYPE_LONGLONG) /* tv_nsec */ 143 165 144 166 STRUCT(snd_timer_status, 145 167 MK_STRUCT(STRUCT_timespec), /* tstamp */