linux-user updates
cover linux-user updates
From: Riku Voipio <[email protected]>
Hi,
I did a dig through the archive for linux-user patches that have slipped through during my inactivity. The ones in this patchset appear good and pass smoketest.
I will send these as pull request once I'm back from travel and can update my git repository.
Riku
Dillon Amburgey (3):
linux-user: Add Alpha socket constants
linux-user: Support setgroups syscall with no groups
linux-user: Add more sparc syscall numbers
John Rigby (2):
linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex
linux-user: fix futex strace of FUTEX_CLOCK_REALTIME
Laurent Vivier (2):
linux-user: improve print_fcntl()
linux-user: correct semctl() and shmctl()
linux-user/socket.h | 69 ++++++++++++++++++++++++++++ linux-user/sparc/syscall_nr.h | 2 + linux-user/strace.c | 103 ++++++++++++++++++++++++++++++++++-------- linux-user/syscall.c | 81 ++++++++++++++++++++------------- 4 files changed, 205 insertions(+), 50 deletions(-)
Signature · 1 line
1.8.1.2
PATCH 1/7 linux-user: Add Alpha socket constants
From: Dillon Amburgey <[email protected]>
Without these, some networking programs will not work
--- linux-user/socket.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
linux-user/socket.h +69 -0
@@ -87,6 +87,75 @@#define TARGET_SOCK_MAX (SOCK_PACKET + 1) +#elif defined(TARGET_ALPHA ) + +/* For setsockopt(2) */ +#define TARGET_SOL_SOCKET 0xffff + +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_LINGER 0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +/* To add :#define TARGET_SO_REUSEPORT 0x0200 */ + +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_SNDBUF 0x1001 +#define TARGET_SO_RCVBUF 0x1002 +#define TARGET_SO_SNDBUFFORCE 0x100a +#define TARGET_SO_RCVBUFFORCE 0x100b +#define TARGET_SO_RCVLOWAT 0x1010 +#define TARGET_SO_SNDLOWAT 0x1011 +#define TARGET_SO_RCVTIMEO 0x1012 +#define TARGET_SO_SNDTIMEO 0x1013 +#define TARGET_SO_ACCEPTCONN 0x1014 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN 0x1029 + +/* linux-specific, might as well be the same as on i386 */ +#define TARGET_SO_NO_CHECK 11 +#define TARGET_SO_PRIORITY 12 +#define TARGET_SO_BSDCOMPAT 14 + +#define TARGET_SO_PASSCRED 17 +#define TARGET_SO_PEERCRED 18 +#define TARGET_SO_BINDTODEVICE 25 + +/* Socket filtering */ +#define TARGET_SO_ATTACH_FILTER 26 +#define TARGET_SO_DETACH_FILTER 27 + +#define TARGET_SO_PEERNAME 28 +#define TARGET_SO_TIMESTAMP 29 +#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP + +#define TARGET_SO_PEERSEC 30 +#define TARGET_SO_PASSSEC 34 +#define TARGET_SO_TIMESTAMPNS 35 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define TARGET_SO_SECURITY_AUTHENTICATION 19 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 20 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 21 + +#define TARGET_SO_MARK 36 + +#define TARGET_SO_TIMESTAMPING 37 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING + +#define TARGET_SO_RXQ_OVFL 40 + +#define TARGET_SO_WIFI_STATUS 41 +#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF 42 + +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define TARGET_SO_NOFCS 43 +#else /* For setsockopt(2) */
Signature · 1 line
1.8.1.2
PATCH 2/7 linux-user: improve print_fcntl()
In reply to [email protected]From: Laurent Vivier <[email protected]>
--- linux-user/strace.c | 97 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 18 deletions(-)
linux-user/strace.c +79 -18
@@ -462,18 +462,6 @@ UNUSED static struct flags mmap_flags[] = { FLAG_END, }; -UNUSED static struct flags fcntl_flags[] = { -FLAG_TARGET (F_DUPFD ), -FLAG_TARGET (F_GETFD ), -FLAG_TARGET (F_SETFD ), -FLAG_TARGET (F_GETFL ), -FLAG_TARGET (F_SETFL ), -FLAG_TARGET (F_GETLK ), -FLAG_TARGET (F_SETLK ), -FLAG_TARGET (F_SETLKW ), -FLAG_END , -}; - UNUSED static struct flags clone_flags[] = {FLAG_GENERIC (CLONE_VM ),FLAG_GENERIC (CLONE_FS ),
@@ -867,12 +855,85 @@ print_fcntl(const struct syscallname *name, {print_syscall_prologue (name);print_raw_param ("%d" , arg0,0 ); -print_flags (fcntl_flags, arg1,0 ); -/* -* TODO: check flags and print following argument only -* when needed. -*/ -print_pointer (arg2,1 ); +switch (arg1) { +case TARGET_F_DUPFD : +gemu_log ("F_DUPFD," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,1 ); +break ; +case TARGET_F_GETFD : +gemu_log ("F_GETFD" ); +break ; +case TARGET_F_SETFD : +gemu_log ("F_SETFD," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,1 ); +break ; +case TARGET_F_GETFL : +gemu_log ("F_GETFL" ); +break ; +case TARGET_F_SETFL : +gemu_log ("F_SETFL," ); +print_open_flags (arg2,1 ); +break ; +case TARGET_F_GETLK : +gemu_log ("F_GETLK," ); +print_pointer (arg2,1 ); +break ; +case TARGET_F_SETLK : +gemu_log ("F_SETLK," ); +print_pointer (arg2,1 ); +break ; +case TARGET_F_SETLKW : +gemu_log ("F_SETLKW," ); +print_pointer (arg2,1 ); +break ; +case TARGET_F_GETOWN : +gemu_log ("F_GETOWN" ); +break ; +case TARGET_F_SETOWN : +gemu_log ("F_SETOWN," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,0 ); +break ; +case TARGET_F_GETSIG : +gemu_log ("F_GETSIG" ); +break ; +case TARGET_F_SETSIG : +gemu_log ("F_SETSIG," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,0 ); +break ; +#if TARGET_ABI_BITS ==32 +case TARGET_F_GETLK64 : +gemu_log ("F_GETLK64," ); +print_pointer (arg2,1 ); +break ; +case TARGET_F_SETLK64 : +gemu_log ("F_SETLK64," ); +print_pointer (arg2,1 ); +break ; +case TARGET_F_SETLKW64 : +gemu_log ("F_SETLKW64," ); +print_pointer (arg2,1 ); +break ; +#endif +case TARGET_F_SETLEASE : +gemu_log ("F_SETLEASE," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,0 ); +break ; +case TARGET_F_GETLEASE : +gemu_log ("F_GETLEASE" ); +break ; +case TARGET_F_DUPFD_CLOEXEC : +gemu_log ("F_DUPFD_CLOEXEC," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,1 ); +break ; +case TARGET_F_NOTIFY : +gemu_log ("F_NOTIFY," ); +print_raw_param (TARGET_ABI_FMT_ld, arg2,0 ); +break ; +default : +print_raw_param (TARGET_ABI_FMT_ld, arg1,0 ); +print_pointer (arg2,1 ); +break ; + }print_syscall_epilogue (name); }#define print_fcntl64 print_fcntl
Signature · 1 line
1.8.1.2
PATCH 3/7 linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex
In reply to [email protected]From: John Rigby <[email protected]>
Upstream libc has recently changed to start using FUTEX_WAIT_BITSET instead of FUTEX_WAIT and this is causing do_futex to return -TARGET_ENOSYS.
Pass bitset in val3 to sys_futex which will be ignored by kernel for the FUTEX_WAIT case.
--- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -1
@@ -4922,6 +4922,7 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,#endif switch (base_op) {case FUTEX_WAIT : +case FUTEX_WAIT_BITSET :if (timeout) { pts = &ts;target_to_host_timespec (pts, timeout);
@@ -4929,7 +4930,7 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, pts =NULL ; }return get_errno (sys_futex (g2h (uaddr), op,tswap32 (val), - pts,NULL ,0 )); + pts,NULL , val3));case FUTEX_WAKE :return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,NULL ,0 ));case FUTEX_FD :
Signature · 1 line
1.8.1.2
PATCH 4/7 linux-user: fix futex strace of FUTEX_CLOCK_REALTIME
In reply to [email protected]From: John Rigby <[email protected]>
Handle same as existing FUTEX_PRIVATE_FLAG.
--- linux-user/strace.c | 6 ++++++ 1 file changed, 6 insertions(+)
linux-user/strace.c +6 -0
@@ -1498,6 +1498,12 @@ if( cmd == val ) { \ cmd &= ~FUTEX_PRIVATE_FLAG ; }#endif +#ifdef FUTEX_CLOCK_REALTIME +if (cmd &FUTEX_CLOCK_REALTIME ) { +gemu_log ("FUTEX_CLOCK_REALTIME|" ); + cmd &= ~FUTEX_CLOCK_REALTIME ; + } +#endif print_op(FUTEX_WAIT) print_op(FUTEX_WAKE) print_op(FUTEX_FD)
Signature · 1 line
1.8.1.2
PATCH 5/7 linux-user: correct semctl() and shmctl()
In reply to [email protected]From: Laurent Vivier <[email protected]>
The parameter "union semun" of semctl() is not a value but a pointer to the value.
Moreover, all fields of target_su must be swapped (if needed).
The third argument of shmctl is a pointer.
WITHOUT this patch:
$ ipcs
kernel not configured for shared memory
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
WITH this patch:
$ ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status 0x4e545030 0 root 600 96 1 0x4e545031 32769 root 600 96 1 0x4e545032 65538 root 666 96 1 0x4e545033 98307 root 666 96 1 0x47505344 131076 root 666 8240 1 0x3c81b7f5 163845 laurent 666 4096 0 0x00000000 729513990 laurent 600 393216 2 dest 0x00000000 729546759 laurent 600 393216 2 dest
0x00000000 1879179273 laurent 600 393216 2 dest
------ Semaphore Arrays --------
key semid owner perms nsems 0x3c81b7f6 32768 laurent 666 1 0x1c44ac47 6586369 laurent 600 1
------ Message Queues --------
key msqid owner perms used-bytes messages 0x1c44ac45 458752 laurent 600 0 0 0x1c44ac46 491521 laurent 600 0 0
--- linux-user/syscall.c | 56 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 21 deletions(-)
linux-user/syscall.c +35 -21
@@ -2652,8 +2652,9 @@ static inline abi_long host_to_target_semarray(int semid, abi_ulong target_addr, }static inline abi_long do_semctl (int semid,int semnum,int cmd, -union target_semun target_su) +abi_ulong ptr) { +union target_semun *target_su;union semun arg;struct semid_ds dsarg;unsigned short *array =NULL ;
@@ -2662,43 +2663,55 @@ static inline abi_long do_semctl(int semid, int semnum, int cmd,abi_long err; cmd &=0xff ; +if (!lock_user_struct (VERIFY_READ , target_su, ptr,1 )) { +return -TARGET_EFAULT ; + }switch ( cmd ) {case GETVAL :case SETVAL : - arg.val =tswap32 (target_su.val); + arg.val =tswap32 (target_su->val); ret =get_errno (semctl (semid, semnum, cmd, arg)); - target_su.val =tswap32 (arg.val); + target_su->val =tswap32 (arg.val);break ;case GETALL :case SETALL : - err =target_to_host_semarray (semid, &array, target_su.array); -if (err) -return err; + err =target_to_host_semarray (semid, &array, +tswapal (target_su->array)); +if (err) { + ret = err; +break ; + } arg.array = array; ret =get_errno (semctl (semid, semnum, cmd, arg)); - err =host_to_target_semarray (semid, target_su.array, &array); -if (err) -return err; + err =host_to_target_semarray (semid,tswapal (target_su->array), + &array); +if (err) { + ret = err; + }break ;case IPC_STAT :case IPC_SET :case SEM_STAT : - err =target_to_host_semid_ds (&dsarg, target_su.buf); -if (err) -return err; + err =target_to_host_semid_ds (&dsarg,tswapal (target_su->buf)); +if (err) { + ret = err; +break ; + } arg.buf = &dsarg; ret =get_errno (semctl (semid, semnum, cmd, arg)); - err =host_to_target_semid_ds (target_su.buf, &dsarg); -if (err) -return err; + err =host_to_target_semid_ds (tswapal (target_su->buf), &dsarg); +if (err) { + ret = err; + }break ;case IPC_INFO :case SEM_INFO : arg.__buf = &seminfo; ret =get_errno (semctl (semid, semnum, cmd, arg)); - err =host_to_target_seminfo (target_su.__buf, &seminfo); -if (err) -return err; + err =host_to_target_seminfo (tswapal (target_su->__buf), &seminfo); +if (err) { + ret = err; + }break ;case IPC_RMID :case GETPID :
@@ -2707,6 +2720,7 @@ static inline abi_long do_semctl(int semid, int semnum, int cmd, ret =get_errno (semctl (semid, semnum, cmd,NULL ));break ; } +unlock_user_struct (target_su, ptr,0 );return ret; }
@@ -3177,7 +3191,7 @@ static abi_long do_ipc(unsigned int call, int first,break ;case IPCOP_semctl: - ret =do_semctl (first, second, third, (union target_semun )(abi_ulong ) ptr); + ret =do_semctl (first, second, third, ptr);break ;case IPCOP_msgget:
@@ -3244,7 +3258,7 @@ static abi_long do_ipc(unsigned int call, int first,/* IPC_* and SHM_* command values are the same on all linux platforms */ case IPCOP_shmctl: - ret =do_shmctl (first, second, third); + ret =do_shmctl (first, second, ptr);break ;default :gemu_log ("Unsupported ipc call: %d (version %d)\n" , call, version);
@@ -6936,7 +6950,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_semctlcase TARGET_NR_semctl: - ret =do_semctl (arg1, arg2, arg3, (union target_semun )(abi_ulong )arg4); + ret =do_semctl (arg1, arg2, arg3, arg4);break ;#endif #ifdef TARGET_NR_msgctl
Signature · 1 line
1.8.1.2
PATCH 6/7 linux-user: Support setgroups syscall with no groups
In reply to [email protected]From: Dillon Amburgey <[email protected]>
--- linux-user/syscall.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
linux-user/syscall.c +12 -10
@@ -7694,18 +7694,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, {int gidsetsize = arg1;target_id *target_grouplist; -gid_t *grouplist; +gid_t *grouplist =NULL ;int i; - - grouplist =alloca (gidsetsize *sizeof (gid_t)); - target_grouplist =lock_user (VERIFY_READ , arg2, gidsetsize *2 ,1 ); -if (!target_grouplist) { - ret = -TARGET_EFAULT ; - goto fail; +if (gidsetsize) { + grouplist =alloca (gidsetsize *sizeof (gid_t)); + target_grouplist =lock_user (VERIFY_READ , arg2, gidsetsize *2 ,1 ); +if (!target_grouplist) { + ret = -TARGET_EFAULT ; + goto fail; + } +for (i =0 ; i < gidsetsize; i++) { + grouplist[i] =low2highgid (tswapid (target_grouplist[i])); + } +unlock_user (target_grouplist, arg2,0 ); } -for (i =0 ;i < gidsetsize; i++) - grouplist[i] =low2highgid (tswapid (target_grouplist[i])); -unlock_user (target_grouplist, arg2,0 ); ret =get_errno (setgroups (gidsetsize, grouplist)); }break ;
Signature · 1 line
1.8.1.2
PATCH 7/7 linux-user: Add more sparc syscall numbers
In reply to [email protected]From: Dillon Amburgey <[email protected]>
--- linux-user/sparc/syscall_nr.h | 2 ++ 1 file changed, 2 insertions(+)
linux-user/sparc/syscall_nr.h +2 -0
@@ -200,6 +200,8 @@#define TARGET_NR__newselect 230/* Linux Specific */ #define TARGET_NR_time 231/* Linux Specific */ #define TARGET_NR_stime 233/* Linux Specific */ +#define TARGET_NR_statfs64 234/* Linux Specific */ +#define TARGET_NR_fstatfs64 235/* Linux Specific */ #define TARGET_NR__llseek 236/* Linux Specific */ #define TARGET_NR_mlock 237#define TARGET_NR_munlock 238
Signature · 1 line
1.8.1.2
Quoted 5 lines · On 7 March 2013 18:21, <[email protected]> wrote:
I did a dig through the archive for linux-user patches that have slipped through during my inactivity. The ones in this patchset appear good and pass smoketest.
linux-user: correct
semctl()andshmctl()
This one's not correct, I'm afraid -- see my comments on the list on the last version Laurent posted. The patch as it stands breaks x86 at least and needs more work before it can go in.
http://lists.gnu.org/archive/html/qemu-devel/2013-02/msg00447.html
thanks
-- PMM
Quoted 4 lines · On 7 March 2013 18:21, <[email protected]> wrote:
From: Riku Voipio <[email protected]>
I did a dig through the archive for linux-user patches that have slipped through during my inactivity. The ones in this patchset appear good and pass smoketest.
These are the linux-user patches I've submitted that are still waiting for review/commit:
linux-user: Fix layout of usage table to account for option text
http://patchwork.ozlabs.org/patch/220481/
linux-user: make bogus negative iovec lengths fail EINVAL
http://patchwork.ozlabs.org/patch/219240/
linux-user: Implement sendfile and sendfile64
http://patchwork.ozlabs.org/patch/219229/
linux-user: Implement accept4
http://patchwork.ozlabs.org/patch/219160/linux-user/syscall.c: Don't warn about unimplemented get_robust_list
http://patchwork.ozlabs.org/patch/219159/
thanks
-- PMM
Hi Peter,
Quoted 10 lines · Peter Maydell
linux-user: Fix layout of usage table to account for option text
http://patchwork.ozlabs.org/patch/220481/
linux-user: make bogus negative iovec lengths fail EINVAL
http://patchwork.ozlabs.org/patch/219240/
linux-user: Implement sendfile and sendfile64
http://patchwork.ozlabs.org/patch/219229/
linux-user: Implement accept4
http://patchwork.ozlabs.org/patch/219160/linux-user/syscall.c: Don't warn about unimplementedget_robust_list
http://patchwork.ozlabs.org/patch/219159/
I've added these (and removed the semctl one) to the patchset I'm testing:
Riku