Linux user for 5.2 patches
The following changes since commit 25f6dc28a3a8dd231c2c092a0e65bd796353c769:
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2020-08-26' =
into staging (2020-08-26 10:28:36 +0100)
are available in the Git repository at:
git://github.com/vivier/qemu.git tags/linux-user-for-5.2-pull-request
for you to fetch changes up to aa26eb42f5eaec54257aaceaeda50b9aa98756a5:
linux-user: Add support for utimensat_time64() and semtimedop_time64() (202=
0-08-27 12:29:51 +0200)
----------------------------------------------------------------
add utimensat_time64, semtimedop_time64, rt_sigtimedwait_time64,
sched_rr_get_interval_time64, clock_nanosleep_time64, clock_adjtime64, mq_timedsend_time64, mq_timedreceive_time64
fix semop, semtimedop, clock_nanosleep, mq_timedsend, target_to_host_timespec= 64
fix tembits.h
add more strace function
Add upport DRM_IOCTL_I915_GETPARAM
detect mismatched ELF ABI in qemu-mips[n32][el]
----------------------------------------------------------------
Carlo Marcelo Arenas Bel=C3=B3n (1):
linux-user: detect mismatched ELF ABI in qemu-mips[n32][el]
Chen Gang (1):
linux-user: syscall: ioctls: support DRM_IOCTL_I915_GETPARAM
Filip Bozuta (15):
linux-user: Fix 'semop()' and 'semtimedop()' implementation
linux-user: Fix 'clock_nanosleep()' implementation
linux-user: Make cpu_env accessible in strace.c
linux-user: Add strace support for printing arguments of
truncate()/ftruncate() and getsid()
linux-user: Add strace support for printing arguments of syscalls used
to lock and unlock memory
linux-user: Add an api to print enumareted argument values with strace
linux-user: Add strace support for printing arguments of some clock
and time functions
linux-user: Add generic 'termbits.h' for some archs
linux-user: Add missing termbits types and values definitions
linux-user: Add strace support for printing arguments for ioctls used
for terminals and serial lines
linux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()'
linux-user: Add support for 'mq_timedsend_time64()' and
'mq_timedreceive_time64()'
linux-user: Add support for 'clock_nanosleep_time64()' and
'clock_adjtime64()'
linux-user: Add support for 'rt_sigtimedwait_time64()' and
'sched_rr_get_interval_time64()' linux-user: Add support for utimensat_time64() and semtimedop_time64()
Laurent Vivier (1):
linux-user: fix target_to_host_timespec64()
include/exec/user/thunk.h | 1 + linux-user/aarch64/target_syscall.h | 5 +- linux-user/aarch64/termbits.h | 228 +---- linux-user/alpha/target_syscall.h | 5 +- linux-user/alpha/termbits.h | 1 + linux-user/arm/target_syscall.h | 6 +- linux-user/arm/termbits.h | 223 +---- linux-user/cris/target_syscall.h | 5 +- linux-user/cris/termbits.h | 18 +- linux-user/elfload.c | 11 + linux-user/generic/termbits.h | 318 +++++++ linux-user/hppa/target_syscall.h | 5 +- linux-user/hppa/termbits.h | 17 +- linux-user/i386/target_syscall.h | 5 +- linux-user/i386/termbits.h | 233 +----- linux-user/ioctls.h | 3 + linux-user/m68k/target_syscall.h | 6 +- linux-user/m68k/termbits.h | 234 +----- linux-user/microblaze/target_syscall.h | 5 +- linux-user/microblaze/termbits.h | 220 +---- linux-user/mips/target_syscall.h | 5 +- linux-user/mips/termbits.h | 17 +- linux-user/mips64/target_syscall.h | 5 +- linux-user/nios2/target_syscall.h | 5 +- linux-user/nios2/termbits.h | 228 +---- linux-user/openrisc/target_syscall.h | 5 +- linux-user/openrisc/termbits.h | 302 +------ linux-user/ppc/target_syscall.h | 5 +- linux-user/ppc/termbits.h | 21 +- linux-user/qemu.h | 40 +- linux-user/riscv/target_syscall.h | 5 +- linux-user/riscv/termbits.h | 228 +---- linux-user/s390x/target_syscall.h | 5 +- linux-user/s390x/termbits.h | 289 +------ linux-user/sh4/target_syscall.h | 5 +- linux-user/sh4/termbits.h | 19 +- linux-user/sparc/target_syscall.h | 5 +- linux-user/sparc/termbits.h | 18 +- linux-user/sparc64/target_syscall.h | 5 +- linux-user/sparc64/termbits.h | 18 +- linux-user/strace.c | 1060 +++++++++++++++++------- linux-user/strace.list | 35 +- linux-user/syscall.c | 471 +++++++++-- linux-user/syscall_defs.h | 41 + linux-user/syscall_types.h | 4 + linux-user/tilegx/target_syscall.h | 5 +- linux-user/tilegx/termbits.h | 276 +----- linux-user/x86_64/target_syscall.h | 5 +- linux-user/x86_64/termbits.h | 254 +----- linux-user/xtensa/target_syscall.h | 5 +- linux-user/xtensa/termbits.h | 55 +- thunk.c | 23 +- 52 files changed, 1790 insertions(+), 3223 deletions(-) create mode 100644 linux-user/generic/termbits.h
--=20
2.26.2
[PULL 01/18] linux-user: Fix 'semop()' and 'semtimedop()' implementation
From: Filip Bozuta <[email protected]>
The implementations of syscalls 'semop()' and 'semtimedop()' in file 'syscall.c' use function 'target_to_host_sembuf()' to convert values of 'struct sembuf' from host to target. However, before this conversion it should be check whether the number of semaphore operations 'nsops' is not bigger than maximum allowed semaphor operations per
syscall: 'SEMOPM'. In these cases, errno 'E2BIG' ("Arg list too long") should be set. But the implementation will set errno 'EFAULT' ("Bad address") in this case since the conversion from target to host in this case fails.
This was confirmed with the LTP test for 'semop()' ('ipc/semop/semop02') in test case where 'nsops' is greater than SEMOPM with unaproppriate errno EFAULT:
semop02.c:130: FAIL: semop failed unexpectedly; expected: E2BIG: EFAULT (14)
This patch changes this by adding a check whether 'nsops' is bigger than 'SEMOPM' before the conversion function 'target_to_host_sembuf()' is called. After the changes from this patch, the test works fine along with the other LTP testcases for 'semop()'):
semop02.c:126: PASS: semop failed as expected: E2BIG (7)
Implementation notes:
A target value ('TARGET_SEMOPM') was added for 'SEMOPM' as to be sure in case the value is not available for some targets.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 13 +++++++++++-- linux-user/syscall_defs.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-)
linux-user/syscall.c +11 -2
@@ -3901,7 +3901,7 @@ static inline abi_long do_semtimedop(int semid, unsigned nsops, abi_long timeout) { -struct sembuf sops[nsops]; +struct sembuf *sops;struct timespec ts, *pts =NULL ;abi_long ret;
@@ -3912,8 +3912,16 @@ static inline abi_long do_semtimedop(int semid, } } -if (target_to_host_sembuf (sops, ptr, nsops)) +if (nsops >TARGET_SEMOPM ) { +return -TARGET_E2BIG ; + } + + sops = g_new(struct sembuf, nsops); + +if (target_to_host_sembuf (sops, ptr, nsops)) { +g_free (sops);return -TARGET_EFAULT ; + } ret = -TARGET_ENOSYS ;#ifdef __NR_semtimedop
@@ -3925,6 +3933,7 @@ static inline abi_long do_semtimedop(int semid, SEMTIMEDOP_IPC_ARGS(nsops, sops, (long)pts))); }#endif +g_free (sops);return ret; }#endif
linux-user/syscall_defs.h +2 -0
@@ -46,6 +46,8 @@#define IPCOP_shmget 23#define IPCOP_shmctl 24 +#define TARGET_SEMOPM 500 +/* * The following is for compatibility across the various Linux * platforms. The i386 ioctl numbering scheme doesn't really enforce
Signature · 1 line
2.26.2
[PULL 02/18] linux-user: Fix 'clock_nanosleep()' implementation
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
Implementation of syscall 'clock_nanosleep()' in 'syscall.c' uses functions 'target_to_host_timespec()' and 'host_to_target_timespec()' to transfer the value of 'struct timespec' between target and host. However, the implementation doesn't check whether this conversion succeeds and thus can return an unaproppriate error instead of 'EFAULT' that is expected. This was confirmed with the modified LTP test suite where testcases with bad 'struct timespec' adress for 'clock_nanosleep()' were added. This modified LTP suite can be found at:
https://github.com/bozutaf/ltp
(Patch with this new test case will be sent to LTP mailing list soon)
Message-Id: <[email protected]>
--- linux-user/syscall.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
linux-user/syscall.c +6 -3
@@ -11875,7 +11875,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_clock_nanosleep: {struct timespec ts; -target_to_host_timespec (&ts, arg3); +if (target_to_host_timespec (&ts, arg3)) { +return -TARGET_EFAULT ; + } ret =get_errno (safe_clock_nanosleep (arg1, arg2, &ts, arg4 ? &ts :NULL ));/*
@@ -11883,8 +11885,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not * TIMER_ABSTIME, it returns the remaining unslept time in arg4. */ -if (ret == -TARGET_EINTR && arg4 && arg2 !=TIMER_ABSTIME ) { -host_to_target_timespec (arg4, &ts); +if (ret == -TARGET_EINTR && arg4 && arg2 !=TIMER_ABSTIME && +host_to_target_timespec (arg4, &ts)) { +return -TARGET_EFAULT ; }return ret;
Signature · 1 line
2.26.2
[PULL 07/18] linux-user: Add an api to print enumareted argument values with strace
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch introduces a type 'struct enums' and function 'print_enums()' that can be used to print enumerated argument values of some syscalls in strace. This can be used in future strace implementations.
Also, macros 'ENUM_GENERIC()', 'ENUM_TARGET()' and 'ENUM_END', are introduced to enable automatic generation of aproppriate enumarated values and their repsective string representations (these macros are exactly the same as 'FLAG_GENERIC()', 'FLAG_TARGET()' and 'FLAG_END').
Future patches are planned to modify all existing print functions in 'strace.c' that print arguments of syscalls with enumerated values to use this new api.
Message-Id: <[email protected]>
--- linux-user/strace.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
linux-user/strace.c +31 -0
@@ -52,9 +52,23 @@ struct flags {/* end of flags array */ #define FLAG_END { 0, NULL } +/* Structure used to translate enumerated values into strings */ +struct enums { +abi_long e_value;/* enum value */ +const char *e_string;/* stringified enum */ +}; + +/* common enums for all architectures */ +#define ENUM_GENERIC (name) { name, #name } +/* target specific enums */ +#define ENUM_TARGET (name) { TARGET_ ## name, #name } +/* end of enums array */ +#define ENUM_END { 0, NULL } + UNUSED static const char *get_comma(int); UNUSED static void print_pointer(abi_long, int); UNUSED static void print_flags(const struct flags *, abi_long, int); +UNUSED static void print_enums(const struct enums *, abi_long, int); UNUSED static void print_at_dirfd(abi_long, int); UNUSED static void print_file_mode(abi_long, int); UNUSED static void print_open_flags(abi_long, int);
@@ -1252,6 +1266,23 @@ print_flags(const struct flags *f, abi_long flags, int last) } } +static void +print_enums (const struct enums *e,abi_long enum_arg,int last) +{ +for (; e->e_string !=NULL ; e++) { +if (e->e_value == enum_arg) { +qemu_log ("%s" , e->e_string); +break ; + } + } + +if (e->e_string ==NULL ) { +qemu_log ("%#x" , (unsigned int )enum_arg); + } + +qemu_log ("%s" ,get_comma (last)); +} +static void print_at_dirfd (abi_long dirfd,int last) {
Signature · 1 line
2.26.2
[PULL 17/18] linux-user: Add support for 'rt_sigtimedwait_time64()' and 'sched_rr_get_interval_time64()'
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch implements functionality for following time64 syscalls:
*rt_sigtimedwait_time64()
This is a year 2038 safe variant of syscall:
int rt_sigtimedwait(const sigset_t *set, siginfo_t *info,
const struct timespec *timeout, size_t sigsetsize)
--synchronously wait for queued signals--
man page: https://man7.org/linux/man-pages/man2/rt_sigtimedwait.2.html
*sched_rr_get_interval_time64()
This is a year 2038 safe variant of syscall:
int sched_rr_get_interval(pid_t pid, struct timespec *tp)
--get the SCHED_RR interval for the named process--
man page: https://man7.org/linux/man-pages/man2/sched_rr_get_interval.2.html
Implementation notes:
These syscalls were implemented in similar ways like 'rt_sigtimedwait()' and 'sched_rr_get_interval()' except that functions 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used to convert values of 'struct timespec' between host and target.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 58 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-)
linux-user/syscall.c +56 -2
@@ -764,7 +764,7 @@ safe_syscall6(ssize_t, recvfrom, int, fd, void *, buf, size_t, len, safe_syscall3(ssize_t, sendmsg, int, fd, const struct msghdr *, msg, int, flags) safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags) safe_syscall2(int, flock, int, fd, int, operation) -#ifdef TARGET_NR_rt_sigtimedwait +#if defined(TARGET_NR_rt_sigtimedwait) || defined(TARGET_NR_rt_sigtimedwait_time64) safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo, const struct timespec *, uts, size_t, sigsetsize)#endif
@@ -1241,7 +1241,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts,defined (TARGET_NR_mq_timedsend_time64) || \defined (TARGET_NR_mq_timedreceive_time64) || \ (defined (TARGET_NR_timerfd_settime64) &&defined (CONFIG_TIMERFD )) || \ - defined(TARGET_NR_clock_nanosleep_time64) +defined (TARGET_NR_clock_nanosleep_time64) || \ + defined(TARGET_NR_rt_sigtimedwait_time64)static inline abi_long target_to_host_timespec64 (struct timespec *host_ts,abi_ulong target_addr) {
@@ -9042,6 +9043,48 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } }return ret; +#endif +#ifdef TARGET_NR_rt_sigtimedwait_time64 +case TARGET_NR_rt_sigtimedwait_time64: + { +sigset_t set; +struct timespec uts, *puts; +siginfo_t uinfo; + +if (arg4 !=sizeof (target_sigset_t)) { +return -TARGET_EINVAL ; + } + + p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ); +if (!p) { +return -TARGET_EFAULT ; + } +target_to_host_sigset (&set, p); +unlock_user (p, arg1,0 ); +if (arg3) { + puts = &uts; +if (target_to_host_timespec64 (puts, arg3)) { +return -TARGET_EFAULT ; + } + }else { + puts =NULL ; + } + ret =get_errno (safe_rt_sigtimedwait (&set, &uinfo, puts, +SIGSET_T_SIZE )); +if (!is_error (ret)) { +if (arg2) { + p =lock_user (VERIFY_WRITE , arg2, +sizeof (target_siginfo_t),0 ); +if (!p) { +return -TARGET_EFAULT ; + } +host_to_target_siginfo (p, &uinfo); +unlock_user (p, arg2,sizeof (target_siginfo_t)); + } + ret =host_to_target_signal (ret); + } + } +return ret;#endif case TARGET_NR_rt_sigqueueinfo: {
@@ -10566,6 +10609,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif +#ifdef TARGET_NR_sched_rr_get_interval_time64 +case TARGET_NR_sched_rr_get_interval_time64: + { +struct timespec ts; + ret =get_errno (sched_rr_get_interval (arg1, &ts)); +if (!is_error (ret)) { + ret =host_to_target_timespec64 (arg2, &ts); + } + } +return ret; +#endif #if defined(TARGET_NR_nanosleep)case TARGET_NR_nanosleep: {
Signature · 1 line
2.26.2
[PULL 03/18] linux-user: syscall: ioctls: support DRM_IOCTL_I915_GETPARAM
In reply to Laurent VivierFrom: Chen Gang <[email protected]>
Another DRM_IOCTL_I915 patches will be sent next.
Message-Id: <[email protected]>
--- linux-user/ioctls.h | 3 +++ linux-user/syscall.c | 35 +++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 8 ++++++++ linux-user/syscall_types.h | 4 ++++ 4 files changed, 50 insertions(+)
linux-user/ioctls.h +3 -0
@@ -581,6 +581,9 @@#ifdef HAVE_DRM_H IOCTL_SPECIAL (DRM_IOCTL_VERSION ,IOC_RW , do_ioctl_drm, MK_PTR(MK_STRUCT(STRUCT_drm_version))) + +IOCTL_SPECIAL (DRM_IOCTL_I915_GETPARAM ,IOC_RW , do_ioctl_drm_i915, + MK_PTR(MK_STRUCT(STRUCT_drm_i915_getparam)))#endif #ifdef TARGET_TIOCSTART
linux-user/syscall.c +35 -0
@@ -114,6 +114,7 @@#include <sound/asound.h> #ifdef HAVE_DRM_H #include <libdrm/drm.h> +#include <libdrm/i915_drm.h> #endif #include "linux_loop.h" #include "uname.h"
@@ -5426,6 +5427,40 @@ static abi_long do_ioctl_drm(const IOCTLEntry *ie, uint8_t *buf_temp,return -TARGET_ENOSYS ; } +static abi_long do_ioctl_drm_i915_getparam (const IOCTLEntry *ie, +struct drm_i915_getparam *gparam, +int fd,abi_long arg) +{ +abi_long ret; +int value; +struct target_drm_i915_getparam *target_gparam; + +if (!lock_user_struct (VERIFY_READ , target_gparam, arg,0 )) { +return -TARGET_EFAULT ; + } + +__get_user (gparam->param, &target_gparam->param); + gparam->value = &value; + ret =get_errno (safe_ioctl (fd, ie->host_cmd, gparam)); +put_user_s32 (value, target_gparam->value); + +unlock_user_struct (target_gparam, arg,0 ); +return ret; +} + +static abi_long do_ioctl_drm_i915 (const IOCTLEntry *ie,uint8_t *buf_temp, +int fd,int cmd,abi_long arg) +{ +switch (ie->host_cmd) { +case DRM_IOCTL_I915_GETPARAM : +return do_ioctl_drm_i915_getparam (ie, + (struct drm_i915_getparam *)buf_temp, + fd, arg); +default : +return -TARGET_ENOSYS ; + } +} +#endif IOCTLEntry ioctl_entries[] = {
linux-user/syscall_defs.h +8 -0
@@ -1177,6 +1177,9 @@ struct target_rtc_pll_info {/* drm ioctls */ #define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00) +/* drm i915 ioctls */ +#define TARGET_DRM_IOCTL_I915_GETPARAM TARGET_IOWRU('d', 0x46) +/* from asm/termbits.h */ #define TARGET_NCC 8
@@ -2620,6 +2623,11 @@ struct target_drm_version {abi_ulong desc; }; +struct target_drm_i915_getparam { +int param; +abi_ulong value; +}; +#include "socket.h" #include "errno_defs.h"
linux-user/syscall_types.h +4 -0
@@ -325,6 +325,10 @@ STRUCT(drm_version, TYPE_ULONG, /* desc_len */ TYPE_PTRVOID) /* desc */ +STRUCT (drm_i915_getparam, +TYPE_INT ,/* param */ + TYPE_PTRVOID) /* value */ + STRUCT(file_clone_range, TYPE_LONGLONG, /* src_fd */ TYPE_ULONGLONG, /* src_offset */
Signature · 1 line
2.26.2
[PULL 05/18] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid()
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch implements strace argument printing functionality for following syscalls:
* truncate, ftruncate - truncate a file to a specified length
int truncate/truncate64(const char *path, off_t length) int ftruncate/ftruncate64(int fd, off_t length)
man page: https://man7.org/linux/man-pages/man2/truncate.2.html
* getsid - get session ID
pid_t getsid(pid_t pid)
man page: https://man7.org/linux/man-pages/man2/getsid.2.html
Implementation notes:
Syscalls truncate/truncate64 take string argument types and thus a separate print function "print_truncate/print_truncate64" is stated in file "strace.list". This function is defined and implemented in "strace.c" by using an existing function used to print string arguments: "print_string()". For syscall ftruncate64, a separate printing function was also stated in "strace.c" as it requires a special kind of handling.
The other syscalls have only primitive argument types, so the rest of the implementation was handled by stating an appropriate printing format in file "strace.list".
Function "regpairs_aligned()" was cut & pasted from "syscall.c" to "qemu.h" as it is used by functions "print_truncate64()" and "print_ftruncate64()" to print the offset arguments of "truncate64()" and "ftruncate64()".
Message-Id: <[email protected]>
--- linux-user/qemu.h | 35 +++++++++++++++++++++++++++++++ linux-user/strace.c | 47 ++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 10 ++++----- linux-user/syscall.c | 32 ---------------------------- 4 files changed, 87 insertions(+), 37 deletions(-)
linux-user/qemu.h +35 -0
@@ -706,6 +706,41 @@ static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) }#endif /* TARGET_ABI_BITS != 32 */ + +/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ +#ifdef TARGET_ARM +static inline int regpairs_aligned (void *cpu_env,int num) +{ +return ((((CPUARMState *)cpu_env)->eabi) ==1 ) ; +} +#elif defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 ) +static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } +#elif defined(TARGET_PPC ) && !defined(TARGET_PPC64 ) +/* +* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs +* of registers which translates to the same as ARM/MIPS, because we start with +* r3 as arg1 +*/ +static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } +#elif defined(TARGET_SH4 ) +/* SH4 doesn't align register pairs, except for p{read,write}64 */ +static inline int regpairs_aligned (void *cpu_env,int num) +{ +switch (num) { +case TARGET_NR_pread64: +case TARGET_NR_pwrite64: +return 1 ; + +default : +return 0 ; + } +} +#elif defined(TARGET_XTENSA ) +static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } +#else +static inline int regpairs_aligned (void *cpu_env,int num) {return 0 ; } +#endif +/** * preexit_cleanup: housekeeping before the guest exits *
linux-user/strace.c +47 -0
53 lines not on this page · raw message
linux-user/strace.list +5 -5
@@ -258,10 +258,10 @@ { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_ftruncate -{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL }, +{ TARGET_NR_ftruncate, "ftruncate" , "%s(%d," TARGET_ABI_FMT_ld ")", NULL, NULL }, #endif #ifdef TARGET_NR_ftruncate64 -{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL }, +{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, print_ftruncate64, NULL }, #endif #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL },
@@ -372,7 +372,7 @@ { TARGET_NR_getrusage, "getrusage" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getsid -{ TARGET_NR_getsid, "getsid" , NULL, NULL, NULL }, +{ TARGET_NR_getsid, "getsid" , "%s(%d)", NULL, NULL }, #endif #ifdef TARGET_NR_getsockname { TARGET_NR_getsockname, "getsockname" , NULL, NULL, NULL },
@@ -1535,10 +1535,10 @@ { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL }, #endif #ifdef TARGET_NR_truncate -{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL }, +{ TARGET_NR_truncate, "truncate" , NULL, print_truncate, NULL }, #endif #ifdef TARGET_NR_truncate64 -{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL }, +{ TARGET_NR_truncate64, "truncate64" , NULL, print_truncate64, NULL }, #endif #ifdef TARGET_NR_tuxcall { TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL },
linux-user/syscall.c +0 -32
@@ -495,38 +495,6 @@ static inline int next_free_host_timer(void) }#endif -/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ -#ifdef TARGET_ARM -static inline int regpairs_aligned (void *cpu_env,int num) -{ -return ((((CPUARMState *)cpu_env)->eabi) ==1 ) ; -} -#elif defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 ) -static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } -#elif defined(TARGET_PPC ) && !defined(TARGET_PPC64 ) -/* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs -* of registers which translates to the same as ARM/MIPS, because we start with -* r3 as arg1 */ -static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } -#elif defined(TARGET_SH4 ) -/* SH4 doesn't align register pairs, except for p{read,write}64 */ -static inline int regpairs_aligned (void *cpu_env,int num) -{ -switch (num) { -case TARGET_NR_pread64: -case TARGET_NR_pwrite64: -return 1 ; - -default : -return 0 ; - } -} -#elif defined(TARGET_XTENSA ) -static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } -#else -static inline int regpairs_aligned (void *cpu_env,int num) {return 0 ; } -#endif -#define ERRNO_TABLE_SIZE 1200/* target_to_host_errno_table[] is initialized from
Signature · 1 line
2.26.2
[PULL 16/18] linux-user: Add support for 'clock_nanosleep_time64()' and 'clock_adjtime64()'
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch implements functionality for following time64 syscall:
*clock_nanosleep_time64()
This is a year 2038 safe vairant of syscall:
int clock_nanosleep(clockid_t clockid, int flags,
const struct timespec *request,
struct timespec *remain)
--high-resolution sleep with specifiable clock--
man page: https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html
*clock_adjtime64()
This is a year 2038 safe variant of syscall:
int clock_adjtime(clockid_t clk_id, struct timex *buf) --tune kernel clock--
man page: https://man7.org/linux/man-pages/man2/clock_adjtime.2.html
Implementation notes:
Syscall 'clock_nanosleep_time64()' was implemented similarly to syscall 'clock_nanosleep()' except that 'host_to_target_timespec64()' and 'target_to_host_timespec64()' were used instead of the regular 'host_to_target_timespec()' and 'target_to_host_timespec()'.
For 'clock_adjtime64()' a 64-bit target kernel version of 'struct timex' was defined in 'syscall_defs.h': 'struct target__kernel_timex'. This type was used to convert the values of 64-bit timex type between host and target. For this purpose a 64-bit timex converting functions 'target_to_host_timex64()' and 'host_to_target_timex64()'. An existing function 'copy_to_user_timeval64()' was used to convert the field 'time' which if of type 'struct timeval' from host to target. Function 'copy_from_user_timveal64()' was added in this patch and used to convert the 'time' field from target to host.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 140 +++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 31 +++++++++ 2 files changed, 168 insertions(+), 3 deletions(-)
linux-user/syscall.c +137 -3
@@ -774,7 +774,8 @@ safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *, len, safe_syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem)#endif -#ifdef TARGET_NR_clock_nanosleep +#if defined(TARGET_NR_clock_nanosleep) || \ + defined(TARGET_NR_clock_nanosleep_time64) safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags, const struct timespec *, req, struct timespec *, rem)#endif
@@ -1177,8 +1178,25 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,return 0 ; } +static inline abi_long copy_from_user_timeval64 (struct timeval *tv, +abi_ulong target_tv_addr) +{ +struct target__kernel_sock_timeval *target_tv; + +if (!lock_user_struct (VERIFY_READ , target_tv, target_tv_addr,1 )) { +return -TARGET_EFAULT ; + } + +__get_user (tv->tv_sec, &target_tv->tv_sec); +__get_user (tv->tv_usec, &target_tv->tv_usec); + +unlock_user_struct (target_tv, target_tv_addr,0 ); + +return 0 ; +} +static inline abi_long copy_to_user_timeval64 (abi_ulong target_tv_addr, -const struct timeval *tv) +const struct timeval *tv) {struct target__kernel_sock_timeval *target_tv;
@@ -1222,7 +1240,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts,defined (TARGET_NR_timer_settime64) || \defined (TARGET_NR_mq_timedsend_time64) || \defined (TARGET_NR_mq_timedreceive_time64) || \ - (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) + (defined (TARGET_NR_timerfd_settime64) &&defined (CONFIG_TIMERFD )) || \ + defined(TARGET_NR_clock_nanosleep_time64)static inline abi_long target_to_host_timespec64 (struct timespec *host_ts,abi_ulong target_addr) {
@@ -6953,6 +6972,87 @@ static inline abi_long host_to_target_timex(abi_long target_addr, }#endif + +#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME ) +static inline abi_long target_to_host_timex64 (struct timex *host_tx, +abi_long target_addr) +{ +struct target__kernel_timex *target_tx; + +if (copy_from_user_timeval64 (&host_tx->time, target_addr + + offsetof(struct target__kernel_timex , + time))) { +return -TARGET_EFAULT ; + } + +if (!lock_user_struct (VERIFY_READ , target_tx, target_addr,1 )) { +return -TARGET_EFAULT ; + } + +__get_user (host_tx->modes, &target_tx->modes); +__get_user (host_tx->offset, &target_tx->offset); +__get_user (host_tx->freq, &target_tx->freq); +__get_user (host_tx->maxerror, &target_tx->maxerror); +__get_user (host_tx->esterror, &target_tx->esterror); +__get_user (host_tx->status, &target_tx->status); +__get_user (host_tx->constant, &target_tx->constant); +__get_user (host_tx->precision, &target_tx->precision); +__get_user (host_tx->tolerance, &target_tx->tolerance); +__get_user (host_tx->tick, &target_tx->tick); +__get_user (host_tx->ppsfreq, &target_tx->ppsfreq); +__get_user (host_tx->jitter, &target_tx->jitter); +__get_user (host_tx->shift, &target_tx->shift); +__get_user (host_tx->stabil, &target_tx->stabil); +__get_user (host_tx->jitcnt, &target_tx->jitcnt); +__get_user (host_tx->calcnt, &target_tx->calcnt); +__get_user (host_tx->errcnt, &target_tx->errcnt); +__get_user (host_tx->stbcnt, &target_tx->stbcnt); +__get_user (host_tx->tai, &target_tx->tai); + +unlock_user_struct (target_tx, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_timex64 (abi_long target_addr, +struct timex *host_tx) +{ +struct target__kernel_timex *target_tx; + +if (copy_to_user_timeval64 (target_addr + + offsetof(struct target__kernel_timex , time), + &host_tx->time)) { +return -TARGET_EFAULT ; + } + +if (!lock_user_struct (VERIFY_WRITE , target_tx, target_addr,0 )) { +return -TARGET_EFAULT ; + } + +__put_user (host_tx->modes, &target_tx->modes); +__put_user (host_tx->offset, &target_tx->offset); +__put_user (host_tx->freq, &target_tx->freq); +__put_user (host_tx->maxerror, &target_tx->maxerror); +__put_user (host_tx->esterror, &target_tx->esterror); +__put_user (host_tx->status, &target_tx->status); +__put_user (host_tx->constant, &target_tx->constant); +__put_user (host_tx->precision, &target_tx->precision); +__put_user (host_tx->tolerance, &target_tx->tolerance); +__put_user (host_tx->tick, &target_tx->tick); +__put_user (host_tx->ppsfreq, &target_tx->ppsfreq); +__put_user (host_tx->jitter, &target_tx->jitter); +__put_user (host_tx->shift, &target_tx->shift); +__put_user (host_tx->stabil, &target_tx->stabil); +__put_user (host_tx->jitcnt, &target_tx->jitcnt); +__put_user (host_tx->calcnt, &target_tx->calcnt); +__put_user (host_tx->errcnt, &target_tx->errcnt); +__put_user (host_tx->stbcnt, &target_tx->stbcnt); +__put_user (host_tx->tai, &target_tx->tai); + +unlock_user_struct (target_tx, target_addr,1 ); +return 0 ; +} +#endif +static inline abi_long target_to_host_sigevent (struct sigevent *host_sevp,abi_ulong target_addr) {
@@ -9940,6 +10040,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } }return ret; +#endif +#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME ) +case TARGET_NR_clock_adjtime64: + { +struct timex htx; + +if (target_to_host_timex64 (&htx, arg2) !=0 ) { +return -TARGET_EFAULT ; + } + ret =get_errno (clock_adjtime (arg1, &htx)); +if (!is_error (ret) &&host_to_target_timex64 (arg2, &htx)) { +return -TARGET_EFAULT ; + } + } +return ret;#endif case TARGET_NR_getpgid:return get_errno (getpgid (arg1));
@@ -11911,6 +12026,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; }#endif +#ifdef TARGET_NR_clock_nanosleep_time64 +case TARGET_NR_clock_nanosleep_time64: + { +struct timespec ts; + +if (target_to_host_timespec64 (&ts, arg3)) { +return -TARGET_EFAULT ; + } + + ret =get_errno (safe_clock_nanosleep (arg1, arg2, + &ts, arg4 ? &ts :NULL )); + +if (ret == -TARGET_EINTR && arg4 && arg2 !=TIMER_ABSTIME && +host_to_target_timespec64 (arg4, &ts)) { +return -TARGET_EFAULT ; + } +return ret; + } +#endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)case TARGET_NR_set_tid_address:
linux-user/syscall_defs.h +31 -0
@@ -294,6 +294,37 @@ struct target_timex { abi_int:32 ; abi_int:32 ; abi_int:32 ; }; +struct target__kernel_timex { +abi_uint modes;/* Mode selector */ + abi_int: 32; /* pad */ +abi_llong offset;/* Time offset */ +abi_llong freq;/* Frequency offset */ +abi_llong maxerror;/* Maximum error (microseconds) */ +abi_llong esterror;/* Estimated error (microseconds) */ +abi_int status;/* Clock command/status */ + abi_int: 32; /* pad */ +abi_llong constant;/* PLL (phase-locked loop) time constant */ +abi_llong precision;/* Clock precision (microseconds, ro) */ +abi_llong tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target__kernel_sock_timeval time;/* Current time */ +abi_llong tick;/* Microseconds between clock ticks */ +abi_llong ppsfreq;/* PPS (pulse per second) frequency */ +abi_llong jitter;/* PPS jitter (ro); nanoseconds */ +abi_int shift;/* PPS interval duration (seconds) */ + abi_int: 32; /* pad */ +abi_llong stabil;/* PPS stability */ +abi_llong jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_llong calcnt;/* PPS calibration intervals */ +abi_llong errcnt;/* PPS calibration errors */ +abi_llong stbcnt;/* PPS stability limit exceeded */ +abi_int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + abi_int:32; abi_int:32; abi_int:32; abi_int:32; + abi_int:32; abi_int:32; abi_int:32; abi_int:32; + abi_int:32; abi_int:32; abi_int:32; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100
Signature · 1 line
2.26.2
[PULL 04/18] linux-user: Make cpu_env accessible in strace.c
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
Variable "cpu_env" is used in file "syscall.c" to store the information about the cpu environment. This variable is used because values of some syscalls can vary between cpu architectures. This patch makes the "cpu_env" accessible in "strace.c" so it can enable aproppriate "-strace" argument printing for these syscalls. This will be a useful addition for future "-strace" implementation in QEMU.
Implementation notes:
Functions "print_syscall()" and "print_syscall_ret()" which are stated and defined in "qemu.h" and "strace.c" respectively are used to print syscall arguments before and after syscall execution. These functions were changed with addition of a new argument "void *cpu_env". Strucute "struct syscallname" in "strace.c" is used to store the information about syscalls. Fields "call" and "result" represent pointers to functions which are used to print syscall arguments before and after execution. These fields were also changed with addition of a new "void *" argumetn.
Also, all defined "print_*" and "print_syscall_ret*" functions in "strace.c" were changed to have the new "void *cpu_env". This was done to not cause build errors (even though none of these functions use this argument).
Message-Id: <[email protected]>
--- linux-user/qemu.h | 4 +- linux-user/strace.c | 479 ++++++++++++++++++++++--------------------- linux-user/syscall.c | 5 +- 3 files changed, 247 insertions(+), 241 deletions(-)
linux-user/qemu.h +2 -2
@@ -400,10 +400,10 @@ extern long safe_syscall_base(int *pending, long number, ...);int host_to_target_waitstatus (int status);/* strace.c */ -void print_syscall (int num, +void print_syscall (void *cpu_env,int num,abi_long arg1,abi_long arg2,abi_long arg3,abi_long arg4,abi_long arg5,abi_long arg6); -void print_syscall_ret (int num,abi_long ret, +void print_syscall_ret (void *cpu_env,int num,abi_long ret,abi_long arg1,abi_long arg2,abi_long arg3,abi_long arg4,abi_long arg5,abi_long arg6);/**
linux-user/strace.c +242 -237
1,009 lines not on this page · raw message
linux-user/syscall.c +3 -2
@@ -12769,14 +12769,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);if (unlikely (qemu_loglevel_mask (LOG_STRACE ))) { -print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); +print_syscall (cpu_env, num, arg1, arg2, arg3, arg4, arg5, arg6); } ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);if (unlikely (qemu_loglevel_mask (LOG_STRACE ))) { -print_syscall_ret (num, ret, arg1, arg2, arg3, arg4, arg5, arg6); +print_syscall_ret (cpu_env, num, ret, arg1, arg2, + arg3, arg4, arg5, arg6); }record_syscall_return (cpu, num, ret);
Signature · 1 line
2.26.2
[PULL 10/18] linux-user: Add missing termbits types and values definitions
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch introduces missing target types ('target_flag_t', 'target_cc_t', 'target_speed_t') in a few 'termibts.h' header files. Also, two missing values ('TARGET_IUTF8' and 'TARGET_EXTPROC') were also added. These values were also added in file 'syscall.c' in bitmask tables 'iflag_tbl[]' and 'lflag_tbl[]' which are used to convert values of 'struct termios' between target and host.
Message-Id: <[email protected]>
--- linux-user/alpha/termbits.h | 1 + linux-user/cris/termbits.h | 18 ++++++++---- linux-user/hppa/termbits.h | 17 +++++++---- linux-user/mips/termbits.h | 17 +++++++---- linux-user/ppc/termbits.h | 21 ++++++++----- linux-user/sh4/termbits.h | 19 ++++++++---- linux-user/sparc/termbits.h | 18 ++++++++---- linux-user/sparc64/termbits.h | 18 ++++++++---- linux-user/syscall.c | 34 ++++++++++++---------- linux-user/xtensa/termbits.h | 55 ++++++++++++++++++----------------- 10 files changed, 132 insertions(+), 86 deletions(-)
linux-user/alpha/termbits.h +1 -0
@@ -159,6 +159,7 @@ struct target_termios {#define TARGET_FLUSHO 0x00800000#define TARGET_PENDIN 0x20000000#define TARGET_IEXTEN 0x00000400 +#define TARGET_EXTPROC 0x10000000#define TARGET_FIOCLEX TARGET_IO('f', 1)#define TARGET_FIONCLEX TARGET_IO('f', 2)
linux-user/cris/termbits.h +12 -6
@@ -5,13 +5,17 @@#define TARGET_NCCS 19 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ };/* c_iflag bits */
@@ -29,6 +33,7 @@ struct target_termios {#define TARGET_IXANY 0004000#define TARGET_IXOFF 0010000#define TARGET_IMAXBEL 0020000 +#define TARGET_IUTF8 0040000/* c_oflag bits */ #define TARGET_OPOST 0000001
@@ -118,6 +123,7 @@ struct target_termios {#define TARGET_FLUSHO 0010000#define TARGET_PENDIN 0040000#define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000/* c_cc character offsets */ #define TARGET_VINTR 0
linux-user/hppa/termbits.h +11 -6
@@ -5,13 +5,17 @@#define TARGET_NCCS 19 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ };/* c_iflag bits */
@@ -120,6 +124,7 @@ struct target_termios {#define TARGET_FLUSHO 0010000#define TARGET_PENDIN 0040000#define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000/* c_cc character offsets */ #define TARGET_VINTR 0
linux-user/mips/termbits.h +11 -6
@@ -5,13 +5,17 @@#define TARGET_NCCS 23 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ };/* c_iflag bits */
@@ -133,6 +137,7 @@ struct target_termios {#define TARGET_PENDIN 0040000#define TARGET_TOSTOP 0100000#define TARGET_ITOSTOP TARGET_TOSTOP +#define TARGET_EXTPROC 0200000/* c_cc character offsets */ #define TARGET_VINTR 0
linux-user/ppc/termbits.h +13 -8
@@ -5,15 +5,19 @@#define TARGET_NCCS 19 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ -unsigned char c_line;/* line discipline */ -unsigned int c_ispeed;/* input speed */ -unsigned int c_ospeed;/* output speed */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ +target_speed_t c_ispeed;/* input speed */ +target_speed_t c_ospeed;/* output speed */ };/* c_cc character offsets */
@@ -158,6 +162,7 @@ struct target_termios {#define TARGET_FLUSHO 0x00800000#define TARGET_PENDIN 0x20000000#define TARGET_IEXTEN 0x00000400 +#define TARGET_EXTPROC 0x10000000/* ioctls */
linux-user/sh4/termbits.h +13 -6
@@ -5,15 +5,20 @@#define TARGET_NCCS 19 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ }; +/* c_cc characters */ #define TARGET_VINTR 0#define TARGET_VQUIT 1
@@ -150,6 +155,8 @@ struct target_termios {#define TARGET_FLUSHO 0010000#define TARGET_PENDIN 0040000#define TARGET_IEXTEN 0100000 +#define TARGET_EXTPROC 0200000 +/* tcflow() and TCXONC use these */ #define TARGET_TCOOFF 0
linux-user/sparc/termbits.h +12 -6
@@ -5,15 +5,20 @@#define TARGET_NCCS 19 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ }; +/* c_cc characters */ #define TARGET_VINTR 0#define TARGET_VQUIT 1
@@ -170,6 +175,7 @@ struct target_termios {#define TARGET_FLUSHO 0x00002000#define TARGET_PENDIN 0x00004000#define TARGET_IEXTEN 0x00008000 +#define TARGET_EXTPROC 0x00010000/* ioctls */
linux-user/sparc64/termbits.h +12 -6
@@ -5,15 +5,20 @@#define TARGET_NCCS 19 +typedef unsigned char target_cc_t ;/* cc_t */ +typedef unsigned int target_speed_t ;/* speed_t */ +typedef unsigned int target_tcflag_t ;/* tcflag_t */ +struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ +target_tcflag_t c_iflag;/* input mode flags */ +target_tcflag_t c_oflag;/* output mode flags */ +target_tcflag_t c_cflag;/* control mode flags */ +target_tcflag_t c_lflag;/* local mode flags */ +target_cc_t c_line;/* line discipline */ +target_cc_t c_cc[TARGET_NCCS ];/* control characters */ }; +/* c_cc characters */ #define TARGET_VINTR 0#define TARGET_VQUIT 1
@@ -170,6 +175,7 @@ struct target_termios {#define TARGET_FLUSHO 0x00002000#define TARGET_PENDIN 0x00004000#define TARGET_IEXTEN 0x00008000 +#define TARGET_EXTPROC 0x00010000/* ioctls */
linux-user/syscall.c +18 -16
@@ -5549,6 +5549,7 @@ static const bitmask_transtbl iflag_tbl[] = { { TARGET_IXANY, TARGET_IXANY, IXANY, IXANY }, { TARGET_IXOFF, TARGET_IXOFF, IXOFF, IXOFF }, { TARGET_IMAXBEL, TARGET_IMAXBEL, IMAXBEL, IMAXBEL }, + { TARGET_IUTF8, TARGET_IUTF8, IUTF8, IUTF8}, { 0, 0, 0, 0 } };
@@ -5616,22 +5617,23 @@ static const bitmask_transtbl cflag_tbl[] = { };static const bitmask_transtbl lflag_tbl[] = { - {TARGET_ISIG ,TARGET_ISIG ,ISIG ,ISIG }, - {TARGET_ICANON ,TARGET_ICANON ,ICANON ,ICANON }, - {TARGET_XCASE ,TARGET_XCASE ,XCASE ,XCASE }, - {TARGET_ECHO ,TARGET_ECHO ,ECHO ,ECHO }, - {TARGET_ECHOE ,TARGET_ECHOE ,ECHOE ,ECHOE }, - {TARGET_ECHOK ,TARGET_ECHOK ,ECHOK ,ECHOK }, - {TARGET_ECHONL ,TARGET_ECHONL ,ECHONL ,ECHONL }, - {TARGET_NOFLSH ,TARGET_NOFLSH ,NOFLSH ,NOFLSH }, - {TARGET_TOSTOP ,TARGET_TOSTOP ,TOSTOP ,TOSTOP }, - {TARGET_ECHOCTL ,TARGET_ECHOCTL ,ECHOCTL ,ECHOCTL }, - {TARGET_ECHOPRT ,TARGET_ECHOPRT ,ECHOPRT ,ECHOPRT }, - {TARGET_ECHOKE ,TARGET_ECHOKE ,ECHOKE ,ECHOKE }, - {TARGET_FLUSHO ,TARGET_FLUSHO ,FLUSHO ,FLUSHO }, - {TARGET_PENDIN ,TARGET_PENDIN ,PENDIN ,PENDIN }, - {TARGET_IEXTEN ,TARGET_IEXTEN ,IEXTEN ,IEXTEN }, - {0 ,0 ,0 ,0 } + {TARGET_ISIG ,TARGET_ISIG ,ISIG ,ISIG }, + {TARGET_ICANON ,TARGET_ICANON ,ICANON ,ICANON }, + {TARGET_XCASE ,TARGET_XCASE ,XCASE ,XCASE }, + {TARGET_ECHO ,TARGET_ECHO ,ECHO ,ECHO }, + {TARGET_ECHOE ,TARGET_ECHOE ,ECHOE ,ECHOE }, + {TARGET_ECHOK ,TARGET_ECHOK ,ECHOK ,ECHOK }, + {TARGET_ECHONL ,TARGET_ECHONL ,ECHONL ,ECHONL }, + {TARGET_NOFLSH ,TARGET_NOFLSH ,NOFLSH ,NOFLSH }, + {TARGET_TOSTOP ,TARGET_TOSTOP ,TOSTOP ,TOSTOP }, + {TARGET_ECHOCTL ,TARGET_ECHOCTL ,ECHOCTL ,ECHOCTL }, + {TARGET_ECHOPRT ,TARGET_ECHOPRT ,ECHOPRT ,ECHOPRT }, + {TARGET_ECHOKE ,TARGET_ECHOKE ,ECHOKE ,ECHOKE }, + {TARGET_FLUSHO ,TARGET_FLUSHO ,FLUSHO ,FLUSHO }, + {TARGET_PENDIN ,TARGET_PENDIN ,PENDIN ,PENDIN }, + {TARGET_IEXTEN ,TARGET_IEXTEN ,IEXTEN ,IEXTEN }, + {TARGET_EXTPROC ,TARGET_EXTPROC ,EXTPROC ,EXTPROC }, + {0 ,0 ,0 ,0 } };static void target_to_host_termios (void *dst,const void *src)
linux-user/xtensa/termbits.h +29 -26
75 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 09/18] linux-user: Add generic 'termbits.h' for some archs
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch introduces a generic 'termbits.h' file for following
archs: 'aarch64', 'arm', 'i386, 'm68k', 'microblaze', 'nios2', 'openrisc', 'riscv', 's390x', 'x86_64'.
Since all of these archs have the same termios flag values and same ioctl_tty numbers, there is no need for a separate 'termbits.h' file for each one of them. For that reason one generic 'termbits.h' file was added for all of them and an '#include' directive was added for this generic file in every arch 'termbits.h' file.
Also, some of the flag values that were missing were added in this generic file so that it matches the generic 'termibts.h' and 'ioctls.h' files from the kernel: 'asm-generic/termbits.h' and 'asm-generic/ioctls.h'.
Message-Id: <[email protected]>
--- linux-user/aarch64/termbits.h | 228 +--------------------- linux-user/arm/termbits.h | 223 +--------------------- linux-user/generic/termbits.h | 318 +++++++++++++++++++++++++++++++ linux-user/i386/termbits.h | 233 +--------------------- linux-user/m68k/termbits.h | 234 +---------------------- linux-user/microblaze/termbits.h | 220 +-------------------- linux-user/nios2/termbits.h | 228 +--------------------- linux-user/openrisc/termbits.h | 302 +---------------------------- linux-user/riscv/termbits.h | 228 +--------------------- linux-user/s390x/termbits.h | 289 +--------------------------- linux-user/tilegx/termbits.h | 276 +-------------------------- linux-user/x86_64/termbits.h | 254 +----------------------- 12 files changed, 329 insertions(+), 2704 deletions(-) create mode 100644 linux-user/generic/termbits.h
linux-user/aarch64/termbits.h +1 -227
@@ -1,227 +1 @@ -/* from asm/termbits.h */ -/* NOTE: exactly the same as i386 */ - -#ifndef LINUX_USER_AARCH64_TERMBITS_H -#define LINUX_USER_AARCH64_TERMBITS_H - -#define TARGET_NCCS 19 - -struct target_termios { -unsigned int c_iflag;/* input mode flags */ -unsigned int c_oflag;/* output mode flags */ -unsigned int c_cflag;/* control mode flags */ -unsigned int c_lflag;/* local mode flags */ -unsigned char c_line;/* line discipline */ -unsigned char c_cc[TARGET_NCCS ];/* control characters */ -}; - -/* c_iflag bits */ -#define TARGET_IGNBRK 0000001 -#define TARGET_BRKINT 0000002 -#define TARGET_IGNPAR 0000004 -#define TARGET_PARMRK 0000010 -#define TARGET_INPCK 0000020 -#define TARGET_ISTRIP 0000040 -#define TARGET_INLCR 0000100 -#define TARGET_IGNCR 0000200 -#define TARGET_ICRNL 0000400 -#define TARGET_IUCLC 0001000 -#define TARGET_IXON 0002000 -#define TARGET_IXANY 0004000 -#define TARGET_IXOFF 0010000 -#define TARGET_IMAXBEL 0020000 -#define TARGET_IUTF8 0040000 - -/* c_oflag bits */ -#define TARGET_OPOST 0000001 -#define TARGET_OLCUC 0000002 -#define TARGET_ONLCR 0000004 -#define TARGET_OCRNL 0000010 -#define TARGET_ONOCR 0000020 -#define TARGET_ONLRET 0000040 -#define TARGET_OFILL 0000100 -#define TARGET_OFDEL 0000200 -#define TARGET_NLDLY 0000400 -#define TARGET_NL0 0000000 -#define TARGET_NL1 0000400 -#define TARGET_CRDLY 0003000 -#define TARGET_CR0 0000000 -#define TARGET_CR1 0001000 -#define TARGET_CR2 0002000 -#define TARGET_CR3 0003000 -#define TARGET_TABDLY 0014000 -#define TARGET_TAB0 0000000 -#define TARGET_TAB1 0004000 -#define TARGET_TAB2 0010000 -#define TARGET_TAB3 0014000 -#define TARGET_XTABS 0014000 -#define TARGET_BSDLY 0020000 -#define TARGET_BS0 0000000 -#define TARGET_BS1 0020000 -#define TARGET_VTDLY 0040000 -#define TARGET_VT0 0000000 -#define TARGET_VT1 0040000 -#define TARGET_FFDLY 0100000 -#define TARGET_FF0 0000000 -#define TARGET_FF1 0100000 - -/* c_cflag bit meaning */ -#define TARGET_CBAUD 0010017 -#define TARGET_B0 0000000/* hang up */ -#define TARGET_B50 0000001 -#define TARGET_B75 0000002 -#define TARGET_B110 0000003 -#define TARGET_B134 0000004 -#define TARGET_B150 0000005 -#define TARGET_B200 0000006 -#define TARGET_B300 0000007 -#define TARGET_B600 0000010 -#define TARGET_B1200 0000011 -#define TARGET_B1800 0000012 -#define TARGET_B2400 0000013 -#define TARGET_B4800 0000014 -#define TARGET_B9600 0000015 -#define TARGET_B19200 0000016 -#define TARGET_B38400 0000017 -#define TARGET_EXTA B19200 -#define TARGET_EXTB B38400 -#define TARGET_CSIZE 0000060 -#define TARGET_CS5 0000000 -#define TARGET_CS6 0000020 -#define TARGET_CS7 0000040 -#define TARGET_CS8 0000060 -#define TARGET_CSTOPB 0000100 -#define TARGET_CREAD 0000200 -#define TARGET_PARENB 0000400 -#define TARGET_PARODD 0001000 -#define TARGET_HUPCL 0002000 -#define TARGET_CLOCAL 0004000 -#define TARGET_CBAUDEX 0010000 -#define TARGET_B57600 0010001 -#define TARGET_B115200 0010002 -#define TARGET_B230400 0010003 -#define TARGET_B460800 0010004 -#define TARGET_CIBAUD 002003600000/* input baud rate (not used) */ -#define TARGET_CMSPAR 010000000000/* mark or space (stick) parity */ -#define TARGET_CRTSCTS 020000000000/* flow control */ - -/* c_lflag bits */ -#define TARGET_ISIG 0000001 -#define TARGET_ICANON 0000002 -#define TARGET_XCASE 0000004 -#define TARGET_ECHO 0000010 -#define TARGET_ECHOE 0000020 -#define TARGET_ECHOK 0000040 -#define TARGET_ECHONL 0000100 -#define TARGET_NOFLSH 0000200 -#define TARGET_TOSTOP 0000400 -#define TARGET_ECHOCTL 0001000 -#define TARGET_ECHOPRT 0002000 -#define TARGET_ECHOKE 0004000 -#define TARGET_FLUSHO 0010000 -#define TARGET_PENDIN 0040000 -#define TARGET_IEXTEN 0100000 - -/* c_cc character offsets */ -#define TARGET_VINTR 0 -#define TARGET_VQUIT 1 -#define TARGET_VERASE 2 -#define TARGET_VKILL 3 -#define TARGET_VEOF 4 -#define TARGET_VTIME 5 -#define TARGET_VMIN 6 -#define TARGET_VSWTC 7 -#define TARGET_VSTART 8 -#define TARGET_VSTOP 9 -#define TARGET_VSUSP 10 -#define TARGET_VEOL 11 -#define TARGET_VREPRINT 12 -#define TARGET_VDISCARD 13 -#define TARGET_VWERASE 14 -#define TARGET_VLNEXT 15 -#define TARGET_VEOL2 16 - -/* ioctls */ - -#define TARGET_TCGETS 0x5401 -#define TARGET_TCSETS 0x5402 -#define TARGET_TCSETSW 0x5403 -#define TARGET_TCSETSF 0x5404 -#define TARGET_TCGETA 0x5405 -#define TARGET_TCSETA 0x5406 -#define TARGET_TCSETAW 0x5407 -#define TARGET_TCSETAF 0x5408 -#define TARGET_TCSBRK 0x5409 -#define TARGET_TCXONC 0x540A -#define TARGET_TCFLSH 0x540B - -#define TARGET_TIOCEXCL 0x540C -#define TARGET_TIOCNXCL 0x540D -#define TARGET_TIOCSCTTY 0x540E -#define TARGET_TIOCGPGRP 0x540F -#define TARGET_TIOCSPGRP 0x5410 -#define TARGET_TIOCOUTQ 0x5411 -#define TARGET_TIOCSTI 0x5412 -#define TARGET_TIOCGWINSZ 0x5413 -#define TARGET_TIOCSWINSZ 0x5414 -#define TARGET_TIOCMGET 0x5415 -#define TARGET_TIOCMBIS 0x5416 -#define TARGET_TIOCMBIC 0x5417 -#define TARGET_TIOCMSET 0x5418 -#define TARGET_TIOCGSOFTCAR 0x5419 -#define TARGET_TIOCSSOFTCAR 0x541A -#define TARGET_FIONREAD 0x541B -#define TARGET_TIOCINQ TARGET_FIONREAD -#define TARGET_TIOCLINUX 0x541C -#define TARGET_TIOCCONS 0x541D -#define TARGET_TIOCGSERIAL 0x541E -#define TARGET_TIOCSSERIAL 0x541F -#define TARGET_TIOCPKT 0x5420 -#define TARGET_FIONBIO 0x5421 -#define TARGET_TIOCNOTTY 0x5422 -#define TARGET_TIOCSETD 0x5423 -#define TARGET_TIOCGETD 0x5424 -#define TARGET_TCSBRKP 0x5425/* Needed for POSIX tcsendbreak() */ -#define TARGET_TIOCTTYGSTRUCT 0x5426/* For debugging only */ -#define TARGET_TIOCSBRK 0x5427/* BSD compatibility */ -#define TARGET_TIOCCBRK 0x5428/* BSD compatibility */ -#define TARGET_TIOCGSID 0x5429/* Return the session ID of FD */ -#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) -/* Get Pty Number (of pty-mux device) */ -#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) -/* Lock/unlock Pty */ -#define TARGET_TIOCGPTPEER TARGET_IO('T', 0x41) -/* Safely open the slave */ - -#define TARGET_FIONCLEX 0x5450/* these numbers need to be adjusted. */ -#define TARGET_FIOCLEX 0x5451 -#define TARGET_FIOASYNC 0x5452 -#define TARGET_TIOCSERCONFIG 0x5453 -#define TARGET_TIOCSERGWILD 0x5454 -#define TARGET_TIOCSERSWILD 0x5455 -#define TARGET_TIOCGLCKTRMIOS 0x5456 -#define TARGET_TIOCSLCKTRMIOS 0x5457 -#define TARGET_TIOCSERGSTRUCT 0x5458/* For debugging only */ -#define TARGET_TIOCSERGETLSR 0x5459/* Get line status register */ -#define TARGET_TIOCSERGETMULTI 0x545A/* Get multiport config */ -#define TARGET_TIOCSERSETMULTI 0x545B/* Set multiport config */ - -#define TARGET_TIOCMIWAIT 0x545C -/* wait for a change on serial input line(s) */ -#define TARGET_TIOCGICOUNT 0x545D -/* read serial port inline interrupt counts */ -#define TARGET_TIOCGHAYESESP 0x545E/* Get Hayes ESP configuration */ -#define TARGET_TIOCSHAYESESP 0x545F/* Set Hayes ESP configuration */ - -/* Used for packet mode */ -#define TARGET_TIOCPKT_DATA 0 -#define TARGET_TIOCPKT_FLUSHREAD 1 -#define TARGET_TIOCPKT_FLUSHWRITE 2 -#define TARGET_TIOCPKT_STOP 4 -#define TARGET_TIOCPKT_START 8 -#define TARGET_TIOCPKT_NOSTOP 16 -#define TARGET_TIOCPKT_DOSTOP 32 - -#define TARGET_TIOCSER_TEMT 0x01/* Transmitter physically empty */ - -#endif +#include "../generic/termbits.h"
linux-user/arm/termbits.h +1 -222
223 lines not on this page · raw message
linux-user/generic/termbits.h new file +318 -0
318 lines not on this page · raw message
linux-user/i386/termbits.h +1 -232
233 lines not on this page · raw message
linux-user/m68k/termbits.h +1 -233
234 lines not on this page · raw message
linux-user/microblaze/termbits.h +1 -219
220 lines not on this page · raw message
linux-user/nios2/termbits.h +1 -227
228 lines not on this page · raw message
linux-user/openrisc/termbits.h +1 -301
302 lines not on this page · raw message
linux-user/riscv/termbits.h +1 -227
228 lines not on this page · raw message
linux-user/s390x/termbits.h +1 -288
289 lines not on this page · raw message
linux-user/tilegx/termbits.h +1 -275
276 lines not on this page · raw message
linux-user/x86_64/termbits.h +1 -253
221 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2
Part of the diff is not shown here. View the raw message.
[PULL 06/18] linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch implements strace argument printing functionality for following syscalls:
* mlock, munlock, mlockall, munlockall - lock and unlock memory
int mlock(const void *addr, size_t len)
int munlock(const void *addr, size_t len)
int mlockall(int flags)
int munlockall(void)
man page: https://man7.org/linux/man-pages/man2/mlock.2.html
Implementation notes:
Syscall mlockall() takes an argument that is composed of predefined values which represent flags that determine the type of locking operation that is to be performed. For that reason, a printing function "print_mlockall" was stated in file "strace.list". This printing function uses an already existing function "print_flags()" to print the "flags" argument. These flags are stated inside an array "mlockall_flags" that contains values of type "struct flags". These values are instantiated using an existing macro "FLAG_TARGET()" that crates aproppriate target flag values based on those defined in files '/target_syscall.h'. These target flag values were changed from "TARGET_MLOCKALL_MCL*" to "TARGET_MCL_*" so that they can be aproppriately set and recognised in "strace.c" with "FLAG_TARGET()". Value for "MCL_ONFAULT" was added in this patch. This value was also added in "syscall.c" in function "target_to_host_mlockall_arg()". Because this flag value was added in kernel version 4.4, it is enwrapped in an #ifdef directive (both in "syscall.c" and in "strace.c") as to support older kernel versions.
The other syscalls have only primitive argument types, so the
rest of the implementation was handled by stating an appropriate printing format in file "strace.list". Syscall mlock2() is not implemented in "syscall.c" and thus it's argument printing is not implemented in this patch.
Message-Id: <[email protected]>
--- linux-user/aarch64/target_syscall.h | 5 +++-- linux-user/alpha/target_syscall.h | 5 +++-- linux-user/arm/target_syscall.h | 6 ++++-- linux-user/cris/target_syscall.h | 5 +++-- linux-user/hppa/target_syscall.h | 5 +++-- linux-user/i386/target_syscall.h | 5 +++-- linux-user/m68k/target_syscall.h | 6 +++--- linux-user/microblaze/target_syscall.h | 5 +++-- linux-user/mips/target_syscall.h | 5 +++-- linux-user/mips64/target_syscall.h | 5 +++-- linux-user/nios2/target_syscall.h | 5 +++-- linux-user/openrisc/target_syscall.h | 5 +++-- linux-user/ppc/target_syscall.h | 5 +++-- linux-user/riscv/target_syscall.h | 5 +++-- linux-user/s390x/target_syscall.h | 5 +++-- linux-user/sh4/target_syscall.h | 5 +++-- linux-user/sparc/target_syscall.h | 5 +++-- linux-user/sparc64/target_syscall.h | 5 +++-- linux-user/strace.c | 21 +++++++++++++++++++++ linux-user/strace.list | 8 ++++---- linux-user/syscall.c | 10 ++++++++-- linux-user/tilegx/target_syscall.h | 5 +++-- linux-user/x86_64/target_syscall.h | 5 +++-- linux-user/xtensa/target_syscall.h | 5 +++-- 24 files changed, 97 insertions(+), 49 deletions(-)
linux-user/aarch64/target_syscall.h +3 -2
@@ -16,8 +16,9 @@ struct target_pt_regs {#define UNAME_MINIMUM_RELEASE "3.8.0"#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_PR_SVE_SET_VL 50#define TARGET_PR_SVE_GET_VL 51
linux-user/alpha/target_syscall.h +3 -2
@@ -258,7 +258,8 @@ struct target_pt_regs {#define TARGET_UAC_NOFIX 2#define TARGET_UAC_SIGBUS 4#define TARGET_MINSIGSTKSZ 4096 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000#endif /* ALPHA_TARGET_SYSCALL_H */
linux-user/arm/target_syscall.h +4 -2
@@ -28,8 +28,10 @@ struct target_pt_regs {#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 +#define TARGET_WANT_OLD_SYS_SELECT #define TARGET_FORCE_SHMLBA
linux-user/cris/target_syscall.h +3 -2
@@ -40,7 +40,8 @@ struct target_pt_regs {#define TARGET_CLONE_BACKWARDS2 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#endif
linux-user/hppa/target_syscall.h +3 -2
@@ -23,8 +23,9 @@ struct target_pt_regs {#define UNAME_MINIMUM_RELEASE "2.6.32"#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#undef TARGET_ENOMSG#define TARGET_ENOMSG 35
linux-user/i386/target_syscall.h +3 -2
@@ -151,8 +151,9 @@ struct target_vm86plus_struct {#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_WANT_OLD_SYS_SELECT #endif /* I386_TARGET_SYSCALL_H */
linux-user/m68k/target_syscall.h +3 -3
@@ -21,9 +21,9 @@ struct target_pt_regs {#define UNAME_MINIMUM_RELEASE "2.6.32"#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 - +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_WANT_OLD_SYS_SELECT #endif /* M68K_TARGET_SYSCALL_H */
linux-user/microblaze/target_syscall.h +3 -2
@@ -50,8 +50,9 @@ struct target_pt_regs {#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_WANT_NI_OLD_SELECT
linux-user/mips/target_syscall.h +3 -2
@@ -234,8 +234,9 @@ struct target_pt_regs {#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_FORCE_SHMLBA
linux-user/mips64/target_syscall.h +3 -2
@@ -231,8 +231,9 @@ struct target_pt_regs {#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_FORCE_SHMLBA
linux-user/nios2/target_syscall.h +3 -2
@@ -31,7 +31,8 @@ struct target_pt_regs { };#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#endif /* NIOS2_TARGET_SYSCALL_H */
linux-user/openrisc/target_syscall.h +3 -2
@@ -16,8 +16,9 @@ struct target_pt_regs {#define UNAME_MINIMUM_RELEASE "2.6.32"#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define MMAP_SHIFT TARGET_PAGE_BITS
linux-user/ppc/target_syscall.h +3 -2
@@ -72,8 +72,9 @@ struct target_revectored_struct {#define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000#define TARGET_WANT_NI_OLD_SELECT #endif /* PPC_TARGET_SYSCALL_H */
linux-user/riscv/target_syscall.h +3 -2
@@ -51,8 +51,9 @@ struct target_pt_regs {#define UNAME_MINIMUM_RELEASE "4.15.0"#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4/* clone(flags, newsp, ptidptr, tls, ctidptr) for RISC-V */ /* This comes from linux/kernel/fork.c, CONFIG_CLONE_BACKWARDS */
linux-user/s390x/target_syscall.h +3 -2
@@ -28,7 +28,8 @@ struct target_pt_regs {#define TARGET_CLONE_BACKWARDS2 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#endif /* S390X_TARGET_SYSCALL_H */
linux-user/sh4/target_syscall.h +3 -2
@@ -16,8 +16,9 @@ struct target_pt_regs {#define UNAME_MINIMUM_RELEASE "2.6.32"#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#define TARGET_FORCE_SHMLBA
linux-user/sparc/target_syscall.h +3 -2
@@ -21,8 +21,9 @@ struct target_pt_regs {*/ #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000/* For SPARC SHMLBA is determined at runtime in the kernel, and * libc has to runtime-detect it using the hwcaps (see glibc
linux-user/sparc64/target_syscall.h +3 -2
@@ -22,8 +22,9 @@ struct target_pt_regs {*/ #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 -#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 +#define TARGET_MCL_CURRENT 0x2000 +#define TARGET_MCL_FUTURE 0x4000 +#define TARGET_MCL_ONFAULT 0x8000#define TARGET_FORCE_SHMLBA
linux-user/strace.c +21 -0
@@ -1198,6 +1198,15 @@ UNUSED static struct flags falloc_flags[] = {#endif }; +UNUSED static struct flags mlockall_flags[] = { +FLAG_TARGET (MCL_CURRENT ), +FLAG_TARGET (MCL_FUTURE ), +#ifdef MCL_ONFAULT +FLAG_TARGET (MCL_ONFAULT ), +#endif +FLAG_END , +}; +/* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter
@@ -2009,6 +2018,18 @@ print_ftruncate64(void *cpu_env, const struct syscallname *name, }#endif +#ifdef TARGET_NR_mlockall +static void +print_mlockall (void *cpu_env,const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_flags (mlockall_flags, arg0,1 ); +print_syscall_epilogue (name); +} +#endif +#if defined(TARGET_NR_socket) static void print_socket(void *cpu_env, const struct syscallname *name,
linux-user/strace.list +4 -4
@@ -568,13 +568,13 @@ { TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, #endif #ifdef TARGET_NR_mlock -{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL }, +{ TARGET_NR_mlock, "mlock" , "%s(%p," TARGET_FMT_lu ")", NULL, NULL }, #endif #ifdef TARGET_NR_mlock2 { TARGET_NR_mlock2, "mlock2" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_mlockall -{ TARGET_NR_mlockall, "mlockall" , NULL, NULL, NULL }, +{ TARGET_NR_mlockall, "mlockall" , NULL, print_mlockall, NULL }, #endif #ifdef TARGET_NR_mmap { TARGET_NR_mmap, "mmap" , NULL, print_mmap, print_syscall_ret_addr },
@@ -637,10 +637,10 @@ { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_munlock -{ TARGET_NR_munlock, "munlock" , NULL, NULL, NULL }, +{ TARGET_NR_munlock, "munlock" , "%s(%p," TARGET_FMT_lu ")", NULL, NULL }, #endif #ifdef TARGET_NR_munlockall -{ TARGET_NR_munlockall, "munlockall" , NULL, NULL, NULL }, +{ TARGET_NR_munlockall, "munlockall" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_munmap { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL },
linux-user/syscall.c +8 -2
@@ -6975,12 +6975,18 @@ static inline int target_to_host_mlockall_arg(int arg) {int result =0 ; -if (arg &TARGET_MLOCKALL_MCL_CURRENT ) { +if (arg &TARGET_MCL_CURRENT ) { result |=MCL_CURRENT ; } -if (arg &TARGET_MLOCKALL_MCL_FUTURE ) { +if (arg &TARGET_MCL_FUTURE ) { result |=MCL_FUTURE ; } +#ifdef MCL_ONFAULT +if (arg &TARGET_MCL_ONFAULT ) { + result |=MCL_ONFAULT ; + } +#endif +return result; }#endif
linux-user/tilegx/target_syscall.h +3 -2
@@ -34,8 +34,9 @@ struct target_pt_regs {tilegx_reg_t pad[2 ]; }; -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4/* For faultnum */ #define TARGET_INT_SWINT_1 14
linux-user/x86_64/target_syscall.h +3 -2
@@ -101,7 +101,8 @@ struct target_msqid64_ds {#define TARGET_ARCH_GET_FS 0x1003#define TARGET_ARCH_GET_GS 0x1004#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#endif /* X86_64_TARGET_SYSCALL_H */
linux-user/xtensa/target_syscall.h +3 -2
@@ -43,7 +43,8 @@ struct target_pt_regs { xtensa_reg_t areg[16]; }; -#define TARGET_MLOCKALL_MCL_CURRENT 1 -#define TARGET_MLOCKALL_MCL_FUTURE 2 +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4#endif
Signature · 1 line
2.26.2
[PULL 11/18] linux-user: Add strace support for printing arguments for ioctls used for terminals and serial lines
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
Functions "print_ioctl()" and "print_syscall_ret_ioctl()" are used to print arguments of "ioctl()" with "-strace". These functions use "thunk_print()", which is defined in "thunk.c", to print the contents of ioctl's third arguments that are not basic types.
However, this function doesn't handle ioctls of group ioctl_tty which are used for terminals and serial lines. These ioctls use a type "struct termios" which thunk type is defined in a non standard way using "STRUCT_SPECIAL()". This means that this type is not decoded regularly using "thunk_convert()" and uses special converting functions "target_to_host_termios()" and "host_to_target_termios()", which are defined in "syscall.c" to decode it's values.
For simillar reasons, this type is also not printed regularly using "thunk_print()". That is the reason why a separate printing function "print_termios()" is defined in file "strace.c". This function decodes and prints flag values of the "termios" structure.
Implementation notes:
Function "print_termios()" was implemented in "strace.c" using an existing function "print_flags()" to print flag values of "struct termios" fields. Also, recently implemented function "print_enums()" was also used to print enumareted values which are contained in the fields of 'struct termios'.
These flag values were defined using an existing macro "FLAG_TARGET()" that generates aproppriate target flag values and string representations of these flags. Also, the recently defined macro "ENUM_TARGET()" was used to generate aproppriate enumarated values and their respective string representations.
Function "print_termios()" was declared in "qemu.h" so that it can be accessed in "syscall.c". Type "StructEntry" defined in "exec/user/thunk.h" contains information that is used to decode structure values. Field "void print(void *arg)" was added in this structure as a special print function. Also, function "thunk_print()" was changed a little so that it uses this special print function in case it is defined. This printing function was instantiated with the defined "print_termios()" in "syscall.c" in "struct_termios_def".
Message-Id: <[email protected]>
--- include/exec/user/thunk.h | 1 + linux-user/qemu.h | 1 + linux-user/strace.c | 195 ++++++++++++++++++++++++++++++++++++++ linux-user/syscall.c | 1 + thunk.c | 23 +++-- 5 files changed, 212 insertions(+), 9 deletions(-)
include/exec/user/thunk.h +1 -0
@@ -55,6 +55,7 @@ typedef struct {int *field_offsets[2 ];/* special handling */ void (*convert[2 ])(void *dst,const void *src); +void (*print)(void *arg);int size[2 ];int align[2 ];const char *name;
linux-user/qemu.h +1 -0
@@ -706,6 +706,7 @@ static inline uint64_t target_offset64(uint64_t word0, uint64_t word1) }#endif /* TARGET_ABI_BITS != 32 */ +void print_termios (void *arg);/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM
linux-user/strace.c +195 -0
207 lines not on this page · raw message
linux-user/syscall.c +1 -0
@@ -5710,6 +5710,7 @@ static const StructEntry struct_termios_def = { .convert = { host_to_target_termios, target_to_host_termios }, .size = { sizeof(struct target_termios), sizeof(struct host_termios) }, .align = { __alignof__(struct target_termios), __alignof__(struct host_termios) }, + .print = print_termios, }; static bitmask_transtbl mmap_flags_tbl[] = {
thunk.c +14 -9
@@ -404,19 +404,24 @@ const argtype *thunk_print(void *arg, const argtype *type_ptr)const int *arg_offsets; se = struct_entries + *type_ptr++; - a = arg; - field_types = se->field_types; - arg_offsets = se->field_offsets[0 ]; +if (se->print !=NULL ) { + se->else { + a = arg; -qemu_log ("{" ); -for (i =0 ; i < se->nb_fields; i++) { -if (i >0 ) { -qemu_log ("," ); + field_types = se->field_types; + arg_offsets = se->field_offsets[0 ]; + +qemu_log ("{" ); +for (i =0 ; i < se->nb_fields; i++) { +if (i >0 ) { +qemu_log ("," ); + } + field_types =thunk_print (a + arg_offsets[i], field_types); } - field_types =thunk_print (a + arg_offsets[i], field_types); +qemu_log ("}" ); } -qemu_log ("}" ); }break ;default :
Signature · 1 line
2.26.2
[PULL 08/18] linux-user: Add strace support for printing arguments of some clock and time functions
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res) int clock_gettime(clockid_t clockid, struct timespec *tp) int clock_settime(clockid_t clockid, const struct timespec *tp) man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz) man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value) int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus a separate printing function was stated in file "strace.list" for each of them. All of these functions use existing functions for their appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this patch so that they can be used to print types "struct timespec" and "struct itimerval" used by some of the syscalls. Function "print_itimerval()" uses the existing function "print_timeval()" to print fields of the structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used to print the interval timer type which is the first argument of "getitimer()" and "setitimer()". Also, this function is used to print the clock id which is the first argument of "clock_getres()" and "clock_gettime()". For that reason, the existing function "print_clockid()" was removed in this patch. Existing function "print_clock_adjtime()" was also changed for this reason to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number and types of arguments and thus their print functions "print_clock_getres" and "print_clock_gettime" share a common definition in file "strace.c".
Message-Id: <[email protected]>
--- linux-user/strace.c | 287 +++++++++++++++++++++++++++++++---------- linux-user/strace.list | 17 ++- 2 files changed, 232 insertions(+), 72 deletions(-)
linux-user/strace.c +221 -66
@@ -78,7 +78,9 @@ UNUSED static void print_string(abi_long, int); UNUSED static void print_buf(abi_long addr, abi_long len, int last); UNUSED static void print_raw_param(const char *, abi_long, int); UNUSED static void print_timeval(abi_ulong, int); +UNUSED static void print_timespec(abi_ulong, int); UNUSED static void print_timezone(abi_ulong, int); +UNUSED static void print_itimerval(abi_ulong, int); UNUSED static void print_number(abi_long, int); UNUSED static void print_signal(abi_ulong, int); UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
@@ -582,69 +584,6 @@ print_fdset(int n, abi_ulong target_fds_addr) }#endif -#ifdef TARGET_NR_clock_adjtime -/* IDs of the various system clocks */ -#define TARGET_CLOCK_REALTIME 0 -#define TARGET_CLOCK_MONOTONIC 1 -#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 -#define TARGET_CLOCK_THREAD_CPUTIME_ID 3 -#define TARGET_CLOCK_MONOTONIC_RAW 4 -#define TARGET_CLOCK_REALTIME_COARSE 5 -#define TARGET_CLOCK_MONOTONIC_COARSE 6 -#define TARGET_CLOCK_BOOTTIME 7 -#define TARGET_CLOCK_REALTIME_ALARM 8 -#define TARGET_CLOCK_BOOTTIME_ALARM 9 -#define TARGET_CLOCK_SGI_CYCLE 10 -#define TARGET_CLOCK_TAI 11 - -static void -print_clockid (int clockid,int last) -{ -switch (clockid) { -case TARGET_CLOCK_REALTIME : -qemu_log ("CLOCK_REALTIME" ); -break ; -case TARGET_CLOCK_MONOTONIC : -qemu_log ("CLOCK_MONOTONIC" ); -break ; -case TARGET_CLOCK_PROCESS_CPUTIME_ID : -qemu_log ("CLOCK_PROCESS_CPUTIME_ID" ); -break ; -case TARGET_CLOCK_THREAD_CPUTIME_ID : -qemu_log ("CLOCK_THREAD_CPUTIME_ID" ); -break ; -case TARGET_CLOCK_MONOTONIC_RAW : -qemu_log ("CLOCK_MONOTONIC_RAW" ); -break ; -case TARGET_CLOCK_REALTIME_COARSE : -qemu_log ("CLOCK_REALTIME_COARSE" ); -break ; -case TARGET_CLOCK_MONOTONIC_COARSE : -qemu_log ("CLOCK_MONOTONIC_COARSE" ); -break ; -case TARGET_CLOCK_BOOTTIME : -qemu_log ("CLOCK_BOOTTIME" ); -break ; -case TARGET_CLOCK_REALTIME_ALARM : -qemu_log ("CLOCK_REALTIME_ALARM" ); -break ; -case TARGET_CLOCK_BOOTTIME_ALARM : -qemu_log ("CLOCK_BOOTTIME_ALARM" ); -break ; -case TARGET_CLOCK_SGI_CYCLE : -qemu_log ("CLOCK_SGI_CYCLE" ); -break ; -case TARGET_CLOCK_TAI : -qemu_log ("CLOCK_TAI" ); -break ; -default : -qemu_log ("%d" , clockid); -break ; - } -qemu_log ("%s" ,get_comma (last)); -} -#endif -/* * Sysycall specific output functions */
@@ -843,6 +782,81 @@ print_syscall_ret_adjtimex(void *cpu_env, const struct syscallname *name, }#endif +#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) +static void +print_syscall_ret_clock_gettime (void *cpu_env,const struct syscallname *name, +abi_long ret,abi_long arg0,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5) +{ +if (!print_syscall_err (ret)) { +qemu_log (TARGET_ABI_FMT_ld, ret); +qemu_log (" (" ); +print_timespec (arg1,1 ); +qemu_log (")" ); + } + +qemu_log ("\n" ); +} +#define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime +#endif + +#ifdef TARGET_NR_gettimeofday +static void +print_syscall_ret_gettimeofday (void *cpu_env,const struct syscallname *name, +abi_long ret,abi_long arg0,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5) +{ +if (!print_syscall_err (ret)) { +qemu_log (TARGET_ABI_FMT_ld, ret); +qemu_log (" (" ); +print_timeval (arg0,0 ); +print_timezone (arg1,1 ); +qemu_log (")" ); + } + +qemu_log ("\n" ); +} +#endif + +#ifdef TARGET_NR_getitimer +static void +print_syscall_ret_getitimer (void *cpu_env,const struct syscallname *name, +abi_long ret,abi_long arg0,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5) +{ +if (!print_syscall_err (ret)) { +qemu_log (TARGET_ABI_FMT_ld, ret); +qemu_log (" (" ); +print_itimerval (arg1,1 ); +qemu_log (")" ); + } + +qemu_log ("\n" ); +} +#endif + + +#ifdef TARGET_NR_getitimer +static void +print_syscall_ret_setitimer (void *cpu_env,const struct syscallname *name, +abi_long ret,abi_long arg0,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5) +{ +if (!print_syscall_err (ret)) { +qemu_log (TARGET_ABI_FMT_ld, ret); +qemu_log (" (old_value = " ); +print_itimerval (arg2,1 ); +qemu_log (")" ); + } + +qemu_log ("\n" ); +} +#endif +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ || defined(TARGGET_NR_flistxattr) static void
@@ -1221,6 +1235,43 @@ UNUSED static struct flags mlockall_flags[] = { FLAG_END, }; +/* IDs of the various system clocks */ +#define TARGET_CLOCK_REALTIME 0 +#define TARGET_CLOCK_MONOTONIC 1 +#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 +#define TARGET_CLOCK_THREAD_CPUTIME_ID 3 +#define TARGET_CLOCK_MONOTONIC_RAW 4 +#define TARGET_CLOCK_REALTIME_COARSE 5 +#define TARGET_CLOCK_MONOTONIC_COARSE 6 +#define TARGET_CLOCK_BOOTTIME 7 +#define TARGET_CLOCK_REALTIME_ALARM 8 +#define TARGET_CLOCK_BOOTTIME_ALARM 9 +#define TARGET_CLOCK_SGI_CYCLE 10 +#define TARGET_CLOCK_TAI 11 + +UNUSED static struct enums clockids[] = { +ENUM_TARGET (CLOCK_REALTIME ), +ENUM_TARGET (CLOCK_MONOTONIC ), +ENUM_TARGET (CLOCK_PROCESS_CPUTIME_ID ), +ENUM_TARGET (CLOCK_THREAD_CPUTIME_ID ), +ENUM_TARGET (CLOCK_MONOTONIC_RAW ), +ENUM_TARGET (CLOCK_REALTIME_COARSE ), +ENUM_TARGET (CLOCK_MONOTONIC_COARSE ), +ENUM_TARGET (CLOCK_BOOTTIME ), +ENUM_TARGET (CLOCK_REALTIME_ALARM ), +ENUM_TARGET (CLOCK_BOOTTIME_ALARM ), +ENUM_TARGET (CLOCK_SGI_CYCLE ), +ENUM_TARGET (CLOCK_TAI ), +ENUM_END , +}; + +UNUSED static struct enums itimer_types[] = { +ENUM_GENERIC (ITIMER_REAL ), +ENUM_GENERIC (ITIMER_VIRTUAL ), +ENUM_GENERIC (ITIMER_PROF ), +ENUM_END , +}; +/* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter
@@ -1439,13 +1490,34 @@ print_timeval(abi_ulong tv_addr, int last)print_pointer (tv_addr, last);return ; } -qemu_log ("{" TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld"}%s" , -tswapal (tv->tv_sec),tswapal (tv->tv_usec),get_comma (last)); +qemu_log ("{tv_sec = " TARGET_ABI_FMT_ld +",tv_usec = " TARGET_ABI_FMT_ld"}%s" , +tswapal (tv->tv_sec),tswapal (tv->tv_usec),get_comma (last));unlock_user (tv, tv_addr,0 ); }else qemu_log ("NULL%s" ,get_comma (last)); } +static void +print_timespec (abi_ulong ts_addr,int last) +{ +if (ts_addr) { +struct target_timespec *ts; + + ts =lock_user (VERIFY_READ , ts_addr,sizeof (*ts),1 ); +if (!ts) { +print_pointer (ts_addr, last); +return ; + } +qemu_log ("{tv_sec = " TARGET_ABI_FMT_ld +",tv_nsec = " TARGET_ABI_FMT_ld"}%s" , +tswapal (ts->tv_sec),tswapal (ts->tv_nsec),get_comma (last)); +unlock_user (ts, ts_addr,0 ); + }else { +qemu_log ("NULL%s" ,get_comma (last)); + } +} +static void print_timezone (abi_ulong tz_addr,int last) {
@@ -1465,6 +1537,22 @@ print_timezone(abi_ulong tz_addr, int last) } } +static void +print_itimerval (abi_ulong it_addr,int last) +{ +if (it_addr) { +qemu_log ("{it_interval=" ); +print_timeval (it_addr + + offsetof(struct target_itimerval , it_interval),0 ); +qemu_log ("it_value=" ); +print_timeval (it_addr + + offsetof(struct target_itimerval , it_value),0 ); +qemu_log ("}%s" ,get_comma (last)); + }else { +qemu_log ("NULL%s" ,get_comma (last)); + } +} +#undef UNUSED#ifdef TARGET_NR_accept
@@ -1577,7 +1665,7 @@ print_clock_adjtime(void *cpu_env, const struct syscallname *name, abi_long arg3, abi_long arg4, abi_long arg5) {print_syscall_prologue (name ); -print_clockid (arg0,0 ); +print_enums (clockids, arg0,0 );print_pointer (arg1,1 );print_syscall_epilogue (name); }
@@ -1907,6 +1995,19 @@ print_futimesat(void *cpu_env, const struct syscallname *name, }#endif +#ifdef TARGET_NR_gettimeofday +static void +print_gettimeofday (void *cpu_env,const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_pointer (arg0,0 ); +print_pointer (arg1,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_settimeofday static void print_settimeofday(void *cpu_env, const struct syscallname *name,
@@ -1920,6 +2021,60 @@ print_settimeofday(void *cpu_env, const struct syscallname *name, }#endif +#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) +static void +print_clock_gettime (void *cpu_env,const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_enums (clockids, arg0,0 ); +print_pointer (arg1,1 ); +print_syscall_epilogue (name); +} +#define print_clock_getres print_clock_gettime +#endif + +#ifdef TARGET_NR_clock_settime +static void +print_clock_settime (void *cpu_env,const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_enums (clockids, arg0,0 ); +print_timespec (arg1,1 ); +print_syscall_epilogue (name); +} +#endif + +#ifdef TARGET_NR_getitimer +static void +print_getitimer (void *cpu_env,const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_enums (itimer_types, arg0,0 ); +print_pointer (arg1,1 ); +print_syscall_epilogue (name); +} +#endif + +#ifdef TARGET_NR_setitimer +static void +print_setitimer (void *cpu_env,const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_enums (itimer_types, arg0,0 ); +print_itimerval (arg1,0 ); +print_pointer (arg2,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_link static void print_link(void *cpu_env, const struct syscallname *name,
linux-user/strace.list +11 -6
@@ -83,16 +83,18 @@ { TARGET_NR_clock_adjtime, "clock_adjtime" , NULL, print_clock_adjtime, NULL }, #endif #ifdef TARGET_NR_clock_getres -{ TARGET_NR_clock_getres, "clock_getres" , NULL, NULL, NULL }, +{ TARGET_NR_clock_getres, "clock_getres" , NULL, print_clock_getres, + print_syscall_ret_clock_getres }, #endif #ifdef TARGET_NR_clock_gettime -{ TARGET_NR_clock_gettime, "clock_gettime" , NULL, NULL, NULL }, +{ TARGET_NR_clock_gettime, "clock_gettime" , NULL, print_clock_gettime, + print_syscall_ret_clock_gettime }, #endif #ifdef TARGET_NR_clock_nanosleep { TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_clock_settime -{ TARGET_NR_clock_settime, "clock_settime" , NULL, NULL, NULL }, +{ TARGET_NR_clock_settime, "clock_settime" , NULL, print_clock_settime, NULL }, #endif #ifdef TARGET_NR_clone { TARGET_NR_clone, "clone" , NULL, print_clone, NULL },
@@ -315,7 +317,8 @@ { TARGET_NR_gethostname, "gethostname" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getitimer -{ TARGET_NR_getitimer, "getitimer" , NULL, NULL, NULL }, +{ TARGET_NR_getitimer, "getitimer" , NULL, print_getitimer, + print_syscall_ret_getitimer }, #endif #ifdef TARGET_NR_get_kernel_syms { TARGET_NR_get_kernel_syms, "get_kernel_syms" , NULL, NULL, NULL },
@@ -388,7 +391,8 @@ { TARGET_NR_gettid, "gettid" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_gettimeofday -{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, NULL, NULL }, +{ TARGET_NR_gettimeofday, "gettimeofday" , NULL, print_gettimeofday, + print_syscall_ret_gettimeofday }, #endif #ifdef TARGET_NR_getuid { TARGET_NR_getuid, "getuid" , "%s()", NULL, NULL },
@@ -1291,7 +1295,8 @@ { TARGET_NR_sethostname, "sethostname" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_setitimer -{ TARGET_NR_setitimer, "setitimer" , NULL, NULL, NULL }, +{ TARGET_NR_setitimer, "setitimer" , NULL, print_setitimer, + print_syscall_ret_setitimer }, #endif #ifdef TARGET_NR_set_mempolicy { TARGET_NR_set_mempolicy, "set_mempolicy" , NULL, NULL, NULL },
Signature · 1 line
2.26.2
[PULL 14/18] linux-user: fix target_to_host_timespec64()
In reply to Laurent Vivierin 32 bit mode, drop the padding in tv_nsec. If host is 64bit and target is 32bit, the padding bytes will be copied from the target and as the kernel checks the value, the syscall exits with EINVAL.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
linux-user/syscall.c +2 -0
@@ -1229,6 +1229,8 @@ static inline abi_long target_to_host_timespec64(struct timespec *host_ts, }__get_user (host_ts->tv_sec, &target_ts->tv_sec);__get_user (host_ts->tv_nsec, &target_ts->tv_nsec); +/* in 32bit mode, this drops the padding */ + host_ts->tv_nsec = (long )(abi_long )host_ts->tv_nsec;unlock_user_struct (target_ts, target_addr,0 );return 0 ; }
Signature · 1 line
2.26.2
[PULL 12/18] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el]
In reply to Laurent VivierFrom: Carlo Marcelo Arenas Belón <[email protected]>
MIPS provides 2 ILP32 ABIs, and therefore 4 possible qemu-mips binaries with 2 pairs using the same endianess and bitness.
This could lead to an O32 image loading in the N32 binary or vice versa and in cryptic errors (if lucky that the CPU doesn't match the FPU used) like :
qemu: Unexpected FPU mode (o32 ELF loaded to qemu-mipsn32[el])
ELF binary's NaN mode not supported by CPU (n32 -> qemu-mips[el])
Add an ABI check macro that could be used while checking the ELF header that relies in the ABI2 flag to identify n32 binaries and abort instead early with a more descriptive error :
Invalid ELF image for this architecture
Message-Id: <[email protected]>
--- linux-user/elfload.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
linux-user/elfload.c +11 -0
@@ -918,6 +918,12 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en#define elf_check_arch (x) ((x) == EM_MIPS || (x) == EM_NANOMIPS) +#ifdef TARGET_ABI_MIPSN32 +#define elf_check_abi (x) ((x) & EF_MIPS_ABI2) +#else +#define elf_check_abi (x) (!((x) & EF_MIPS_ABI2)) +#endif +static inline void init_thread (struct target_pt_regs *regs,struct image_info *infop) {
@@ -1487,6 +1493,10 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,#define elf_check_arch (x) ((x) == ELF_ARCH)#endif +#ifndef elf_check_abi +#define elf_check_abi (x) (1) +#endif +#ifndef ELF_HWCAP #define ELF_HWCAP 0#endif
@@ -1644,6 +1654,7 @@ static bool elf_check_ident(struct elfhdr *ehdr)static bool elf_check_ehdr (struct elfhdr *ehdr) {return (elf_check_arch (ehdr->e_machine) + &&elf_check_abi (ehdr->e_flags) && ehdr->e_ehsize ==sizeof (struct elfhdr ) && ehdr->e_phentsize ==sizeof (struct elf_phdr ) && (ehdr->e_type ==ET_EXEC || ehdr->e_type ==ET_DYN ));
Signature · 1 line
2.26.2
[PULL 13/18] linux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()'
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
Implementations of syscalls 'mq_timedsend()' and 'mq_timedreceive()' in 'syscall.c' use functions 'target_to_host_timespec()' and 'host_to_target_timespec()' to transfer the value of 'struct timespec' between target and host. However, the implementations don't check whether this conversion succeeds and thus can cause an unaproppriate error instead of the 'EFAULT (Bad address)' which is supposed to be set if the conversion from target to host fails. This was confirmed with the modified LTP test suite where test cases with a bad adress for 'timespec' were added. This modified test suite can be found at:
https://github.com/bozutaf/ltp
Without the changes from this patch the bad adress testcase for 'mq_timedsend()' succeds unexpectedly, while the test returns errno 'ETIMEOUT' for 'mq_timedreceive()':
mq_timedsend01.c:190: FAIL: mq_timedsend() returned 0, expected -1: SUCCESS (0) mq_timedreceive01.c:178: FAIL: mq_timedreceive() failed unexpectedly, expected EFAULT: ETIMEDOUT (110)
After the changes from this patch, testcases for both syscalls fail with EFAULT as expected, which is the same test result that is received with native execution:
mq_timedsend01.c:187: PASS: mq_timedsend() failed expectedly: EFAULT (14) mq_timedreceive01.c:180: PASS: mq_timedreceive() failed expectedly: EFAULT (14)
(Patch with this new test case will be sent to LTP mailing list soon)
Message-Id: <[email protected]>
--- linux-user/syscall.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
linux-user/syscall.c +12 -4
@@ -12043,9 +12043,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_READ , arg2, arg3,1 );if (arg5 !=0 ) { -target_to_host_timespec (&ts, arg5); +if (target_to_host_timespec (&ts, arg5)) { +return -TARGET_EFAULT ; + } ret =get_errno (safe_mq_timedsend (arg1, p, arg3, arg4, &ts)); -host_to_target_timespec (arg5, &ts); +if (!is_error (ret) &&host_to_target_timespec (arg5, &ts)) { +return -TARGET_EFAULT ; + } }else { ret =get_errno (safe_mq_timedsend (arg1, p, arg3, arg4,NULL )); }
@@ -12062,10 +12066,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_READ , arg2, arg3,1 );if (arg5 !=0 ) { -target_to_host_timespec (&ts, arg5); +if (target_to_host_timespec (&ts, arg5)) { +return -TARGET_EFAULT ; + } ret =get_errno (safe_mq_timedreceive (arg1, p, arg3, &prio, &ts)); -host_to_target_timespec (arg5, &ts); +if (!is_error (ret) &&host_to_target_timespec (arg5, &ts)) { +return -TARGET_EFAULT ; + } }else { ret =get_errno (safe_mq_timedreceive (arg1, p, arg3, &prio,NULL ));
Signature · 1 line
2.26.2
[PULL 18/18] linux-user: Add support for utimensat_time64() and semtimedop_time64()
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch introduces functionality for following time64 syscalls:
*utimensat_time64()
int utimensat(int dirfd, const char *pathname,
const struct timespec times[2], int flags);
-- change file timestamps with nanosecond precision -- man page: https://man7.org/linux/man-pages/man2/utimensat.2.html
*semtimedop_time64()
int semtimedop(int semid, struct sembuf *sops, size_t nsops,
const struct timespec *timeout);
-- System V semaphore operations --
man page: https://www.man7.org/linux/man-pages/man2/semtimedop.2.html
Implementation notes:
Syscall 'utimensat_time64()' is implemented in similar way as its regular variants only difference being that time64 converting function is used to convert values of 'struct timespec' between host and target ('target_to_host_timespec64()').
For syscall 'semtimedop_time64()' and additional argument is added in function 'do_semtimedop()' through which the aproppriate 'struct timespec' converting function is called (false for regular target_to_host_timespec() and true for target_to_host_timespec64()). For 'do_ipc()' a check was added as that additional argument: 'TARGET_ABI_BITS == 64'.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 64 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-)
linux-user/syscall.c +53 -11
@@ -391,7 +391,7 @@ static bitmask_transtbl fcntl_flags_tbl[] = { _syscall2(int, sys_getcwd1, char *, buf, size_t, size) -#ifdef TARGET_NR_utimensat +#if defined(TARGET_NR_utimensat) || defined(TARGET_NR_utimensat_time64)#if defined(__NR_utimensat)#define __NR_sys_utimensat __NR_utimensat _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname,
@@ -1242,7 +1242,10 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts,defined (TARGET_NR_mq_timedreceive_time64) || \ (defined (TARGET_NR_timerfd_settime64) &&defined (CONFIG_TIMERFD )) || \defined (TARGET_NR_clock_nanosleep_time64) || \ - defined(TARGET_NR_rt_sigtimedwait_time64) +defined (TARGET_NR_rt_sigtimedwait_time64) || \ +defined (TARGET_NR_utimensat) || \ +defined (TARGET_NR_utimensat_time64) || \ + defined(TARGET_NR_semtimedop_time64)static inline abi_long target_to_host_timespec64 (struct timespec *host_ts,abi_ulong target_addr) {
@@ -3877,7 +3880,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf, }#if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) || \ - defined(TARGET_NR_semtimedop) + defined(TARGET_NR_semtimedop) || defined(TARGET_NR_semtimedop_time64)/* * This macro is required to handle the s390 variants, which passes the
@@ -3894,7 +3897,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,static inline abi_long do_semtimedop (int semid,abi_long ptr,unsigned nsops, -abi_long timeout) +abi_long timeout,bool time64) {struct sembuf *sops;struct timespec ts, *pts =NULL ;
@@ -3902,8 +3905,14 @@ static inline abi_long do_semtimedop(int semid,if (timeout) { pts = &ts; -if (target_to_host_timespec (pts, timeout)) { -return -TARGET_EFAULT ; +if (time64) { +if (target_to_host_timespec64 (pts, timeout)) { +return -TARGET_EFAULT ; + } + }else { +if (target_to_host_timespec (pts, timeout)) { +return -TARGET_EFAULT ; + } } }
@@ -4426,7 +4435,7 @@ static abi_long do_ipc(CPUArchState *cpu_env,switch (call) {case IPCOP_semop: - ret =do_semtimedop (first, ptr, second,0 ); + ret =do_semtimedop (first, ptr, second,0 , false);break ;case IPCOP_semtimedop:/*
@@ -4436,9 +4445,9 @@ static abi_long do_ipc(CPUArchState *cpu_env,* to a struct timespec where the generic variant uses fifth parameter. */ #if defined(TARGET_S390X ) - ret =do_semtimedop (first, ptr, second, third); + ret =do_semtimedop (first, ptr, second, third,TARGET_ABI_BITS ==64 );#else - ret =do_semtimedop (first, ptr, second, fifth); + ret =do_semtimedop (first, ptr, second, fifth,TARGET_ABI_BITS ==64 );#endif break ;
@@ -9947,11 +9956,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_semopcase TARGET_NR_semop: -return do_semtimedop (arg1, arg2, arg3,0 ); +return do_semtimedop (arg1, arg2, arg3,0 , false);#endif #ifdef TARGET_NR_semtimedopcase TARGET_NR_semtimedop: -return do_semtimedop (arg1, arg2, arg3, arg4); +return do_semtimedop (arg1, arg2, arg3, arg4, false); +#endif +#ifdef TARGET_NR_semtimedop_time64 +case TARGET_NR_semtimedop_time64: +return do_semtimedop (arg1, arg2, arg3, arg4, true);#endif #ifdef TARGET_NR_semctlcase TARGET_NR_semctl:
@@ -12158,6 +12171,35 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif +#ifdef TARGET_NR_utimensat_time64 +case TARGET_NR_utimensat_time64: + { +struct timespec *tsp, ts[2 ]; +if (!arg3) { + tsp =NULL ; + }else { +if (target_to_host_timespec64 (ts, arg3)) { +return -TARGET_EFAULT ; + } +if (target_to_host_timespec64 (ts +1 , arg3 + +sizeof (struct target__kernel_timespec ))) { +return -TARGET_EFAULT ; + } + tsp = ts; + } +if (!arg2) + ret =get_errno (sys_utimensat (arg1,NULL , tsp, arg4)); +else { + p =lock_user_string (arg2); +if (!p) { +return -TARGET_EFAULT ; + } + ret =get_errno (sys_utimensat (arg1,path (p), tsp, arg4)); +unlock_user (p, arg2,0 ); + } + } +return ret; +#endif #ifdef TARGET_NR_futexcase TARGET_NR_futex:return do_futex (arg1, arg2, arg3, arg4, arg5, arg6);
Signature · 1 line
2.26.2
[PULL 15/18] linux-user: Add support for 'mq_timedsend_time64()' and 'mq_timedreceive_time64()'
In reply to Laurent VivierFrom: Filip Bozuta <[email protected]>
This patch implements functionality for following time64 syscalls:
*mq_timedsend_time64()
This is a year 2038 safe vairant of syscall:
int mq_timedsend(mqd_t mqdes, const char *msg_ptr,
size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout)
--send a message to a message queue--
man page: https://www.man7.org/linux/man-pages/man2/mq_timedsend.2.html
*mq_timedreceive_time64()
This is a year 2038 safe variant of syscall:
ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr,
size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout)
--receive a message from a message queue--
man page: https://man7.org/linux/man-pages/man3/mq_receive.3.html
Implementation notes:
These syscalls were implemented in similar ways like 'mq_timedsend()' and 'mq_timedreceive' except that functions 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used to convert values of 'struct timespec' between host and target.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
linux-user/syscall.c +54 -2
@@ -799,11 +799,13 @@ safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz, safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops, unsigned, nsops, const struct timespec *, timeout)#endif -#ifdef TARGET_NR_mq_timedsend +#if defined(TARGET_NR_mq_timedsend) || \ + defined(TARGET_NR_mq_timedsend_time64) safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, len, unsigned, prio, const struct timespec *, timeout)#endif -#ifdef TARGET_NR_mq_timedreceive +#if defined(TARGET_NR_mq_timedreceive) || \ + defined(TARGET_NR_mq_timedreceive_time64) safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, timeout)#endif
@@ -1218,6 +1220,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts,#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) || \ defined(TARGET_NR_timer_settime64) || \ + defined(TARGET_NR_mq_timedsend_time64) || \ + defined(TARGET_NR_mq_timedreceive_time64) || \ (defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD ))static inline abi_long target_to_host_timespec64 (struct timespec *host_ts,abi_ulong target_addr)
@@ -12059,6 +12063,27 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif +#ifdef TARGET_NR_mq_timedsend_time64 +case TARGET_NR_mq_timedsend_time64: + { +struct timespec ts; + + p =lock_user (VERIFY_READ , arg2, arg3,1 ); +if (arg5 !=0 ) { +if (target_to_host_timespec64 (&ts, arg5)) { +return -TARGET_EFAULT ; + } + ret =get_errno (safe_mq_timedsend (arg1, p, arg3, arg4, &ts)); +if (!is_error (ret) &&host_to_target_timespec64 (arg5, &ts)) { +return -TARGET_EFAULT ; + } + }else { + ret =get_errno (safe_mq_timedsend (arg1, p, arg3, arg4,NULL )); + } +unlock_user (p, arg2, arg3); + } +return ret; +#endif #ifdef TARGET_NR_mq_timedreceivecase TARGET_NR_mq_timedreceive:
@@ -12086,6 +12111,33 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif +#ifdef TARGET_NR_mq_timedreceive_time64 +case TARGET_NR_mq_timedreceive_time64: + { +struct timespec ts; +unsigned int prio; + + p =lock_user (VERIFY_READ , arg2, arg3,1 ); +if (arg5 !=0 ) { +if (target_to_host_timespec64 (&ts, arg5)) { +return -TARGET_EFAULT ; + } + ret =get_errno (safe_mq_timedreceive (arg1, p, arg3, + &prio, &ts)); +if (!is_error (ret) &&host_to_target_timespec64 (arg5, &ts)) { +return -TARGET_EFAULT ; + } + }else { + ret =get_errno (safe_mq_timedreceive (arg1, p, arg3, + &prio,NULL )); + } +unlock_user (p, arg2, arg3); +if (arg4 !=0 ) { +put_user_u32 (prio, arg4); + } + } +return ret; +#endif /* Not implemented for now... */ /* case TARGET_NR_mq_notify: */
Signature · 1 line
2.26.2
Quoted 15 lines · Laurent Vivier
The following changes since commit
25f6dc28a3a8dd231c2c092a0e65bd796353c769:Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2020-08-26' =
into staging (2020-08-26 10:28:36 +0100)are available in the Git repository at:
git://github.com/vivier/qemu.gittags/linux-user-for-5.2-pull-requestfor you to fetch changes up to
aa26eb42f5eaec54257aaceaeda50b9aa98756a5:linux-user: Add support for
utimensat_time64()andsemtimedop_time64()(202=
0-08-27 12:29:51 +0200)
Quoted 10 lines
----------------------------------------------------------------
addutimensat_time64,semtimedop_time64,rt_sigtimedwait_time64,
sched_rr_get_interval_time64,clock_nanosleep_time64,clock_adjtime64,mq_timedsend_time64,mq_timedreceive_time64
fix semop, semtimedop,clock_nanosleep,mq_timedsend, target_to_host_timespec= 64
fixtembits.h
add more strace function
Add upportDRM_IOCTL_I915_GETPARAM
detect mismatched ELF ABI in qemu-mips[n32][el]
Hi; this fails to build with clang:
../../linux-user/syscall.c:1181:24: error: unused function 'copy_from_user_timeval64' [-Werror,-Wunused-function] static inline abi_long copy_from_user_timeval64(struct timeval *tv,
^
1 error generated.
thanks
-- PMM
Le 28/08/2020 à 14:11, Peter Maydell a écrit :
Quoted 27 lines · Laurent Vivier
Quoted 15 lines
The following changes since commit
25f6dc28a3a8dd231c2c092a0e65bd796353c769:Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2020-08-26' =
into staging (2020-08-26 10:28:36 +0100)are available in the Git repository at:
git://github.com/vivier/qemu.gittags/linux-user-for-5.2-pull-requestfor you to fetch changes up to
aa26eb42f5eaec54257aaceaeda50b9aa98756a5:linux-user: Add support for
utimensat_time64()andsemtimedop_time64()(202=
0-08-27 12:29:51 +0200)Quoted 10 lines
----------------------------------------------------------------
addutimensat_time64,semtimedop_time64,rt_sigtimedwait_time64,
sched_rr_get_interval_time64,clock_nanosleep_time64,clock_adjtime64,mq_timedsend_time64,mq_timedreceive_time64
fix semop, semtimedop,clock_nanosleep,mq_timedsend, target_to_host_timespec= 64
fixtembits.h
add more strace function
Add upportDRM_IOCTL_I915_GETPARAM
detect mismatched ELF ABI in qemu-mips[n32][el]
Quoted 7 lines
Hi; this fails to build with clang:
../../linux-user/syscall.c:1181:24: error: unused function 'copy_from_user_timeval64' [-Werror,-Wunused-function] static inlineabi_longcopy_from_user_timeval64(struct timeval *tv,^1 error generated.
I've added the missing #ifdef and I'm going to resend the PR.
Thanks,
Laurent