linux user: Fix assorted Qemu user mode issues
v5 cover linux user: Fix assorted Qemu user mode issues
From: Aleksandar Markovic <[email protected]>
v4->v5:
- removed three cleanup patches
v3->v4:
- rebased to the latest code
- added patch on clock_adjtime() support
- minor commit messages improvements
v2->v3:
- rebased to the latest code
- merged patches on adjtimex(), sysfs(), and ustat() from another series
- added patch on socketcall() support
- cleanup patches reorganized
v1->v2:
- improved usage of "#ifdefs" in patch on syslog()
- removed EIDRM-related code from patch on msgrcv(), since this error code is already handled well
- added three cleanup patches
(also, v1 for some reason did not appear on qemu-devel, but mails are sent)
This series fixes certain Qemu user mode issues. The fixes mainly originate from observation of LTP tests failures for execution in Qemu user mode on various platforms. The series also contains a cleanup patch.
Aleksandar Markovic (8):
linux-user: Add support for adjtimex() syscall
linux-user: Add support for clock_adjtime() syscall
linux-user: Add support for sysfs() syscall
linux-user: Add support for ustat() syscall
linux-user: Fix msgrcv() and msgsnd() syscalls support
linux-user: Fix socketcall() syscall support
linux-user: Fix syslog() syscall support
linux-user: Remove a duplicate item from strace.list
linux-user/strace.c | 118 +++++++++++++++++++++++++ linux-user/strace.list | 12 +-- linux-user/syscall.c | 221 ++++++++++++++++++++++++++++++++++++++++++---- linux-user/syscall_defs.h | 53 +++++++++++ 4 files changed, 380 insertions(+), 24 deletions(-)
Signature · 1 line
2.9.3
PATCH v5 1/8 linux-user: Add support for adjtimex() syscall
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode adjtimex() syscall support.
Syscall adjtimex() reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios.
The implementation is based on invocation of host's adjtimex(), and its key part is in the correspondent case segment of the main switch statement of the function do_syscall(), in file linux-user/syscalls.c. Also, support for related structure "timex" is added to the file linux-user/syscall_defs.h, based on its definition in Linux kernel. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions, target_to_host_timex() and host_to_target_timex(), are provided for the purpose of such conversions. Moreover, the relevant support for "-strace" Qemu option is included in files linux-user/strace.c and linux-user/strace.list.
This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode.
--- linux-user/strace.c | 12 +++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 28 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-)
linux-user/strace.c +12 -0
@@ -919,6 +919,18 @@ print_access(const struct syscallname *name, }#endif +#ifdef TARGET_NR_adjtimex +static void +print_adjtimex (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,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name,
linux-user/strace.list +1 -1
@@ -16,7 +16,7 @@ { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_adjtimex -{ TARGET_NR_adjtimex, "adjtimex" , NULL, NULL, NULL }, +{ TARGET_NR_adjtimex, "adjtimex" , NULL, print_adjtimex, NULL }, #endif #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL },
linux-user/syscall.c +89 -1
109 lines not on this page · raw message
linux-user/syscall_defs.h +28 -0
@@ -207,6 +207,34 @@ struct target_itimerspec {struct target_timespec it_value; }; +struct target_timex { +unsigned int modes;/* Mode selector */ +abi_long offset;/* Time offset */ +abi_long freq;/* Frequency offset */ +abi_long maxerror;/* Maximum error (microseconds) */ +abi_long esterror;/* Estimated error (microseconds) */ +int status;/* Clock command/status */ +abi_long constant;/* PLL (phase-locked loop) time constant */ +abi_long precision;/* Clock precision (microseconds, ro) */ +abi_long tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target_timeval time;/* Current time */ +abi_long tick;/* Microseconds between clock ticks */ +abi_long ppsfreq;/* PPS (pulse per second) frequency */ +abi_long jitter;/* PPS jitter (ro); nanoseconds */ +int shift;/* PPS interval duration (seconds) */ +abi_long stabil;/* PPS stability */ +abi_long jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_long calcnt;/* PPS calibration intervals */ +abi_long errcnt;/* PPS calibration errors */ +abi_long stbcnt;/* PPS stability limit exceeded */ +int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Quoted 79 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
adjtimex()syscall support.Syscall
adjtimex()reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios.The implementation is based on invocation of host's
adjtimex(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. Also, support for related structure "timex" is added to the filelinux-user/syscall_defs.h, based on its definition in Linux kernel. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions,target_to_host_timex()andhost_to_target_timex(), are provided for the purpose of such conversions. Moreover, the relevant support for "-strace" Qemu option is included in fileslinux-user/strace.cand linux-user/strace.list.This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode.
Signed-off-by Aleksandar Rikalo <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 12 +++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 28 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-)linux-user/strace.c +12
-0@@ -919,6 +919,18 @@ print_access(const struct syscallname *name, }#endif +#ifdef TARGET_NR_adjtimex +static void +print_adjtimex (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,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name,linux-user/strace.list +1
-1@@ -16,7 +16,7 @@ { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_adjtimex -{ TARGET_NR_adjtimex, "adjtimex" , NULL, NULL, NULL }, +{ TARGET_NR_adjtimex, "adjtimex" , NULL, print_adjtimex, NULL }, #endif #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL },linux-user/syscall.c +1
-0@@ -35,6 +35,7 @@#include <sys/swap.h> #include <linux/capability.h> #include <sched.h> +#include <sys/timex.h> #ifdef __ia64__int __clone2 (int (*fn)(void *),void *child_stack_base,size_t stack_size,int flags,void *arg, ...);
linux-user/syscall.c static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, · line 6586
Quoted 8 lines
linux-user/syscall.c +5
-0@@ -6578,6 +6579,78 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif +#ifdef TARGET_NR_adjtimex +static inline abi_long target_to_host_timex (struct timex *host_buf, +abi_long target_addr) +{ +struct target_timex *target_buf;
target_tx instead of target_buf would be nicer(?)
Quoted 16 lines
linux-user/syscall.c +16
-0+ +if (!lock_user_struct (VERIFY_READ , target_buf, target_addr,1 )) { +return -TARGET_EFAULT ; + } + + host_buf->modes =tswap32 (target_buf->modes); + host_buf->offset =tswapal (target_buf->offset); + host_buf->freq =tswapal (target_buf->freq); + host_buf->maxerror =tswapal (target_buf->maxerror); + host_buf->esterror =tswapal (target_buf->esterror); + host_buf->status =tswap32 (target_buf->status); + host_buf->constant =tswapal (target_buf->constant); + host_buf->precision =tswapal (target_buf->precision); + host_buf->tolerance =tswapal (target_buf->tolerance); + host_buf->time.tv_sec =tswapal (target_buf->time.tv_sec); + host_buf->time.tv_usec =tswapal (target_buf->time.tv_usec);
linux-user/syscall.c static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, · line 6612
Quoted 10 lines
linux-user/syscall.c +10
-0+ host_buf->tick =tswapal (target_buf->tick); + host_buf->ppsfreq =tswapal (target_buf->ppsfreq); + host_buf->jitter =tswapal (target_buf->jitter); + host_buf->shift =tswap32 (target_buf->shift); + host_buf->stabil =tswapal (target_buf->stabil); + host_buf->jitcnt =tswapal (target_buf->jitcnt); + host_buf->calcnt =tswapal (target_buf->calcnt); + host_buf->errcnt =tswapal (target_buf->errcnt); + host_buf->stbcnt =tswapal (target_buf->stbcnt); + host_buf->tai =tswap32 (target_buf->tai);
You should use __get_user(), see
c7e35da linux-user: Handle negative values in timespec conversion
linux-user/syscall.c static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, · line 6621
Quoted 9 lines
linux-user/syscall.c +9
-0+ +unlock_user_struct (target_buf, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_timex (abi_long target_addr, +struct timex *host_buf) +{ +struct target_timex *target_buf;
target_tx?
Quoted 16 lines
linux-user/syscall.c +16
-0+ +if (!lock_user_struct (VERIFY_WRITE , target_buf, target_addr,0 )) { +return -TARGET_EFAULT ; + } + + target_buf->modes =tswap32 (host_buf->modes); + target_buf->offset =tswapal (host_buf->offset); + target_buf->freq =tswapal (host_buf->freq); + target_buf->maxerror =tswapal (host_buf->maxerror); + target_buf->esterror =tswapal (host_buf->esterror); + target_buf->status =tswap32 (host_buf->status); + target_buf->constant =tswapal (host_buf->constant); + target_buf->precision =tswapal (host_buf->precision); + target_buf->tolerance =tswapal (host_buf->tolerance); + target_buf->time.tv_sec =tswapal (host_buf->time.tv_sec); + target_buf->time.tv_usec =tswapal (host_buf->time.tv_usec);
linux-user/syscall.c static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, · line 6647
Quoted 10 lines
linux-user/syscall.c +10
-0+ target_buf->tick =tswapal (host_buf->tick); + target_buf->ppsfreq =tswapal (host_buf->ppsfreq); + target_buf->jitter =tswapal (host_buf->jitter); + target_buf->shift =tswap32 (host_buf->shift); + target_buf->stabil =tswapal (host_buf->stabil); + target_buf->jitcnt =tswapal (host_buf->jitcnt); + target_buf->calcnt =tswapal (host_buf->calcnt); + target_buf->errcnt =tswapal (host_buf->errcnt); + target_buf->stbcnt =tswapal (host_buf->stbcnt); + target_buf->tai =tswap32 (host_buf->tai);
I think you should use __put_user()...
Quoted 9 lines
linux-user/syscall.c +5
-0+unlock_user_struct (target_buf, target_addr,1 ); + return 0; +} +#endif +static inline abi_long target_to_host_timespec (struct timespec *host_ts,abi_ulong target_addr) {
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9499
Quoted 9 lines
linux-user/syscall.c +4
-1@@ -9419,8 +9492,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif +#ifdef TARGET_NR_adjtimexcase TARGET_NR_adjtimex: - goto unimplemented; + { +struct timex host_buf; +
check arg1 != NULL, so you manage target_to_host and host_to_target NULL case.
Quoted 41 lines
linux-user/syscall.c +12
-0+if (target_to_host_timex (&host_buf, arg1) !=0 ) { + goto efault; + } + ret =get_errno (adjtimex (&host_buf)); +if (!is_error (ret) && arg1) { +if (host_to_target_timex (arg1, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif linux-user/syscall_defs.h +18
-0@@ -207,6 +207,34 @@ struct target_itimerspec {struct target_timespec it_value; }; +struct target_timex { +unsigned int modes;/* Mode selector */ +abi_long offset;/* Time offset */ +abi_long freq;/* Frequency offset */ +abi_long maxerror;/* Maximum error (microseconds) */ +abi_long esterror;/* Estimated error (microseconds) */ +int status;/* Clock command/status */ +abi_long constant;/* PLL (phase-locked loop) time constant */ +abi_long precision;/* Clock precision (microseconds, ro) */ +abi_long tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target_timeval time;/* Current time */ +abi_long tick;/* Microseconds between clock ticks */ +abi_long ppsfreq;/* PPS (pulse per second) frequency */ +abi_long jitter;/* PPS jitter (ro); nanoseconds */ +int shift;/* PPS interval duration (seconds) */ +abi_long stabil;/* PPS stability */ +abi_long jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_long calcnt;/* PPS calibration intervals */
linux-user/syscall_defs.h struct target_itimerspec { · line 237
Quoted 10 lines
linux-user/syscall_defs.h +10
-0+abi_long errcnt;/* PPS calibration errors */ +abi_long stbcnt;/* PPS stability limit exceeded */ +int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; +}; +
for the alignment purpose, use abi_uint/abi_int instead of uint/int.
linux-user/syscall_defs.h struct target_itimerspec { · line 240
Quoted 4 lines
linux-user/syscall_defs.h +0
-0typedef abi_long target_clock_t ;#define TARGET_HZ 100
Thanks,
Laurent
Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Quoted 4 lines · Laurent Vivier
Le 14/09/2016 à 22:19, Aleksandar Markovic a écrit :
Quoted 16 lines
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9499
Quoted 13 lines
static inline
abi_longtarget_to_host_timespec(struct timespec*host_ts,
abi_ulongtarget_addr)
{linux-user/syscall.c +4
-1@@ -9419,8 +9492,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif +#ifdef TARGET_NR_adjtimexcase TARGET_NR_adjtimex: - goto unimplemented; + { +struct timex host_buf; +check arg1 != NULL, so you manage
target_to_hostandhost_to_targetNULL case.
In fact, I think you should not check that, it will be managed by lock_user_struct().
Laurent
Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
In reply to Aleksandar MarkovicQuoted 35 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
adjtimex()syscall support.Syscall
adjtimex()reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios.The implementation is based on invocation of host's
adjtimex(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. Also, support for related structure "timex" is added to the filelinux-user/syscall_defs.h, based on its definition in Linux kernel. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions,target_to_host_timex()andhost_to_target_timex(), are provided for the purpose of such conversions. Moreover, the relevant support for "-strace" Qemu option is included in fileslinux-user/strace.cand linux-user/strace.list.This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode.
Signed-off-by Aleksandar Rikalo <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 12 +++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 28 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-)linux-user/strace.c +0
-0
linux-user/strace.c print_access(const struct syscallname *name, · line 922
Quoted 4 lines
linux-user/strace.c +1
-0@@ -919,6 +919,18 @@ print_access(const struct syscallname *name, }#endif +#ifdef TARGET_NR_adjtimex
The ifdef isn't needed, all linux platorms support adjtimex.
Quoted 186 lines
linux-user/strace.c +11
-0+static void +print_adjtimex (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,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name,linux-user/strace.list +1
-1@@ -16,7 +16,7 @@ { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_adjtimex -{ TARGET_NR_adjtimex, "adjtimex" , NULL, NULL, NULL }, +{ TARGET_NR_adjtimex, "adjtimex" , NULL, print_adjtimex, NULL }, #endif #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL },linux-user/syscall.c +89
-1@@ -35,6 +35,7 @@#include <sys/swap.h> #include <linux/capability.h> #include <sched.h> +#include <sys/timex.h> #ifdef __ia64__int __clone2 (int (*fn)(void *),void *child_stack_base,size_t stack_size,int flags,void *arg, ...);@@ -6578,6 +6579,78 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif +#ifdef TARGET_NR_adjtimex +static inline abi_long target_to_host_timex (struct timex *host_buf, +abi_long target_addr) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_READ , target_buf, target_addr,1 )) { +return -TARGET_EFAULT ; + } + + host_buf->modes =tswap32 (target_buf->modes); + host_buf->offset =tswapal (target_buf->offset); + host_buf->freq =tswapal (target_buf->freq); + host_buf->maxerror =tswapal (target_buf->maxerror); + host_buf->esterror =tswapal (target_buf->esterror); + host_buf->status =tswap32 (target_buf->status); + host_buf->constant =tswapal (target_buf->constant); + host_buf->precision =tswapal (target_buf->precision); + host_buf->tolerance =tswapal (target_buf->tolerance); + host_buf->time.tv_sec =tswapal (target_buf->time.tv_sec); + host_buf->time.tv_usec =tswapal (target_buf->time.tv_usec); + host_buf->tick =tswapal (target_buf->tick); + host_buf->ppsfreq =tswapal (target_buf->ppsfreq); + host_buf->jitter =tswapal (target_buf->jitter); + host_buf->shift =tswap32 (target_buf->shift); + host_buf->stabil =tswapal (target_buf->stabil); + host_buf->jitcnt =tswapal (target_buf->jitcnt); + host_buf->calcnt =tswapal (target_buf->calcnt); + host_buf->errcnt =tswapal (target_buf->errcnt); + host_buf->stbcnt =tswapal (target_buf->stbcnt); + host_buf->tai =tswap32 (target_buf->tai); + +unlock_user_struct (target_buf, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_timex (abi_long target_addr, +struct timex *host_buf) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_WRITE , target_buf, target_addr,0 )) { +return -TARGET_EFAULT ; + } + + target_buf->modes =tswap32 (host_buf->modes); + target_buf->offset =tswapal (host_buf->offset); + target_buf->freq =tswapal (host_buf->freq); + target_buf->maxerror =tswapal (host_buf->maxerror); + target_buf->esterror =tswapal (host_buf->esterror); + target_buf->status =tswap32 (host_buf->status); + target_buf->constant =tswapal (host_buf->constant); + target_buf->precision =tswapal (host_buf->precision); + target_buf->tolerance =tswapal (host_buf->tolerance); + target_buf->time.tv_sec =tswapal (host_buf->time.tv_sec); + target_buf->time.tv_usec =tswapal (host_buf->time.tv_usec); + target_buf->tick =tswapal (host_buf->tick); + target_buf->ppsfreq =tswapal (host_buf->ppsfreq); + target_buf->jitter =tswapal (host_buf->jitter); + target_buf->shift =tswap32 (host_buf->shift); + target_buf->stabil =tswapal (host_buf->stabil); + target_buf->jitcnt =tswapal (host_buf->jitcnt); + target_buf->calcnt =tswapal (host_buf->calcnt); + target_buf->errcnt =tswapal (host_buf->errcnt); + target_buf->stbcnt =tswapal (host_buf->stbcnt); + target_buf->tai =tswap32 (host_buf->tai); + +unlock_user_struct (target_buf, target_addr,1 ); +return 0 ; +} +#endif +static inline abi_long target_to_host_timespec (struct timespec *host_ts,abi_ulong target_addr) {@@ -9419,8 +9492,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif +#ifdef TARGET_NR_adjtimexcase TARGET_NR_adjtimex: - goto unimplemented; + { +struct timex host_buf; + +if (target_to_host_timex (&host_buf, arg1) !=0 ) { + goto efault; + } + ret =get_errno (adjtimex (&host_buf)); +if (!is_error (ret) && arg1) { +if (host_to_target_timex (arg1, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif linux-user/syscall_defs.h +28
-0@@ -207,6 +207,34 @@ struct target_itimerspec {struct target_timespec it_value; }; +struct target_timex { +unsigned int modes;/* Mode selector */ +abi_long offset;/* Time offset */ +abi_long freq;/* Frequency offset */ +abi_long maxerror;/* Maximum error (microseconds) */ +abi_long esterror;/* Estimated error (microseconds) */ +int status;/* Clock command/status */ +abi_long constant;/* PLL (phase-locked loop) time constant */ +abi_long precision;/* Clock precision (microseconds, ro) */ +abi_long tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target_timeval time;/* Current time */ +abi_long tick;/* Microseconds between clock ticks */ +abi_long ppsfreq;/* PPS (pulse per second) frequency */ +abi_long jitter;/* PPS jitter (ro); nanoseconds */ +int shift;/* PPS interval duration (seconds) */ +abi_long stabil;/* PPS stability */ +abi_long jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_long calcnt;/* PPS calibration intervals */ +abi_long errcnt;/* PPS calibration errors */ +abi_long stbcnt;/* PPS stability limit exceeded */ +int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Hi, Riku,
Thanks a lots for your review.
I have no problem deleting "#ifdef TARGET_NR_adjtimex" in strace.c.
However, I want to bring to your attention the case of future target Linux platforms seizing supporting adjtimex(). Let's say this reflects in such a way that TARGET_NR_adjtimex is not defined for such platform. Then we will have a compiler error that print_adjtimex() is unused. With "ifdef", we wouldn't.
Thanks,
Aleksandar
________________________________________
From: Riku Voipio [[email protected]]
Sent: Wednesday, September 21, 2016 9:42 PM
To: Aleksandar Markovic
Cc: [email protected]; [email protected]; Petar Jovanovic; Miodrag Dinic; Aleksandar Rikalo; Aleksandar Markovic
Subject: Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Quoted 35 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
adjtimex()syscall support.Syscall
adjtimex()reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios.The implementation is based on invocation of host's
adjtimex(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. Also, support for related structure "timex" is added to the filelinux-user/syscall_defs.h, based on its definition in Linux kernel. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions,target_to_host_timex()andhost_to_target_timex(), are provided for the purpose of such conversions. Moreover, the relevant support for "-strace" Qemu option is included in fileslinux-user/strace.cand linux-user/strace.list.This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode.
Signed-off-by Aleksandar Rikalo <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 12 +++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 28 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-)linux-user/strace.c +0
-0
linux-user/strace.c print_access(const struct syscallname *name, · line 922
Quoted 4 lines
linux-user/strace.c +1
-0@@ -919,6 +919,18 @@ print_access(const struct syscallname *name, }#endif +#ifdef TARGET_NR_adjtimex
The ifdef isn't needed, all linux platorms support adjtimex.
Quoted 186 lines
linux-user/strace.c +11
-0+static void +print_adjtimex (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,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name,linux-user/strace.list +1
-1@@ -16,7 +16,7 @@ { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_adjtimex -{ TARGET_NR_adjtimex, "adjtimex" , NULL, NULL, NULL }, +{ TARGET_NR_adjtimex, "adjtimex" , NULL, print_adjtimex, NULL }, #endif #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL },linux-user/syscall.c +89
-1@@ -35,6 +35,7 @@#include <sys/swap.h> #include <linux/capability.h> #include <sched.h> +#include <sys/timex.h> #ifdef __ia64__int __clone2 (int (*fn)(void *),void *child_stack_base,size_t stack_size,int flags,void *arg, ...);@@ -6578,6 +6579,78 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif +#ifdef TARGET_NR_adjtimex +static inline abi_long target_to_host_timex (struct timex *host_buf, +abi_long target_addr) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_READ , target_buf, target_addr,1 )) { +return -TARGET_EFAULT ; + } + + host_buf->modes =tswap32 (target_buf->modes); + host_buf->offset =tswapal (target_buf->offset); + host_buf->freq =tswapal (target_buf->freq); + host_buf->maxerror =tswapal (target_buf->maxerror); + host_buf->esterror =tswapal (target_buf->esterror); + host_buf->status =tswap32 (target_buf->status); + host_buf->constant =tswapal (target_buf->constant); + host_buf->precision =tswapal (target_buf->precision); + host_buf->tolerance =tswapal (target_buf->tolerance); + host_buf->time.tv_sec =tswapal (target_buf->time.tv_sec); + host_buf->time.tv_usec =tswapal (target_buf->time.tv_usec); + host_buf->tick =tswapal (target_buf->tick); + host_buf->ppsfreq =tswapal (target_buf->ppsfreq); + host_buf->jitter =tswapal (target_buf->jitter); + host_buf->shift =tswap32 (target_buf->shift); + host_buf->stabil =tswapal (target_buf->stabil); + host_buf->jitcnt =tswapal (target_buf->jitcnt); + host_buf->calcnt =tswapal (target_buf->calcnt); + host_buf->errcnt =tswapal (target_buf->errcnt); + host_buf->stbcnt =tswapal (target_buf->stbcnt); + host_buf->tai =tswap32 (target_buf->tai); + +unlock_user_struct (target_buf, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_timex (abi_long target_addr, +struct timex *host_buf) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_WRITE , target_buf, target_addr,0 )) { +return -TARGET_EFAULT ; + } + + target_buf->modes =tswap32 (host_buf->modes); + target_buf->offset =tswapal (host_buf->offset); + target_buf->freq =tswapal (host_buf->freq); + target_buf->maxerror =tswapal (host_buf->maxerror); + target_buf->esterror =tswapal (host_buf->esterror); + target_buf->status =tswap32 (host_buf->status); + target_buf->constant =tswapal (host_buf->constant); + target_buf->precision =tswapal (host_buf->precision); + target_buf->tolerance =tswapal (host_buf->tolerance); + target_buf->time.tv_sec =tswapal (host_buf->time.tv_sec); + target_buf->time.tv_usec =tswapal (host_buf->time.tv_usec); + target_buf->tick =tswapal (host_buf->tick); + target_buf->ppsfreq =tswapal (host_buf->ppsfreq); + target_buf->jitter =tswapal (host_buf->jitter); + target_buf->shift =tswap32 (host_buf->shift); + target_buf->stabil =tswapal (host_buf->stabil); + target_buf->jitcnt =tswapal (host_buf->jitcnt); + target_buf->calcnt =tswapal (host_buf->calcnt); + target_buf->errcnt =tswapal (host_buf->errcnt); + target_buf->stbcnt =tswapal (host_buf->stbcnt); + target_buf->tai =tswap32 (host_buf->tai); + +unlock_user_struct (target_buf, target_addr,1 ); +return 0 ; +} +#endif +static inline abi_long target_to_host_timespec (struct timespec *host_ts,abi_ulong target_addr) {@@ -9419,8 +9492,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif +#ifdef TARGET_NR_adjtimexcase TARGET_NR_adjtimex: - goto unimplemented; + { +struct timex host_buf; + +if (target_to_host_timex (&host_buf, arg1) !=0 ) { + goto efault; + } + ret =get_errno (adjtimex (&host_buf)); +if (!is_error (ret) && arg1) { +if (host_to_target_timex (arg1, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif linux-user/syscall_defs.h +28
-1@@ -207,6 +207,34 @@ struct target_itimerspec {struct target_timespec it_value; }; +struct target_timex { +unsigned int modes;/* Mode selector */ +abi_long offset;/* Time offset */ +abi_long freq;/* Frequency offset */ +abi_long maxerror;/* Maximum error (microseconds) */ +abi_long esterror;/* Estimated error (microseconds) */ +int status;/* Clock command/status */ +abi_long constant;/* PLL (phase-locked loop) time constant */ +abi_long precision;/* Clock precision (microseconds, ro) */ +abi_long tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target_timeval time;/* Current time */ +abi_long tick;/* Microseconds between clock ticks */ +abi_long ppsfreq;/* PPS (pulse per second) frequency */ +abi_long jitter;/* PPS jitter (ro); nanoseconds */ +int shift;/* PPS interval duration (seconds) */ +abi_long stabil;/* PPS stability */ +abi_long jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_long calcnt;/* PPS calibration intervals */ +abi_long errcnt;/* PPS calibration errors */ +abi_long stbcnt;/* PPS stability limit exceeded */ +int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100 --2.9.3
Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Quoted 8 lines · Aleksandar Markovic
Hi, Riku,
Thanks a lots for your review.
I have no problem deleting "#ifdef
TARGET_NR_adjtimex" instrace.c.However, I want to bring to your attention the case of future target Linux platforms seizing supporting
adjtimex(). Let's say this reflects in such a way thatTARGET_NR_adjtimexis not defined for such platform. Then we will have a compiler error thatprint_adjtimex()is unused. With "ifdef", we wouldn't.
To add a new plaform to qemu, changes to the code are needed anyways, so adding an ifdef then isn't a problem. The #ifdef TARGET_NR_ guards are useful for 1) legacy syscalls that new platforms don't support, or 2) new syscalls that old platforms don't support (yet). adjtimex may be deprecated on day, but even the new platforms (aarch64, ppc64le) have opted to support it.
Quoted 239 lines
Thanks,
Aleksandar________________________________________
From: Riku Voipio [[email protected]]
Sent: Wednesday, September 21, 2016 9:42 PM
To: Aleksandar Markovic
Cc: [email protected]; [email protected]; Petar Jovanovic; Miodrag Dinic; Aleksandar Rikalo; Aleksandar Markovic
Subject: Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support foradjtimex()syscallQuoted 35 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
adjtimex()syscall support.Syscall
adjtimex()reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios.The implementation is based on invocation of host's
adjtimex(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. Also, support for related structure "timex" is added to the filelinux-user/syscall_defs.h, based on its definition in Linux kernel. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions,target_to_host_timex()andhost_to_target_timex(), are provided for the purpose of such conversions. Moreover, the relevant support for "-strace" Qemu option is included in fileslinux-user/strace.cand linux-user/strace.list.This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode.
Signed-off-by Aleksandar Rikalo <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 12 +++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 28 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-)linux-user/strace.c +0
-0linux-user/strace.c print_access(const struct syscallname *name, · line 922
Quoted 4 lines
linux-user/strace.c +1
-0@@ -919,6 +919,18 @@ print_access(const struct syscallname *name, }#endif +#ifdef TARGET_NR_adjtimexThe ifdef isn't needed, all linux platorms support adjtimex.
Quoted 186 lines
linux-user/strace.c +11
-0+static void +print_adjtimex (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,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name,linux-user/strace.list +1
-1@@ -16,7 +16,7 @@ { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_adjtimex -{ TARGET_NR_adjtimex, "adjtimex" , NULL, NULL, NULL }, +{ TARGET_NR_adjtimex, "adjtimex" , NULL, print_adjtimex, NULL }, #endif #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL },linux-user/syscall.c +89
-1@@ -35,6 +35,7 @@#include <sys/swap.h> #include <linux/capability.h> #include <sched.h> +#include <sys/timex.h> #ifdef __ia64__int __clone2 (int (*fn)(void *),void *child_stack_base,size_t stack_size,int flags,void *arg, ...);@@ -6578,6 +6579,78 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif +#ifdef TARGET_NR_adjtimex +static inline abi_long target_to_host_timex (struct timex *host_buf, +abi_long target_addr) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_READ , target_buf, target_addr,1 )) { +return -TARGET_EFAULT ; + } + + host_buf->modes =tswap32 (target_buf->modes); + host_buf->offset =tswapal (target_buf->offset); + host_buf->freq =tswapal (target_buf->freq); + host_buf->maxerror =tswapal (target_buf->maxerror); + host_buf->esterror =tswapal (target_buf->esterror); + host_buf->status =tswap32 (target_buf->status); + host_buf->constant =tswapal (target_buf->constant); + host_buf->precision =tswapal (target_buf->precision); + host_buf->tolerance =tswapal (target_buf->tolerance); + host_buf->time.tv_sec =tswapal (target_buf->time.tv_sec); + host_buf->time.tv_usec =tswapal (target_buf->time.tv_usec); + host_buf->tick =tswapal (target_buf->tick); + host_buf->ppsfreq =tswapal (target_buf->ppsfreq); + host_buf->jitter =tswapal (target_buf->jitter); + host_buf->shift =tswap32 (target_buf->shift); + host_buf->stabil =tswapal (target_buf->stabil); + host_buf->jitcnt =tswapal (target_buf->jitcnt); + host_buf->calcnt =tswapal (target_buf->calcnt); + host_buf->errcnt =tswapal (target_buf->errcnt); + host_buf->stbcnt =tswapal (target_buf->stbcnt); + host_buf->tai =tswap32 (target_buf->tai); + +unlock_user_struct (target_buf, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_timex (abi_long target_addr, +struct timex *host_buf) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_WRITE , target_buf, target_addr,0 )) { +return -TARGET_EFAULT ; + } + + target_buf->modes =tswap32 (host_buf->modes); + target_buf->offset =tswapal (host_buf->offset); + target_buf->freq =tswapal (host_buf->freq); + target_buf->maxerror =tswapal (host_buf->maxerror); + target_buf->esterror =tswapal (host_buf->esterror); + target_buf->status =tswap32 (host_buf->status); + target_buf->constant =tswapal (host_buf->constant); + target_buf->precision =tswapal (host_buf->precision); + target_buf->tolerance =tswapal (host_buf->tolerance); + target_buf->time.tv_sec =tswapal (host_buf->time.tv_sec); + target_buf->time.tv_usec =tswapal (host_buf->time.tv_usec); + target_buf->tick =tswapal (host_buf->tick); + target_buf->ppsfreq =tswapal (host_buf->ppsfreq); + target_buf->jitter =tswapal (host_buf->jitter); + target_buf->shift =tswap32 (host_buf->shift); + target_buf->stabil =tswapal (host_buf->stabil); + target_buf->jitcnt =tswapal (host_buf->jitcnt); + target_buf->calcnt =tswapal (host_buf->calcnt); + target_buf->errcnt =tswapal (host_buf->errcnt); + target_buf->stbcnt =tswapal (host_buf->stbcnt); + target_buf->tai =tswap32 (host_buf->tai); + +unlock_user_struct (target_buf, target_addr,1 ); +return 0 ; +} +#endif +static inline abi_long target_to_host_timespec (struct timespec *host_ts,abi_ulong target_addr) {@@ -9419,8 +9492,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif +#ifdef TARGET_NR_adjtimexcase TARGET_NR_adjtimex: - goto unimplemented; + { +struct timex host_buf; + +if (target_to_host_timex (&host_buf, arg1) !=0 ) { + goto efault; + } + ret =get_errno (adjtimex (&host_buf)); +if (!is_error (ret) && arg1) { +if (host_to_target_timex (arg1, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif linux-user/syscall_defs.h +28
-1@@ -207,6 +207,34 @@ struct target_itimerspec {struct target_timespec it_value; }; +struct target_timex { +unsigned int modes;/* Mode selector */ +abi_long offset;/* Time offset */ +abi_long freq;/* Frequency offset */ +abi_long maxerror;/* Maximum error (microseconds) */ +abi_long esterror;/* Estimated error (microseconds) */ +int status;/* Clock command/status */ +abi_long constant;/* PLL (phase-locked loop) time constant */ +abi_long precision;/* Clock precision (microseconds, ro) */ +abi_long tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target_timeval time;/* Current time */ +abi_long tick;/* Microseconds between clock ticks */ +abi_long ppsfreq;/* PPS (pulse per second) frequency */ +abi_long jitter;/* PPS jitter (ro); nanoseconds */ +int shift;/* PPS interval duration (seconds) */ +abi_long stabil;/* PPS stability */ +abi_long jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_long calcnt;/* PPS calibration intervals */ +abi_long errcnt;/* PPS calibration errors */ +abi_long stbcnt;/* PPS stability limit exceeded */ +int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100 --2.9.3
Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Hi, Riku,
I really appreciate your clarification. I am going to address your concern in the next version of this series, which is planned to be posted in a short time.
Thank,
Aleksandar
________________________________________
From: Riku Voipio [[email protected]]
Sent: Thursday, September 22, 2016 1:12 AM
To: Aleksandar Markovic
Cc: Aleksandar Markovic; [email protected]; [email protected]; Petar Jovanovic; Miodrag Dinic; Aleksandar Rikalo
Subject: Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support for adjtimex() syscall
Quoted 8 lines · Aleksandar Markovic
Hi, Riku,
Thanks a lots for your review.
I have no problem deleting "#ifdef
TARGET_NR_adjtimex" instrace.c.However, I want to bring to your attention the case of future target Linux platforms seizing supporting
adjtimex(). Let's say this reflects in such a way thatTARGET_NR_adjtimexis not defined for such platform. Then we will have a compiler error thatprint_adjtimex()is unused. With "ifdef", we wouldn't.
To add a new plaform to qemu, changes to the code are needed anyways, so adding an ifdef then isn't a problem. The #ifdef TARGET_NR_ guards are useful for 1) legacy syscalls that new platforms don't support, or 2) new syscalls that old platforms don't support (yet). adjtimex may be deprecated on day, but even the new platforms (aarch64, ppc64le) have opted to support it.
Quoted 239 lines
Thanks,
Aleksandar________________________________________
From: Riku Voipio [[email protected]]
Sent: Wednesday, September 21, 2016 9:42 PM
To: Aleksandar Markovic
Cc: [email protected]; [email protected]; Petar Jovanovic; Miodrag Dinic; Aleksandar Rikalo; Aleksandar Markovic
Subject: Re: [Qemu-devel] [PATCH v5 1/8] linux-user: Add support foradjtimex()syscallQuoted 35 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
adjtimex()syscall support.Syscall
adjtimex()reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios.The implementation is based on invocation of host's
adjtimex(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. Also, support for related structure "timex" is added to the filelinux-user/syscall_defs.h, based on its definition in Linux kernel. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions,target_to_host_timex()andhost_to_target_timex(), are provided for the purpose of such conversions. Moreover, the relevant support for "-strace" Qemu option is included in fileslinux-user/strace.cand linux-user/strace.list.This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode.
Signed-off-by Aleksandar Rikalo <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 12 +++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 28 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-)linux-user/strace.c +0
-0linux-user/strace.c print_access(const struct syscallname *name, · line 922
Quoted 4 lines
linux-user/strace.c +1
-0@@ -919,6 +919,18 @@ print_access(const struct syscallname *name, }#endif +#ifdef TARGET_NR_adjtimexThe ifdef isn't needed, all linux platorms support adjtimex.
Quoted 186 lines
linux-user/strace.c +11
-0+static void +print_adjtimex (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,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_brk static void print_brk(const struct syscallname *name,linux-user/strace.list +1
-1@@ -16,7 +16,7 @@ { TARGET_NR_add_key, "add_key" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_adjtimex -{ TARGET_NR_adjtimex, "adjtimex" , NULL, NULL, NULL }, +{ TARGET_NR_adjtimex, "adjtimex" , NULL, print_adjtimex, NULL }, #endif #ifdef TARGET_NR_afs_syscall { TARGET_NR_afs_syscall, "afs_syscall" , NULL, NULL, NULL },linux-user/syscall.c +89
-1@@ -35,6 +35,7 @@#include <sys/swap.h> #include <linux/capability.h> #include <sched.h> +#include <sys/timex.h> #ifdef __ia64__int __clone2 (int (*fn)(void *),void *child_stack_base,size_t stack_size,int flags,void *arg, ...);@@ -6578,6 +6579,78 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif +#ifdef TARGET_NR_adjtimex +static inline abi_long target_to_host_timex (struct timex *host_buf, +abi_long target_addr) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_READ , target_buf, target_addr,1 )) { +return -TARGET_EFAULT ; + } + + host_buf->modes =tswap32 (target_buf->modes); + host_buf->offset =tswapal (target_buf->offset); + host_buf->freq =tswapal (target_buf->freq); + host_buf->maxerror =tswapal (target_buf->maxerror); + host_buf->esterror =tswapal (target_buf->esterror); + host_buf->status =tswap32 (target_buf->status); + host_buf->constant =tswapal (target_buf->constant); + host_buf->precision =tswapal (target_buf->precision); + host_buf->tolerance =tswapal (target_buf->tolerance); + host_buf->time.tv_sec =tswapal (target_buf->time.tv_sec); + host_buf->time.tv_usec =tswapal (target_buf->time.tv_usec); + host_buf->tick =tswapal (target_buf->tick); + host_buf->ppsfreq =tswapal (target_buf->ppsfreq); + host_buf->jitter =tswapal (target_buf->jitter); + host_buf->shift =tswap32 (target_buf->shift); + host_buf->stabil =tswapal (target_buf->stabil); + host_buf->jitcnt =tswapal (target_buf->jitcnt); + host_buf->calcnt =tswapal (target_buf->calcnt); + host_buf->errcnt =tswapal (target_buf->errcnt); + host_buf->stbcnt =tswapal (target_buf->stbcnt); + host_buf->tai =tswap32 (target_buf->tai); + +unlock_user_struct (target_buf, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_timex (abi_long target_addr, +struct timex *host_buf) +{ +struct target_timex *target_buf; + +if (!lock_user_struct (VERIFY_WRITE , target_buf, target_addr,0 )) { +return -TARGET_EFAULT ; + } + + target_buf->modes =tswap32 (host_buf->modes); + target_buf->offset =tswapal (host_buf->offset); + target_buf->freq =tswapal (host_buf->freq); + target_buf->maxerror =tswapal (host_buf->maxerror); + target_buf->esterror =tswapal (host_buf->esterror); + target_buf->status =tswap32 (host_buf->status); + target_buf->constant =tswapal (host_buf->constant); + target_buf->precision =tswapal (host_buf->precision); + target_buf->tolerance =tswapal (host_buf->tolerance); + target_buf->time.tv_sec =tswapal (host_buf->time.tv_sec); + target_buf->time.tv_usec =tswapal (host_buf->time.tv_usec); + target_buf->tick =tswapal (host_buf->tick); + target_buf->ppsfreq =tswapal (host_buf->ppsfreq); + target_buf->jitter =tswapal (host_buf->jitter); + target_buf->shift =tswap32 (host_buf->shift); + target_buf->stabil =tswapal (host_buf->stabil); + target_buf->jitcnt =tswapal (host_buf->jitcnt); + target_buf->calcnt =tswapal (host_buf->calcnt); + target_buf->errcnt =tswapal (host_buf->errcnt); + target_buf->stbcnt =tswapal (host_buf->stbcnt); + target_buf->tai =tswap32 (host_buf->tai); + +unlock_user_struct (target_buf, target_addr,1 ); +return 0 ; +} +#endif +static inline abi_long target_to_host_timespec (struct timespec *host_ts,abi_ulong target_addr) {@@ -9419,8 +9492,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif #endif +#ifdef TARGET_NR_adjtimexcase TARGET_NR_adjtimex: - goto unimplemented; + { +struct timex host_buf; + +if (target_to_host_timex (&host_buf, arg1) !=0 ) { + goto efault; + } + ret =get_errno (adjtimex (&host_buf)); +if (!is_error (ret) && arg1) { +if (host_to_target_timex (arg1, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif linux-user/syscall_defs.h +28
-1@@ -207,6 +207,34 @@ struct target_itimerspec {struct target_timespec it_value; }; +struct target_timex { +unsigned int modes;/* Mode selector */ +abi_long offset;/* Time offset */ +abi_long freq;/* Frequency offset */ +abi_long maxerror;/* Maximum error (microseconds) */ +abi_long esterror;/* Estimated error (microseconds) */ +int status;/* Clock command/status */ +abi_long constant;/* PLL (phase-locked loop) time constant */ +abi_long precision;/* Clock precision (microseconds, ro) */ +abi_long tolerance;/* Clock freq. tolerance (ppm, ro) */ +struct target_timeval time;/* Current time */ +abi_long tick;/* Microseconds between clock ticks */ +abi_long ppsfreq;/* PPS (pulse per second) frequency */ +abi_long jitter;/* PPS jitter (ro); nanoseconds */ +int shift;/* PPS interval duration (seconds) */ +abi_long stabil;/* PPS stability */ +abi_long jitcnt;/* PPS jitter limit exceeded (ro) */ +abi_long calcnt;/* PPS calibration intervals */ +abi_long errcnt;/* PPS calibration errors */ +abi_long stbcnt;/* PPS stability limit exceeded */ +int tai;/* TAI offset */ + +/* Further padding bytes to allow for future expansion */ + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; int:32; + int:32; int:32; int:32; +}; +typedef abi_long target_clock_t ;#define TARGET_HZ 100 --2.9.3
PATCH v5 2/8 linux-user: Add support for clock_adjtime() syscall
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode clock_adjtime() syscall support.
The implementation is based on invocation of host's clock_adjtime(), and is very similar to the implementation of adjtimex() syscall support. The main difference is the presence of "clockid_t" argument in clock_adjtime().
--- linux-user/strace.c | 13 +++++++++++++ linux-user/strace.list | 3 +++ linux-user/syscall.c | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-)
linux-user/strace.c +13 -0
@@ -968,6 +968,19 @@ print_chmod(const struct syscallname *name, }#endif +#ifdef TARGET_NR_clock_adjtime +static void +print_clock_adjtime (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_raw_param ("%d" , arg0,0 ); +print_pointer (arg1,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_clone static void do_print_clone(unsigned int flags, abi_ulong newsp, abi_ulong parent_tidptr, target_ulong newtls,
linux-user/strace.list +3 -0
@@ -72,6 +72,9 @@ #ifdef TARGET_NR_chroot { TARGET_NR_chroot, "chroot" , NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_clock_adjtime +{ 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 }, #endif
linux-user/syscall.c +18 -1
@@ -6579,7 +6579,7 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif -#ifdef TARGET_NR_adjtimex +#if defined(TARGET_NR_adjtimex) || defined(TARGET_NR_clock_adjtime)static inline abi_long target_to_host_timex (struct timex *host_buf,abi_long target_addr) {
@@ -9509,6 +9509,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif +#ifdef TARGET_NR_clock_adjtime +case TARGET_NR_clock_adjtime: + { +struct timex host_buf; + +if (target_to_host_timex (&host_buf, arg2) !=0 ) { + goto efault; + } + ret =get_errno (clock_adjtime (arg1, &host_buf)); +if (!is_error (ret) && arg1) { +if (host_to_target_timex (arg2, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 2/8] linux-user: Add support for clock_adjtime() syscall
Quoted 71 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
clock_adjtime()syscall support.The implementation is based on invocation of host's
clock_adjtime(), and is very similar to the implementation ofadjtimex()syscall support. The main difference is the presence of "clockid_t" argument inclock_adjtime().Signed-off-by Aleksandar Rikalo <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 13 +++++++++++++ linux-user/strace.list | 3 +++ linux-user/syscall.c | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-)linux-user/strace.c +13
-0@@ -968,6 +968,19 @@ print_chmod(const struct syscallname *name, }#endif +#ifdef TARGET_NR_clock_adjtime +static void +print_clock_adjtime (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_raw_param ("%d" , arg0,0 ); +print_pointer (arg1,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_clone static void do_print_clone(unsigned int flags, abi_ulong newsp, abi_ulong parent_tidptr, target_ulong newtls,linux-user/strace.list +3
-0@@ -72,6 +72,9 @@ #ifdef TARGET_NR_chroot { TARGET_NR_chroot, "chroot" , NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_clock_adjtime +{ 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 }, #endiflinux-user/syscall.c +1
-1@@ -6579,7 +6579,7 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, }#endif -#ifdef TARGET_NR_adjtimex +#if defined(TARGET_NR_adjtimex) || defined(TARGET_NR_clock_adjtime)static inline abi_long target_to_host_timex (struct timex *host_buf,abi_long target_addr) {@@ -9509,6 +9509,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }break ;#endif
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9521
Quoted 10 lines
linux-user/syscall.c +10
-0+#ifdef TARGET_NR_clock_adjtime +case TARGET_NR_clock_adjtime: + { +struct timex host_buf; + +if (target_to_host_timex (&host_buf, arg2) !=0 ) { + goto efault; + } + ret =get_errno (clock_adjtime (arg1, &host_buf)); +if (!is_error (ret) && arg1) {
Why do you check arg1 here ?
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9531
Quoted 11 lines
linux-user/syscall.c +7
-0+if (host_to_target_timex (arg2, &host_buf) !=0 ) { + goto efault; + } + } + } +break ; +#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:#endif
Laurent
PATCH v5 3/8 linux-user: Add support for sysfs() syscall
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode sysfs() syscall support.
Syscall sysfs() involves returning information about the filesystem types currently present in the kernel, and can operate in three distinct flavors, depending on its first argument.
The implementation is based on invocation of host's sysfs(), and its key part is in the correspondent case segment of the main switch statement of the function do_syscall(), in file linux-user/syscalls.c. All necessary conversions of data structures from target to host and from host to target are covered. Based on the value of the first argument, three cases are distinguished, and such conversions are implemented separately for each case. Relevant support for "-strace" option is included in files linux-user/strace.c and linux-user/strace.list.
This patch also fixes failures of LTP tests sysfs01, sysfs02, sysfs03, sysfs04, sysfs05, and sysfs06, if executed in Qemu user mode.
--- linux-user/strace.c | 25 +++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 2 deletions(-)
linux-user/strace.c +25 -0
@@ -2151,6 +2151,31 @@ print_kill(const struct syscallname *name, }#endif +#if defined(TARGET_NR_sysfs) +static void +print_sysfs (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); +switch (arg0) { +case 1 : +print_raw_param ("%d" , arg0,1 ); +print_string (arg1,1 ); +break ; +case 2 : +print_raw_param ("%d" , arg0,0 ); +print_raw_param ("%u" , arg1,0 ); +print_pointer (arg2,1 ); +break ; +default : +print_raw_param ("%d" , arg0,1 ); +break ; + } +print_syscall_epilogue (name); +} +#endif +/* * An array of all of the syscalls we know about */
linux-user/strace.list +1 -1
@@ -1371,7 +1371,7 @@ { TARGET_NR_sys_epoll_wait, "sys_epoll_wait" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_sysfs -{ TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL }, +{ TARGET_NR_sysfs, "sysfs" , NULL, print_sysfs, NULL }, #endif #ifdef TARGET_NR_sysinfo { TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },
linux-user/syscall.c +41 -1
48 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 3/8] linux-user: Add support for sysfs() syscall
Quoted 32 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
sysfs()syscall support.Syscall
sysfs()involves returning information about the filesystem types currently present in the kernel, and can operate in three distinct flavors, depending on its first argument.The implementation is based on invocation of host's
sysfs(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. All necessary conversions of data structures from target to host and from host to target are covered. Based on the value of the first argument, three cases are distinguished, and such conversions are implemented separately for each case. Relevant support for "-strace" option is included in fileslinux-user/strace.cand linux-user/strace.list.This patch also fixes failures of LTP tests sysfs01, sysfs02, sysfs03, sysfs04, sysfs05, and sysfs06, if executed in Qemu user mode.
Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 25 +++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 2 deletions(-)linux-user/strace.c +0
-0
linux-user/strace.c print_kill(const struct syscallname *name, · line 2160
Quoted 10 lines
linux-user/strace.c +7
-0@@ -2151,6 +2151,31 @@ print_kill(const struct syscallname *name, }#endif +#if defined(TARGET_NR_sysfs) +static void +print_sysfs (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);
perhaps you can move here:
print_raw_param("%d", arg0, 0);linux-user/strace.c print_kill(const struct syscallname *name, · line 2163
Quoted 3 lines
linux-user/strace.c +3
-0+switch (arg0) { +case 1 : +print_raw_param ("%d" , arg0,1 );
should be ", 0);"
linux-user/strace.c print_kill(const struct syscallname *name, · line 2173
Quoted 10 lines
linux-user/strace.c +10
-0+print_string (arg1,1 ); +break ; +case 2 : +print_raw_param ("%d" , arg0,0 ); +print_raw_param ("%u" , arg1,0 ); +print_pointer (arg2,1 ); +break ; +default : +print_raw_param ("%d" , arg0,1 ); +break ;
in syscall.c, you use 3 for this, and default is EINVAL.
Quoted 26 lines
linux-user/strace.c +5
-0+ } +print_syscall_epilogue (name); +} +#endif +/* * An array of all of the syscalls we know about */ linux-user/strace.list +1
-1@@ -1371,7 +1371,7 @@ { TARGET_NR_sys_epoll_wait, "sys_epoll_wait" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_sysfs -{ TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL }, +{ TARGET_NR_sysfs, "sysfs" , NULL, print_sysfs, NULL }, #endif #ifdef TARGET_NR_sysinfo { TARGET_NR_sysinfo, "sysinfo" , NULL, NULL, NULL },linux-user/syscall.c +0
-0
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9555
Quoted 8 lines
linux-user/syscall.c +4
-1@@ -9549,7 +9549,47 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_sysfscase TARGET_NR_sysfs: - goto unimplemented; +switch (arg1) { +case 1 : + { +if (arg2 !=0 ) {
"arg2 == NULL" will be managed by lock_user_string()
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9563
Quoted 8 lines
linux-user/syscall.c +8
-0+ p =lock_user_string (arg2); +if (!p) { + goto efault; + } + ret =get_errno (syscall (__NR_sysfs, arg1, p)); +unlock_user (p, arg2,0 ); + }else { + ret =get_errno (syscall (__NR_sysfs, arg1,NULL ));
why?
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9570
Quoted 7 lines
linux-user/syscall.c +7
-0+ } + } +break ; +case 2 : + { +if (arg3 !=0 ) { +char buf[PATH_MAX ];
PATH_MAX (4096) should be a little bit excessive for a filesystem name. they have rarely more than 16 characters.
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9582
Quoted 12 lines
linux-user/syscall.c +12
-0+int len; +memset (buf,0 ,PATH_MAX ); + ret =get_errno (syscall (__NR_sysfs, arg1, arg2, buf)); + len =PATH_MAX ; +if (len >strlen (buf)) { + len =strlen (buf); + } +if (copy_to_user (arg3, buf, len) !=0 ) { + goto efault; + } + }else { + ret =get_errno (syscall (__NR_sysfs, arg1, arg2,NULL ));
Why?
just let the copy_to_user() trigger the "goto efault" in the case of arg3 == 0.
Quoted 14 lines
linux-user/syscall.c +10
-0+ } + } +break ; +case 3 : + ret =get_errno (syscall (__NR_sysfs, arg1)); +break ; +default : + ret = -EINVAL ; + } +break ;#endif case TARGET_NR_personality: ret =get_errno (personality (arg1));
PATCH v5 4/8 linux-user: Add support for ustat() syscall
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode ustat() syscall support.
Syscall ustat() returns information about a mounted filesystem.
The implementation is similar to the implementations of statfs(), fstatfs() and other related syscalls. It is based on invocation of host's ustat(), and its key part is in the correspondent case segment of the main switch statement of the function do_syscall(), in file linux-user/syscalls.c. All necessary conversions of data structures from target to host and from host to target are covered. Sufficient support for "-strace" option for this syscall is already present, and this patch does not change it.
This patch also fixes failures of LTP tests ustat01, and ustat02, if executed on Qemu-emulated systems.
--- linux-user/syscall.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
linux-user/syscall.c +24 -1
@@ -48,6 +48,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,#include <sys/shm.h> #include <sys/sem.h> #include <sys/statfs.h> +#include <ustat.h> #include <utime.h> #include <sys/sysinfo.h> #include <sys/signalfd.h>
@@ -8098,7 +8099,29 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#ifdef TARGET_NR_ustatcase TARGET_NR_ustat: - goto unimplemented; + { +struct ustat ust; +int cnt; + ret =get_errno (ustat (arg1, &ust)); + +if (!is_error (ret)) { +struct ustat *target_ust; + +if (!lock_user_struct (VERIFY_WRITE , target_ust, arg2,0 )) { + goto efault; + } + +__put_user (ust.f_tfree, &target_ust->f_tfree); +__put_user (ust.f_tinode, &target_ust->f_tinode); + +for (cnt =0 ; cnt <6 ; cnt++) { +__put_user (ust.f_fname[cnt], &target_ust->f_fname[cnt]); +__put_user (ust.f_fpack[cnt], &target_ust->f_fpack[cnt]); + } +unlock_user_struct (target_ust, arg2,1 ); + } +break ; + }#endif #ifdef TARGET_NR_dup2case TARGET_NR_dup2:
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 4/8] linux-user: Add support for ustat() syscall
Quoted 37 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
This patch implements Qemu user mode
ustat()syscall support.Syscall
ustat()returns information about a mounted filesystem.The implementation is similar to the implementations of
statfs(),fstatfs()and other related syscalls. It is based on invocation of host'sustat(), and its key part is in the correspondent case segment of the main switch statement of the functiondo_syscall(), in filelinux-user/syscalls.c. All necessary conversions of data structures from target to host and from host to target are covered. Sufficient support for "-strace" option for this syscall is already present, and this patch does not change it.This patch also fixes failures of LTP tests ustat01, and ustat02, if executed on Qemu-emulated systems.
Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/syscall.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)linux-user/syscall.c +1
-0@@ -48,6 +48,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,#include <sys/shm.h> #include <sys/sem.h> #include <sys/statfs.h> +#include <ustat.h> #include <utime.h> #include <sys/sysinfo.h> #include <sys/signalfd.h> @@ -8098,7 +8099,29 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8108
Quoted 10 lines
linux-user/syscall.c +7
-1#ifdef TARGET_NR_ustatcase TARGET_NR_ustat: - goto unimplemented; + { +struct ustat ust; +int cnt; + ret =get_errno (ustat (arg1, &ust)); + +if (!is_error (ret)) { +struct ustat *target_ust;
You must define your own "struct target_ustat" as __kernel_daddr_t and __kernel_ino_t are long (or int).
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8120
Quoted 12 lines
linux-user/syscall.c +12
-0+ +if (!lock_user_struct (VERIFY_WRITE , target_ust, arg2,0 )) { + goto efault; + } + +__put_user (ust.f_tfree, &target_ust->f_tfree); +__put_user (ust.f_tinode, &target_ust->f_tinode); + +for (cnt =0 ; cnt <6 ; cnt++) { +__put_user (ust.f_fname[cnt], &target_ust->f_fname[cnt]); +__put_user (ust.f_fpack[cnt], &target_ust->f_fpack[cnt]); + }
As the structure is locked and they are "char", you can do memcpy().
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8127
Quoted 8 lines
linux-user/syscall.c +4
-0+ unlock_user_struct(target_ust, arg2, 1); + } +break ; + }#endif #ifdef TARGET_NR_dup2case TARGET_NR_dup2:
Laurent
PATCH v5 5/8 linux-user: Fix msgrcv() and msgsnd() syscalls support
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
If syscalls msgrcv() and msgsnd() fail, they return E2BIG, EACCES, EAGAIN, EFAULT, EIDRM, EINTR, EINVAL, ENOMEM, or ENOMSG.
By examining negative scenarios of these syscalls for Mips, it was established that ENOMSG does not have the same value accross all platforms, but it is nevertheless not included for conversion in the correspondant conversion table defined in linux-user/syscall.c. This is certainly a bug, since it leads to the incorrect emulation of msgrcv() and msgsnd() for scenarios involving ENOMSG.
This patch fixes this by extending the conversion table to include ENOMSG.
Also, LTP test msgrcv04 will be fixed for some platforms.
--- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+)
linux-user/syscall.c +3 -0
@@ -750,6 +750,9 @@ static uint16_t host_to_target_errno_table[ERRNO_TABLE_SIZE] = { #ifdef ENOTRECOVERABLE [ENOTRECOVERABLE ] =TARGET_ENOTRECOVERABLE , #endif +#ifdef ENOMSG + [ENOMSG] = TARGET_ENOMSG, +#endif };static inline int host_to_target_errno (int err)
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 5/8] linux-user: Fix msgrcv() and msgsnd() syscalls support
Quoted 12 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
If syscalls
msgrcv()andmsgsnd()fail, they return E2BIG, EACCES, EAGAIN, EFAULT, EIDRM, EINTR, EINVAL, ENOMEM, or ENOMSG.By examining negative scenarios of these syscalls for Mips, it was established that ENOMSG does not have the same value accross all platforms, but it is nevertheless not included for conversion in the correspondant conversion table defined in
linux-user/syscall.c. This is certainly a bug, since it leads to the incorrect emulation ofmsgrcv()andmsgsnd()for scenarios involving ENOMSG.
Quoted 6 lines
This patch fixes this by extending the conversion table to include ENOMSG.
Also, LTP test msgrcv04 will be fixed for some platforms.
Signed-off-by Aleksandar Markovic <[email protected]>
Quoted 19 lines
--- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+)linux-user/syscall.c +3
-0@@ -750,6 +750,9 @@ static uint16_t host_to_target_errno_table[ERRNO_TABLE_SIZE] = { #ifdef ENOTRECOVERABLE [ENOTRECOVERABLE ] =TARGET_ENOTRECOVERABLE , #endif +#ifdef ENOMSG + [ENOMSG] = TARGET_ENOMSG, +#endif };static inline int host_to_target_errno (int err)
Aleksandar Markovic
Reviewed-by Laurent VivierRe: [Qemu-devel] [PATCH v5 5/8] linux-user: Fix msgrcv() and msgsnd() syscalls support
Hello, Lorain.
I really appreciate your reviewing these patches. This was a great opportunity for me to learn a lot. I will address all your concerns about this series in its next version, which is planned to be posted by the end of this week. Regarding another series on Mips-specific issues, its v7 was posted on qemu-devel today.
Thanks,
Aleksandar
________________________________________
From: Laurent Vivier [[email protected]]
Sent: Saturday, September 17, 2016 4:43 PM
To: Aleksandar Markovic; [email protected]; [email protected]; [email protected]; Petar Jovanovic; Miodrag Dinic; Aleksandar Rikalo; Aleksandar Markovic
Subject: Re: [Qemu-devel] [PATCH v5 5/8] linux-user: Fix msgrcv() and msgsnd() syscalls support
Quoted 12 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
If syscalls
msgrcv()andmsgsnd()fail, they return E2BIG, EACCES, EAGAIN, EFAULT, EIDRM, EINTR, EINVAL, ENOMEM, or ENOMSG.By examining negative scenarios of these syscalls for Mips, it was established that ENOMSG does not have the same value accross all platforms, but it is nevertheless not included for conversion in the correspondant conversion table defined in
linux-user/syscall.c. This is certainly a bug, since it leads to the incorrect emulation ofmsgrcv()andmsgsnd()for scenarios involving ENOMSG.
Quoted 6 lines
This patch fixes this by extending the conversion table to include ENOMSG.
Also, LTP test msgrcv04 will be fixed for some platforms.
Signed-off-by Aleksandar Markovic <[email protected]>
Quoted 19 lines
--- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+)linux-user/syscall.c +3
-0@@ -750,6 +750,9 @@ static uint16_t host_to_target_errno_table[ERRNO_TABLE_SIZE] = { #ifdef ENOTRECOVERABLE [ENOTRECOVERABLE ] =TARGET_ENOTRECOVERABLE , #endif +#ifdef ENOMSG + [ENOMSG] = TARGET_ENOMSG, +#endif };static inline int host_to_target_errno (int err)
PATCH v5 6/8 linux-user: Fix socketcall() syscall support
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
do_socketcall() function in Qemu's syscalls.c is implemented to mirror corespondant implementation of socketcall() in Linux kernel. (see kernel source file net/socket.c, definition of socketcall).
However, error codes are wrong for the cases of invalid values of the first argument. This patch in this sense brings do_socketcall() closer to its kernel counterpart.
Also, this patch fixes failure of LTP test socketcall02, if executed on some Qemu emulated sywstems (uer mode).
--- linux-user/syscall.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
linux-user/syscall.c +12 -9
@@ -3845,15 +3845,18 @@ static abi_long do_socketcall(int num, abi_ulong vptr) [SOCKOP_getsockopt] = 5, /* sockfd, level, optname, optval, optlen */ };abi_long a[6 ];/* max 6 args */ +unsigned i; -/* first, collect the arguments in a[] according to ac[] */ -if (num >=0 && num <ARRAY_SIZE (ac)) { -unsigned i; -assert (ARRAY_SIZE (a) >= ac[num]);/* ensure we have space for args */ -for (i =0 ; i < ac[num]; ++i) { -if (get_user_ual (a[i], vptr + i *sizeof (abi_long)) !=0 ) { -return -TARGET_EFAULT ; - } +/* check the range of the first argument num */ +if (num <0 || num >ARRAY_SIZE (ac)) { +return -TARGET_EINVAL ; + } + +/* collect the arguments in a[] according to ac[] */ +assert (ARRAY_SIZE (a) >= ac[num]);/* ensure we have space for args */ +for (i =0 ; i < ac[num]; ++i) { +if (get_user_ual (a[i], vptr + i *sizeof (abi_long)) !=0 ) { +return -TARGET_EFAULT ; } }
@@ -3901,7 +3904,7 @@ static abi_long do_socketcall(int num, abi_ulong vptr)return do_getsockopt (a[0 ], a[1 ], a[2 ], a[3 ], a[4 ]);default :gemu_log ("Unsupported socketcall: %d\n" , num); - return -TARGET_ENOSYS; + return -TARGET_EINVAL; } }#endif
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 6/8] linux-user: Fix socketcall() syscall support
Quoted 30 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
do_socketcall()function in Qemu'ssyscalls.cis implemented to mirror corespondant implementation ofsocketcall()in Linux kernel. (see kernel source filenet/socket.c, definition of socketcall).However, error codes are wrong for the cases of invalid values of the first argument. This patch in this sense brings
do_socketcall()closer to its kernel counterpart.Also, this patch fixes failure of LTP test socketcall02, if executed on some Qemu emulated sywstems (uer mode).
Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/syscall.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)linux-user/syscall.c +1
-2@@ -3845,15 +3845,18 @@ static abi_long do_socketcall(int num, abi_ulong vptr) [SOCKOP_getsockopt] = 5, /* sockfd, level, optname, optval, optlen */ };abi_long a[6 ];/* max 6 args */ +unsigned i; -/* first, collect the arguments in a[] according to ac[] */ -if (num >=0 && num <ARRAY_SIZE (ac)) {
linux-user/syscall.c static abi_long do_socketcall(int num, abi_ulong vptr) · line 3853
Quoted 10 lines
linux-user/syscall.c +4
-6-unsigned i; -assert (ARRAY_SIZE (a) >= ac[num]);/* ensure we have space for args */ -for (i =0 ; i < ac[num]; ++i) { -if (get_user_ual (a[i], vptr + i *sizeof (abi_long)) !=0 ) { -return -TARGET_EFAULT ; - } +/* check the range of the first argument num */ +if (num <0 || num >ARRAY_SIZE (ac)) { +return -TARGET_EINVAL ; + }
I'm not sure you can check this using the array index. kernel checks against "num" value, i.e.:
if (num < 1 || num > SOCKOP_sendmmsg) {
return -TARGET_EINVAL;
}linux-user/syscall.c static abi_long do_socketcall(int num, abi_ulong vptr) · line 3856
Quoted 2 lines
linux-user/syscall.c +2
-0+/* collect the arguments in a[] according to ac[] */ +assert (ARRAY_SIZE (a) >= ac[num]);/* ensure we have space for args */
instead, do this like the kernel does:
if (ac[num] > ARRAY_SIZE(a)) {
return -TARGET_EINVAL;
}Quoted 16 lines
linux-user/syscall.c +4
-1+for (i =0 ; i < ac[num]; ++i) { +if (get_user_ual (a[i], vptr + i *sizeof (abi_long)) !=0 ) { +return -TARGET_EFAULT ; } }@@ -3901,7 +3904,7 @@ static abi_long do_socketcall(int num, abi_ulong vptr)return do_getsockopt (a[0 ], a[1 ], a[2 ], a[3 ], a[4 ]);default :gemu_log ("Unsupported socketcall: %d\n" , num); - return -TARGET_ENOSYS; + return -TARGET_EINVAL; } }#endif
PATCH v5 7/8 linux-user: Fix syslog() syscall support
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
There are currently several problems related to syslog() support.
For example, if the second argument "bufp" of target syslog() syscall is NULL, the current implementation always returns error code EFAULT. However, NULL is a perfectly valid value for the second argument for many use cases of this syscall. This is, for example, visible from this excerpt of man page for syslog(2):
Quoted 3 lines
EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
NULL, or len is less than zero; or for type 8, the level is outside the range 1 to 8).
Moreover, the argument "bufp" is ignored for all cases of values of the first argument, except 2, 3 and 4. This means that for such cases (the first argument is not 2, 3 or 4), there is no need to pass "buf" between host and target, and it can be set to NULL while calling host's syslog(), without loss of emulation accuracy.
Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the correct returned error code is EINVAL, not EFAULT.
All these details are reflected in this patch.
"#ifdef TARGET_NR_syslog" is also proprerly inserted when needed.
Support for Qemu's "-strace" switch for syslog() syscall is included too.
LTP tests syslog11 and syslog12 pass with this patch (while fail without it), on any platform.
--- linux-user/strace.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 23 +++++++++++----- linux-user/syscall_defs.h | 25 +++++++++++++++++ 4 files changed, 111 insertions(+), 7 deletions(-)
linux-user/strace.c +68 -0
@@ -1709,6 +1709,74 @@ print_rt_sigprocmask(const struct syscallname *name, }#endif +#ifdef TARGET_NR_syslog +static void +print_syslog_action (abi_ulong arg,int last) +{ +switch (arg) { +case TARGET_SYSLOG_ACTION_CLOSE : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_CLOSE" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_OPEN : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_OPEN" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_READ : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_READ" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_READ_ALL : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_READ_ALL" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_READ_CLEAR : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_READ_CLEAR" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_CLEAR : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_CLEAR" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_CONSOLE_OFF : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_CONSOLE_OFF" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_CONSOLE_ON : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_CONSOLE_ON" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_CONSOLE_LEVEL" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_SIZE_UNREAD : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_SIZE_UNREAD" ,get_comma (last)); +break ; + } +case TARGET_SYSLOG_ACTION_SIZE_BUFFER : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_SIZE_BUFFER" ,get_comma (last)); +break ; + } +default : { +print_raw_param ("%ld" , arg, last); + } + } +} + +static void +print_syslog (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_syslog_action (arg0,0 ); +print_pointer (arg1,0 ); +print_raw_param ("%d" , arg2,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_mknod static void print_mknod(const struct syscallname *name,
linux-user/strace.list +1 -1
@@ -1380,7 +1380,7 @@ { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_syslog -{ TARGET_NR_syslog, "syslog" , NULL, NULL, NULL }, +{ TARGET_NR_syslog, "syslog" , NULL, print_syslog, NULL }, #endif #ifdef TARGET_NR_sysmips { TARGET_NR_sysmips, "sysmips" , NULL, NULL, NULL },
linux-user/syscall.c +17 -6
@@ -9219,14 +9219,25 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =do_setsockopt (arg1, arg2, arg3, arg4, (socklen_t ) arg5);break ;#endif - +#ifdef TARGET_NR_syslogcase TARGET_NR_syslog: -if (!(p =lock_user_string (arg2))) - goto efault; - ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3)); -unlock_user (p, arg2,0 ); + { +if (((int )arg1 ==TARGET_SYSLOG_ACTION_READ ) || + ((int )arg1 ==TARGET_SYSLOG_ACTION_READ_ALL ) || + ((int )arg1 ==TARGET_SYSLOG_ACTION_READ_CLEAR )) { + p =lock_user_string (arg2); +if (!p) { + ret = -TARGET_EINVAL ; + goto fail; + } + ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3)); +unlock_user (p, arg2,0 ); + }else { + ret =get_errno (sys_syslog ((int )arg1,NULL , (int )arg3)); + } + }break ; - +#endif case TARGET_NR_setitimer: {struct itimerval value, ovalue, *pvalue;
linux-user/syscall_defs.h +25 -0
@@ -2661,4 +2661,29 @@ struct target_user_cap_data { uint32_t inheritable; }; +/* from kernel's include/linux/syslog.h */ + +/* Close the log. Currently a NOP. */ +#define TARGET_SYSLOG_ACTION_CLOSE 0 +/* Open the log. Currently a NOP. */ +#define TARGET_SYSLOG_ACTION_OPEN 1 +/* Read from the log. */ +#define TARGET_SYSLOG_ACTION_READ 2 +/* Read all messages remaining in the ring buffer. */ +#define TARGET_SYSLOG_ACTION_READ_ALL 3 +/* Read and clear all messages remaining in the ring buffer */ +#define TARGET_SYSLOG_ACTION_READ_CLEAR 4 +/* Clear ring buffer. */ +#define TARGET_SYSLOG_ACTION_CLEAR 5 +/* Disable printk's to console */ +#define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6 +/* Enable printk's to console */ +#define TARGET_SYSLOG_ACTION_CONSOLE_ON 7 +/* Set level of messages printed to console */ +#define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8 +/* Return number of unread characters in the log buffer */ +#define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9 +/* Return size of the log buffer */ +#define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10 +#endif
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 7/8] linux-user: Fix syslog() syscall support
Quoted 45 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
There are currently several problems related to
syslog()support.For example, if the second argument "bufp" of target
syslog()syscall is NULL, the current implementation always returns error code EFAULT. However, NULL is a perfectly valid value for the second argument for many use cases of this syscall. This is, for example, visible from this excerpt of man page for syslog(2):Quoted 3 lines
EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
NULL, or len is less than zero; or for type 8, the level is outside the range 1 to 8).Moreover, the argument "bufp" is ignored for all cases of values of the first argument, except 2, 3 and 4. This means that for such cases (the first argument is not 2, 3 or 4), there is no need to pass "buf" between host and target, and it can be set to NULL while calling host's
syslog(), without loss of emulation accuracy.Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the correct returned error code is EINVAL, not EFAULT.
All these details are reflected in this patch.
"#ifdef
TARGET_NR_syslog" is also proprerly inserted when needed.Support for Qemu's "-strace" switch for
syslog()syscall is included too.LTP tests syslog11 and syslog12 pass with this patch (while fail without it), on any platform.
Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 2 +- linux-user/syscall.c | 23 +++++++++++----- linux-user/syscall_defs.h | 25 +++++++++++++++++ 4 files changed, 111 insertions(+), 7 deletions(-)linux-user/strace.c +0
-0
linux-user/strace.c print_rt_sigprocmask(const struct syscallname *name, · line 1715
Quoted 7 lines
linux-user/strace.c +4
-0@@ -1709,6 +1709,74 @@ print_rt_sigprocmask(const struct syscallname *name, }#endif +#ifdef TARGET_NR_syslog +static void +print_syslog_action (abi_ulong arg,int last) +{
The double "%s" and duplicate gemu_log() are not really nice.
you can do:
const char *type;
linux-user/strace.c print_rt_sigprocmask(const struct syscallname *name, · line 1718
Quoted 3 lines
linux-user/strace.c +3
-0+switch (arg) { +case TARGET_SYSLOG_ACTION_CLOSE : { +gemu_log ("%s%s" ,"SYSLOG_ACTION_CLOSE" ,get_comma (last));
type = "SYSLOG_ACTION_CLOSE";
break;...
linux-user/strace.c print_rt_sigprocmask(const struct syscallname *name, · line 1762
Quoted 2 lines
linux-user/strace.c +2
-0+default : { +print_raw_param ("%ld" , arg, last);
return;
linux-user/strace.c
Quoted 2 lines
linux-user/strace.c +2
-0+ } + }
gemu_log(%s%s", type, get_comma(last));
Quoted 41 lines
linux-user/strace.c +15
-0+} + +static void +print_syslog (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_syslog_action (arg0,0 ); +print_pointer (arg1,0 ); +print_raw_param ("%d" , arg2,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_mknod static void print_mknod(const struct syscallname *name,linux-user/strace.list +1
-1@@ -1380,7 +1380,7 @@ { TARGET_NR_sys_kexec_load, "sys_kexec_load" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_syslog -{ TARGET_NR_syslog, "syslog" , NULL, NULL, NULL }, +{ TARGET_NR_syslog, "syslog" , NULL, print_syslog, NULL }, #endif #ifdef TARGET_NR_sysmips { TARGET_NR_sysmips, "sysmips" , NULL, NULL, NULL },linux-user/syscall.c +1
-1@@ -9219,14 +9219,25 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =do_setsockopt (arg1, arg2, arg3, arg4, (socklen_t ) arg5);break ;#endif - +#ifdef TARGET_NR_syslog
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9228
Quoted 10 lines
linux-user/syscall.c +5
-4case TARGET_NR_syslog: -if (!(p =lock_user_string (arg2))) - goto efault; - ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3)); -unlock_user (p, arg2,0 ); + { +if (((int )arg1 ==TARGET_SYSLOG_ACTION_READ ) || + ((int )arg1 ==TARGET_SYSLOG_ACTION_READ_ALL ) || + ((int )arg1 ==TARGET_SYSLOG_ACTION_READ_CLEAR )) { + p =lock_user_string (arg2);
arg2 is empty. length is given by arg3.
Use lock_user(VERIFY_WRITE, arg2, arg3, 0) for that.
linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9234
Quoted 6 lines
linux-user/syscall.c +6
-0+if (!p) { + ret = -TARGET_EINVAL ; + goto fail; + } + ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3)); +unlock_user (p, arg2,0 );
unlock_user(p, arg2, arg3);
Quoted 45 lines
linux-user/syscall.c +5
-1+ } else { + ret =get_errno (sys_syslog ((int )arg1,NULL , (int )arg3)); + } + }break ; - +#endif case TARGET_NR_setitimer: {struct itimerval value, ovalue, *pvalue;linux-user/syscall_defs.h +25
-0@@ -2661,4 +2661,29 @@ struct target_user_cap_data { uint32_t inheritable; }; +/* from kernel's include/linux/syslog.h */ + +/* Close the log. Currently a NOP. */ +#define TARGET_SYSLOG_ACTION_CLOSE 0 +/* Open the log. Currently a NOP. */ +#define TARGET_SYSLOG_ACTION_OPEN 1 +/* Read from the log. */ +#define TARGET_SYSLOG_ACTION_READ 2 +/* Read all messages remaining in the ring buffer. */ +#define TARGET_SYSLOG_ACTION_READ_ALL 3 +/* Read and clear all messages remaining in the ring buffer */ +#define TARGET_SYSLOG_ACTION_READ_CLEAR 4 +/* Clear ring buffer. */ +#define TARGET_SYSLOG_ACTION_CLEAR 5 +/* Disable printk's to console */ +#define TARGET_SYSLOG_ACTION_CONSOLE_OFF 6 +/* Enable printk's to console */ +#define TARGET_SYSLOG_ACTION_CONSOLE_ON 7 +/* Set level of messages printed to console */ +#define TARGET_SYSLOG_ACTION_CONSOLE_LEVEL 8 +/* Return number of unread characters in the log buffer */ +#define TARGET_SYSLOG_ACTION_SIZE_UNREAD 9 +/* Return size of the log buffer */ +#define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10 +#endif
PATCH v5 8/8 linux-user: Remove a duplicate item from strace.list
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
There is a duplicate item in strace.list. It is benign, but it shouldn't be there. It is the only duplicate in strace.list. This patch removes it.
--- linux-user/strace.list | 3 --- 1 file changed, 3 deletions(-)
linux-user/strace.list +0 -3
@@ -1532,9 +1532,6 @@ #ifdef TARGET_NR_utimensat { TARGET_NR_utimensat, "utimensat", NULL, print_utimensat, NULL }, #endif -#ifdef TARGET_NR_sync_file_range -{ TARGET_NR_sync_file_range, "sync_file_range", NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sync_file_range2 { TARGET_NR_sync_file_range2, "sync_file_range2", NULL, NULL, NULL }, #endif
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 8/8] linux-user: Remove a duplicate item from strace.list
Quoted 17 lines · Aleksandar Markovic
From: Aleksandar Markovic <[email protected]>
There is a duplicate item in strace.list. It is benign, but it shouldn't be there. It is the only duplicate in strace.list. This patch removes it.
Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/strace.list | 3 --- 1 file changed, 3 deletions(-)linux-user/strace.list +0
-0
linux-user/strace.list line 1537
Quoted 9 lines
linux-user/strace.list +0
-3@@ -1532,9 +1532,6 @@ #ifdef TARGET_NR_utimensat { TARGET_NR_utimensat, "utimensat", NULL, print_utimensat, NULL }, #endif -#ifdef TARGET_NR_sync_file_range -{ TARGET_NR_sync_file_range, "sync_file_range", NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sync_file_range2 { TARGET_NR_sync_file_range2, "sync_file_range2", NULL, NULL, NULL }, #endif
You should remove the other one, as this one has been added when the syscall has been implemented:
c727f47 linux-user: Implement sync_file_range{,2} syscalls
Laurent