linux-user: pending patches
cover linux-user: pending patches
Apart from the last patch, all patches have been seen on the list. If no problems are found in reviews, I'll send these as the next pull request.
Changes can also be pulled by git from:
git://gitorious.org/qemu-maemo/qemu.git linux-user-for-upstream
notice that linux-user git will move soon to some other location.
Alexander Graf (1):
linux-user: add s390x to llseek list
Laurent Vivier (3):
linux-user: improve traces
linux-user: convert ioctl(SIOCGIFCONF, ...) result.
linux-user: add ioctl(SIOCGIWNAME, ...) support.
Riku Voipio (2):
[v2] linux-user: bigger default stack
linux-user: untie syscalls from UID16
linux-user/alpha/syscall_nr.h | 7 -- linux-user/ioctls.h | 4 +- linux-user/strace.c | 161 +++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 12 ++-- linux-user/syscall.c | 154 +++++++++++++++++++++++++++++++++++---- linux-user/syscall_defs.h | 8 ++- 6 files changed, 315 insertions(+), 31 deletions(-)
PATCH 2/6 linux-user: improve traces
From: Laurent Vivier <[email protected]>
Add trace details for getpid(), kill(), _llseek(), rt_sigaction(), rt_sigprocmask(), clone().
--- linux-user/strace.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 12 ++-- 2 files changed, 167 insertions(+), 6 deletions(-)
linux-user/strace.c +161 -0
@@ -9,6 +9,7 @@#include <sys/mount.h> #include <sys/mman.h> #include <unistd.h> +#include <sched.h> #include "qemu.h" int do_strace=0 ;
@@ -63,6 +64,7 @@ UNUSED static void print_string(abi_long, int); UNUSED static void print_raw_param(const char *, abi_long, int); UNUSED static void print_timeval(abi_ulong, int); UNUSED static void print_number(abi_long, int); +UNUSED static void print_signal(abi_ulong, int);/* * Utility functions
@@ -117,6 +119,37 @@ if( cmd == val ) { \gemu_log ("%d" ,cmd); } +static void +print_signal (abi_ulong arg,int last) +{ +const char *signal_name =NULL ; +switch (arg) { +case TARGET_SIGHUP : signal_name ="SIGHUP" ;break ; +case TARGET_SIGINT : signal_name ="SIGINT" ;break ; +case TARGET_SIGQUIT : signal_name ="SIGQUIT" ;break ; +case TARGET_SIGILL : signal_name ="SIGILL" ;break ; +case TARGET_SIGABRT : signal_name ="SIGABRT" ;break ; +case TARGET_SIGFPE : signal_name ="SIGFPE" ;break ; +case TARGET_SIGKILL : signal_name ="SIGKILL" ;break ; +case TARGET_SIGSEGV : signal_name ="SIGSEGV" ;break ; +case TARGET_SIGPIPE : signal_name ="SIGPIPE" ;break ; +case TARGET_SIGALRM : signal_name ="SIGALRM" ;break ; +case TARGET_SIGTERM : signal_name ="SIGTERM" ;break ; +case TARGET_SIGUSR1 : signal_name ="SIGUSR1" ;break ; +case TARGET_SIGUSR2 : signal_name ="SIGUSR2" ;break ; +case TARGET_SIGCHLD : signal_name ="SIGCHLD" ;break ; +case TARGET_SIGCONT : signal_name ="SIGCONT" ;break ; +case TARGET_SIGSTOP : signal_name ="SIGSTOP" ;break ; +case TARGET_SIGTTIN : signal_name ="SIGTTIN" ;break ; +case TARGET_SIGTTOU : signal_name ="SIGTTOU" ;break ; + } +if (signal_name ==NULL ) { +print_raw_param ("%ld" , arg,1 ); +return ; + } +gemu_log ("%s%s" , signal_name,get_comma (last)); +} +#ifdef TARGET_NR__newselectstatic void print_fdset (int n,abi_ulong target_fds_addr)
@@ -427,6 +460,32 @@ UNUSED static struct flags fcntl_flags[] = { FLAG_END, }; +UNUSED static struct flags clone_flags[] = { +FLAG_GENERIC (CLONE_VM ), +FLAG_GENERIC (CLONE_FS ), +FLAG_GENERIC (CLONE_FILES ), +FLAG_GENERIC (CLONE_SIGHAND ), +FLAG_GENERIC (CLONE_PTRACE ), +FLAG_GENERIC (CLONE_VFORK ), +FLAG_GENERIC (CLONE_PARENT ), +FLAG_GENERIC (CLONE_THREAD ), +FLAG_GENERIC (CLONE_NEWNS ), +FLAG_GENERIC (CLONE_SYSVSEM ), +FLAG_GENERIC (CLONE_SETTLS ), +FLAG_GENERIC (CLONE_PARENT_SETTID ), +FLAG_GENERIC (CLONE_CHILD_CLEARTID ), +FLAG_GENERIC (CLONE_DETACHED ), +FLAG_GENERIC (CLONE_UNTRACED ), +FLAG_GENERIC (CLONE_CHILD_SETTID ), +FLAG_GENERIC (CLONE_NEWUTS ), +FLAG_GENERIC (CLONE_NEWIPC ), +FLAG_GENERIC (CLONE_NEWUSER ), +FLAG_GENERIC (CLONE_NEWPID ), +FLAG_GENERIC (CLONE_NEWNET ), +FLAG_GENERIC (CLONE_IO ), +FLAG_END , +}; +/* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter
@@ -669,6 +728,39 @@ print_chmod(const struct syscallname *name, }#endif +#ifdef TARGET_NR_clone +static void +print_clone (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); +#if defined(TARGET_M68K ) +print_flags (clone_flags, arg0,0 ); +print_raw_param ("newsp=0x" TARGET_ABI_FMT_lx, arg1,1 ); +#elif defined(TARGET_SH4 ) || defined(TARGET_ALPHA ) +print_flags (clone_flags, arg0,0 ); +print_raw_param ("child_stack=0x" TARGET_ABI_FMT_lx, arg1,0 ); +print_raw_param ("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2,0 ); +print_raw_param ("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3,0 ); +print_raw_param ("tls=0x" TARGET_ABI_FMT_lx, arg4,1 ); +#elif defined(TARGET_CRIS ) +print_raw_param ("child_stack=0x" TARGET_ABI_FMT_lx, arg0,0 ); +print_flags (clone_flags, arg1,0 ); +print_raw_param ("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2,0 ); +print_raw_param ("tls=0x" TARGET_ABI_FMT_lx, arg3,0 ); +print_raw_param ("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4,1 ); +#else +print_flags (clone_flags, arg0,0 ); +print_raw_param ("child_stack=0x" TARGET_ABI_FMT_lx, arg1,0 ); +print_raw_param ("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2,0 ); +print_raw_param ("tls=0x" TARGET_ABI_FMT_lx, arg3,0 ); +print_raw_param ("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4,1 ); +#endif +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_creat static void print_creat(const struct syscallname *name,
@@ -805,6 +897,28 @@ print_linkat(const struct syscallname *name, }#endif +#ifdef TARGET_NR__llseek +static void +print__llseek (const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +const char *whence ="UNKNOWN" ; +print_syscall_prologue (name); +print_raw_param ("%d" , arg0,0 ); +print_raw_param ("%ld" , arg1,0 ); +print_raw_param ("%ld" , arg2,0 ); +print_pointer (arg3,0 ); +switch (arg4) { +case SEEK_SET : whence ="SEEK_SET" ;break ; +case SEEK_CUR : whence ="SEEK_CUR" ;break ; +case SEEK_END : whence ="SEEK_END" ;break ; + } +gemu_log ("%s" ,whence); +print_syscall_epilogue (name); +} +#endif +#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) static void
@@ -875,6 +989,40 @@ print_rmdir(const struct syscallname *name, }#endif +#ifdef TARGET_NR_rt_sigaction +static void +print_rt_sigaction (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_signal (arg0,0 ); +print_pointer (arg1,0 ); +print_pointer (arg2,1 ); +print_syscall_epilogue (name); +} +#endif + +#ifdef TARGET_NR_rt_sigprocmask +static void +print_rt_sigprocmask (const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +const char *how ="UNKNOWN" ; +print_syscall_prologue (name); +switch (arg0) { +case TARGET_SIG_BLOCK : how ="SIG_BLOCK" ;break ; +case TARGET_SIG_UNBLOCK : how ="SIG_UNBLOCK" ;break ; +case TARGET_SIG_SETMASK : how ="SIG_SETMASK" ;break ; + } +gemu_log ("%s," ,how); +print_pointer (arg1,0 ); +print_pointer (arg2,1 ); +print_syscall_epilogue (name); +} +#endif +#ifdef TARGET_NR_mknod static void print_mknod(const struct syscallname *name,
@@ -1298,6 +1446,19 @@ print_futex(const struct syscallname *name, }#endif +#ifdef TARGET_NR_kill +static void +print_kill (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_signal (arg1,1 ); +print_syscall_epilogue (name); +} +#endif +/* * An array of all of the syscalls we know about */
linux-user/strace.list +6 -6
@@ -85,7 +85,7 @@ { TARGET_NR_clock_settime, "clock_settime" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_clone -{ TARGET_NR_clone, "clone" , NULL, NULL, NULL }, +{ TARGET_NR_clone, "clone" , NULL, print_clone, NULL }, #endif #ifdef TARGET_NR_close { TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
@@ -292,7 +292,7 @@ { TARGET_NR_getpgrp, "getpgrp" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_getpid -{ TARGET_NR_getpid, "getpid" , NULL, NULL, NULL }, +{ TARGET_NR_getpid, "getpid" , "%s()", NULL, NULL }, #endif #ifdef TARGET_NR_getpmsg { TARGET_NR_getpmsg, "getpmsg" , NULL, NULL, NULL },
@@ -418,7 +418,7 @@ { TARGET_NR_keyctl, "keyctl" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_kill -{ TARGET_NR_kill, "kill" , NULL, NULL, NULL }, +{ TARGET_NR_kill, "kill", NULL, print_kill, NULL }, #endif #ifdef TARGET_NR_lchown { TARGET_NR_lchown, "lchown" , NULL, NULL, NULL },
@@ -448,7 +448,7 @@ { TARGET_NR_llistxattr, "llistxattr" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR__llseek -{ TARGET_NR__llseek, "_llseek" , NULL, NULL, NULL }, +{ TARGET_NR__llseek, "_llseek" , NULL, print__llseek, NULL }, #endif #ifdef TARGET_NR_lock { TARGET_NR_lock, "lock" , NULL, NULL, NULL },
@@ -1063,13 +1063,13 @@ { TARGET_NR_rmdir, "rmdir" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_rt_sigaction -{ TARGET_NR_rt_sigaction, "rt_sigaction" , NULL, NULL, NULL }, +{ TARGET_NR_rt_sigaction, "rt_sigaction" , NULL, print_rt_sigaction, NULL }, #endif #ifdef TARGET_NR_rt_sigpending { TARGET_NR_rt_sigpending, "rt_sigpending" , NULL, NULL, NULL }, #endif #ifdef TARGET_NR_rt_sigprocmask -{ TARGET_NR_rt_sigprocmask, "rt_sigprocmask" , NULL, NULL, NULL }, +{ TARGET_NR_rt_sigprocmask, "rt_sigprocmask" , NULL, print_rt_sigprocmask, NULL }, #endif #ifdef TARGET_NR_rt_sigqueueinfo { TARGET_NR_rt_sigqueueinfo, "rt_sigqueueinfo" , NULL, NULL, NULL },
Signature · 1 line
1.7.1
PATCH v2 1/6 linux-user: bigger default stack
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
PTHREAD_STACK_MIN (16KB) is somewhat inadequate for a new stack for new QEMU threads. Set new limit to 256K which should be enough, yet doesn't increase memory pressure significantly.
--- linux-user/syscall.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
linux-user/syscall.c +2 -5
@@ -3690,9 +3690,9 @@ static abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)#endif /* defined(TARGET_I386) */ -#if defined(CONFIG_USE_NPTL) +#define NEW_STACK_SIZE 0x40000 -#define NEW_STACK_SIZE PTHREAD_STACK_MIN +#if defined(CONFIG_USE_NPTL) static pthread_mutex_t clone_lock = PTHREAD_MUTEX_INITIALIZER; typedef struct {
@@ -3736,9 +3736,6 @@ static void *clone_func(void *arg) return NULL; }#else -/* this stack is the equivalent of the kernel stack associated with a -thread/process */ -#define NEW_STACK_SIZE 8192static int clone_func (void *arg) {
Signature · 1 line
1.7.1
PATCH 3/6 linux-user: convert ioctl(SIOCGIFCONF, ...) result.
In reply to Riku VoipioFrom: Laurent Vivier <[email protected]>
The result needs to be converted as it is stored in an array of struct ifreq and sizeof(struct ifreq) differs according to target and host alignment rules.
This patch allows to execute correctly the following program on arm and m68k:
#include <stdio.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <alloca.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(void)
{
int s, ret;
struct ifconf ifc;
int i;
memset( &ifc, 0, sizeof( struct ifconf ) );
ifc.ifc_len = 8 * sizeof(struct ifreq);
ifc.ifc_buf = alloca(ifc.ifc_len);
s = socket( AF_INET, SOCK_DGRAM, 0 );
if (s < 0) {
perror("Cannot open socket");
return 1;
}
ret = ioctl( s, SIOCGIFCONF, &ifc );
if (s < 0) {
perror("ioctl() failed");
return 1;
}
for (i = 0; i < ifc.ifc_len / sizeof(struct ifreq) ; i ++) {
struct sockaddr_in *s;
s = (struct sockaddr_in*)&ifc.ifc_req[i].ifr_addr;
printf("%s\n", ifc.ifc_req[i].ifr_name);
printf("%s\n", inet_ntoa(s->sin_addr));
}
}--- linux-user/ioctls.h | 3 +- linux-user/syscall.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 97 insertions(+), 2 deletions(-)
linux-user/ioctls.h +2 -1
@@ -112,7 +112,8 @@ IOCTL(SIOCADDMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq))) IOCTL(SIOCDELMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq))) IOCTL(SIOCSIFLINK, 0, TYPE_NULL) - IOCTL(SIOCGIFCONF, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifconf))) +IOCTL_SPECIAL (SIOCGIFCONF ,IOC_W |IOC_R , do_ioctl_ifconf, + MK_PTR(MK_STRUCT(STRUCT_ifconf))) IOCTL(SIOCGIFENCAP, IOC_RW, MK_PTR(TYPE_INT)) IOCTL(SIOCSIFENCAP, IOC_W, MK_PTR(TYPE_INT))IOCTL (SIOCDARP ,IOC_W ,MK_PTR (MK_STRUCT (STRUCT_arpreq)))
linux-user/syscall.c +95 -1
114 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 4/6 linux-user: add ioctl(SIOCGIWNAME, ...) support.
In reply to Riku VoipioFrom: Laurent Vivier <[email protected]>
Allow to run properly following program from linux-user:
/* cc -o wifi wifi.c */
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/wireless.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
int main(int argc, char **argv)
{
int ret;
struct ifreq req;
struct sockaddr_in *addr;
int s;
if (argc != 2) {
fprintf(stderr, "Need an interface name (like wlan0)\n");
return 1;
}
s = socket( AF_INET, SOCK_DGRAM, 0 );
if (s < 0) {
perror("Cannot open socket");
return 1;
}
strncpy(req.ifr_name, argv[1], sizeof(req.ifr_name));
ret = ioctl( s, SIOCGIWNAME, &req );
if (ret < 0) {
fprintf(stderr, "No wireless extension\n");
return 1;
}
printf("%s\n", req.ifr_name);
printf("%s\n", req.ifr_newname);
return 0;
}$ ./wifi eth0 No wireless extension
$ ./wifi wlan0 wlan0 IEEE 802.11bg
--- linux-user/ioctls.h | 1 + linux-user/syscall.c | 2 +- linux-user/syscall_defs.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletions(-)
linux-user/ioctls.h +1 -0
@@ -122,6 +122,7 @@ IOCTL(SIOCDRARP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_arpreq))) IOCTL(SIOCSRARP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_arpreq))) IOCTL(SIOCGRARP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_arpreq))) + IOCTL(SIOCGIWNAME, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_char_ifreq))) IOCTL(CDROMPAUSE, 0, TYPE_NULL)IOCTL (CDROMSTART ,0 ,TYPE_NULL )
linux-user/syscall.c +1 -1
@@ -59,7 +59,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,//#include <sys/user.h> #include <netinet/ip.h> #include <netinet/tcp.h> -#include <net/if.h> +#include <linux/wireless.h> #include <qemu-common.h> #ifdef TARGET_GPROF #include <sys/gmon.h>
linux-user/syscall_defs.h +3 -0
@@ -765,6 +765,9 @@ struct target_pollfd {#define TARGET_SIOCADDDLCI 0x8980/* Create new DLCI device */ #define TARGET_SIOCDELDLCI 0x8981/* Delete DLCI device */ +/* From <linux/wireless.h> */ + +#define TARGET_SIOCGIWNAME 0x8B01/* get name == wireless protocol */ /* From <linux/fs.h> */
Signature · 1 line
1.7.1
PATCH 5/6 linux-user: add s390x to llseek list
In reply to Riku VoipioFrom: Alexander Graf <[email protected]>
We keep a list of host architectures that do llseek with the same syscall as lseek. S390x is one of them, so let's add it to the list.
--- linux-user/syscall.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
linux-user/syscall.c +2 -1
@@ -197,7 +197,8 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \#define __NR_sys_inotify_add_watch __NR_inotify_add_watch#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch -#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) +#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) || \ + defined(__s390x__)#define __NR__llseek __NR_lseek#endif
Signature · 1 line
1.7.1
PATCH 6/6 linux-user: untie syscalls from UID16
In reply to Riku VoipioQuite a number of uid/gid related syscalls are only defined on systems with USE_UID16 defined. This is apperently based on the idea that these system calls would never be called on non-UID16 systems. Make these syscalls available for all architectures that define them.
drop alpha hack to support selected UID16 syscalls. MIPS and PowerPC were also defined as UID16, to get uid/gid syscalls available, drop this error as well.
Change QEMU to reflect this.
--- linux-user/alpha/syscall_nr.h | 7 ------ linux-user/syscall.c | 48 +++++++++++++++++++++++++++++++++------- linux-user/syscall_defs.h | 5 +++- 3 files changed, 43 insertions(+), 17 deletions(-)
linux-user/alpha/syscall_nr.h +0 -7
@@ -412,10 +412,3 @@#define TARGET_NR_timerfd 477#define TARGET_NR_eventfd 478 -/* The following aliases are defined in order to match up with the -standard i386 syscalls implemented in syscalls.c. */ -#define TARGET_NR_chown32 TARGET_NR_chown -#define TARGET_NR_setuid32 TARGET_NR_setuid -#define TARGET_NR_setgid32 TARGET_NR_setgid -#define TARGET_NR_setfsuid32 TARGET_NR_setfsuid -#define TARGET_NR_setfsgid32 TARGET_NR_setfsgid
linux-user/syscall.c +39 -9
120 lines not on this page · raw message
linux-user/syscall_defs.h +4 -1
@@ -49,9 +49,12 @@#define TARGET_IOC_TYPEBITS 8#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_SPARC ) \ - || defined(TARGET_M68K ) || defined(TARGET_SH4 ) || defined(TARGET_CRIS ) || defined(TARGET_PPC ) || defined(TARGET_MIPS ) + || defined(TARGET_M68K ) || defined(TARGET_SH4 ) || defined(TARGET_CRIS )/* 16 bit uid wrappers emulation */ #define USE_UID16 +#define target_id uint16_t +#else +#define target_id uint32_t#endif #if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_SH4 ) \
Signature · 1 line
1.7.1