Pending linux-user patches
cover Pending linux-user patches
From: Riku Voipio <[email protected]>
All the things in linux-user tree at the moment:
https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream
Since the maemo git hosting regrettably only provides https transport, you can download the git tree faster if you already have a git tree:
git clone git://git.sv.gnu.org/qemu.git
cd qemu
git remote add maemo https://git.maemo.org/projects/qemu
git fetch maemo
git checkout -b linux-user maemo/linux-user-for-upstream
This tree is constantly rebased against upstream git HEAD, so avoid basing your work on this branch.
Arnaud Patard (2):
Fix struct termios host - target translation Return EOPNOTSUPP instead of ENOSYS for *xattr* syscalls
Arnaud Patard (Rtp) (1):
RFC: fix fcntl support in linux-user - new try
Eduardo Habkost (1):
linux-user/syscall.c: define _ATFILE_SOURCE
Laurent Vivier (1):
linux-user: remove duplicate tswap32() from do_getsockopt()
Lionel Landwerlin (2):
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to
setsockopt
linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP
flags to setsockopt
Martin Mohring (2):
linux-user: include linux/fs.h
linux-user: support private futexes
Mika Westerberg (4):
linux-user: implemented ELF coredump support for ARM target
linux-user: added x86 and x86_64 support for ELF coredump
linux-user: strace now handles guest strings correctly [v2] Revived GUEST_BASE support for usermode emulation targets [v5]
Nathan Froyd (1):
linux-user: initialize mmap_mutex properly
Riku Voipio (6):
export mmap_find_vma for shmat
Implement shm* syscalls and fix 64/32bit errors
linux-user: fix utimensat
add futex wake op
linux-user: update syscall list
linux-user: implement pipe2 [v3]
vibisreenivasan (1):
linux-user: add tee, splice and vmsplice
configure | 75 +++ cpu-all.h | 9 +- elf.h | 19 +- exec.c | 69 ++- linux-user/arm/syscall_nr.h | 9 + linux-user/elfload.c | 1033 +++++++++++++++++++++++++++++++++++++- linux-user/i386/syscall_nr.h | 8 + linux-user/linuxload.c | 50 +- linux-user/m68k/syscall_nr.h | 8 + linux-user/main.c | 101 ++++- linux-user/mips/syscall_nr.h | 9 + linux-user/mips64/syscall_nr.h | 9 + linux-user/mipsn32/syscall_nr.h | 9 + linux-user/mmap.c | 4 +- linux-user/ppc/syscall_nr.h | 9 + linux-user/qemu.h | 17 +- linux-user/sh4/syscall_nr.h | 8 + linux-user/signal.c | 40 ++- linux-user/sparc/syscall_nr.h | 9 + linux-user/sparc64/syscall_nr.h | 9 + linux-user/strace.c | 1072 ++++++++++++++++++++++++++++++++++++++- linux-user/strace.list | 111 +++-- linux-user/syscall.c | 595 +++++++++++++++++----- linux-user/syscall_defs.h | 41 ++- linux-user/x86_64/syscall_nr.h | 9 + tcg/i386/tcg-target.c | 36 +- tcg/x86_64/tcg-target.c | 30 +- 27 files changed, 3110 insertions(+), 288 deletions(-)
PATCH 1/21 export mmap_find_vma for shmat
From: Riku Voipio <[email protected]>
--- linux-user/mmap.c | 2 +- linux-user/qemu.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)
linux-user/mmap.c +1 -1
@@ -281,7 +281,7 @@ unsigned long last_brk;*/ /* page_init() marks pages used by the host as reserved to be sure not to use them. */ -static abi_ulong mmap_find_vma (abi_ulong start,abi_ulong size) +abi_ulong mmap_find_vma (abi_ulong start,abi_ulong size) {abi_ulong addr, addr1, addr_start;int prot;
linux-user/qemu.h +1 -0
@@ -229,6 +229,7 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);extern unsigned long last_brk;void mmap_lock (void );void mmap_unlock (void ); +abi_ulong mmap_find_vma (abi_ulong ,abi_ulong );void cpu_list_lock (void );void cpu_list_unlock (void );#if defined(USE_NPTL )
Signature · 1 line
1.6.2.1
PATCH 2/21 Implement shm* syscalls and fix 64/32bit errors
In reply to [email protected]From: Riku Voipio <[email protected]>
Verified with ltp shm* tests. Following test still fails
shmt09 3 FAIL
No regressions were observed on either 64bit or 32bit IA hosts.
Patch based on original patches by:
Kirill A. Shutemov <[email protected]>
- Implement shm* syscalls
- Fix and cleanup IPCOP_shm* ipc calls handling
Depends on "Rewrite mmap_find_vma()" patch.
Various whitespace uglifications applied to minimize patch size.
--- linux-user/syscall.c | 299 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 250 insertions(+), 49 deletions(-)
linux-user/syscall.c +250 -49
@@ -1924,14 +1924,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr) }#endif -#ifdef TARGET_NR_ipc#define N_SHM_REGIONS 32static struct shm_region {abi_ulong start;abi_ulong size; } shm_regions[N_SHM_REGIONS ]; -#endif struct target_ipc_perm {
@@ -2424,6 +2422,224 @@ end:return ret; } +struct target_shmid_ds +{ +struct target_ipc_perm shm_perm; +abi_ulong shm_segsz; +abi_ulong shm_atime; +#if TARGET_ABI_BITS ==32 +abi_ulong __unused1; +#endif +abi_ulong shm_dtime; +#if TARGET_ABI_BITS ==32 +abi_ulong __unused2; +#endif +abi_ulong shm_ctime; +#if TARGET_ABI_BITS ==32 +abi_ulong __unused3; +#endif +int shm_cpid; +int shm_lpid; +abi_ulong shm_nattch; +unsigned long int __unused4; +unsigned long int __unused5; +}; + +static inline abi_long target_to_host_shmid_ds (struct shmid_ds *host_sd, +abi_ulong target_addr) +{ +struct target_shmid_ds *target_sd; + +if (!lock_user_struct (VERIFY_READ , target_sd, target_addr,1 )) +return -TARGET_EFAULT ; +if (target_to_host_ipc_perm (&(host_sd->shm_perm), target_addr)) +return -TARGET_EFAULT ; +__get_user (host_sd->shm_segsz, &target_sd->shm_segsz); +__get_user (host_sd->shm_atime, &target_sd->shm_atime); +__get_user (host_sd->shm_dtime, &target_sd->shm_dtime); +__get_user (host_sd->shm_ctime, &target_sd->shm_ctime); +__get_user (host_sd->shm_cpid, &target_sd->shm_cpid); +__get_user (host_sd->shm_lpid, &target_sd->shm_lpid); +__get_user (host_sd->shm_nattch, &target_sd->shm_nattch); +unlock_user_struct (target_sd, target_addr,0 ); +return 0 ; +} + +static inline abi_long host_to_target_shmid_ds (abi_ulong target_addr, +struct shmid_ds *host_sd) +{ +struct target_shmid_ds *target_sd; + +if (!lock_user_struct (VERIFY_WRITE , target_sd, target_addr,0 )) +return -TARGET_EFAULT ; +if (host_to_target_ipc_perm (target_addr, &(host_sd->shm_perm))) +return -TARGET_EFAULT ; +__put_user (host_sd->shm_segsz, &target_sd->shm_segsz); +__put_user (host_sd->shm_atime, &target_sd->shm_atime); +__put_user (host_sd->shm_dtime, &target_sd->shm_dtime); +__put_user (host_sd->shm_ctime, &target_sd->shm_ctime); +__put_user (host_sd->shm_cpid, &target_sd->shm_cpid); +__put_user (host_sd->shm_lpid, &target_sd->shm_lpid); +__put_user (host_sd->shm_nattch, &target_sd->shm_nattch); +unlock_user_struct (target_sd, target_addr,1 ); +return 0 ; +} + +struct target_shminfo { +abi_ulong shmmax; +abi_ulong shmmin; +abi_ulong shmmni; +abi_ulong shmseg; +abi_ulong shmall; +}; + +static inline abi_long host_to_target_shminfo (abi_ulong target_addr, +struct shminfo *host_shminfo) +{ +struct target_shminfo *target_shminfo; +if (!lock_user_struct (VERIFY_WRITE , target_shminfo, target_addr,0 )) +return -TARGET_EFAULT ; +__put_user (host_shminfo->shmmax, &target_shminfo->shmmax); +__put_user (host_shminfo->shmmin, &target_shminfo->shmmin); +__put_user (host_shminfo->shmmni, &target_shminfo->shmmni); +__put_user (host_shminfo->shmseg, &target_shminfo->shmseg); +__put_user (host_shminfo->shmall, &target_shminfo->shmall); +unlock_user_struct (target_shminfo, target_addr,1 ); +return 0 ; +} + +struct target_shm_info { +int used_ids; +abi_ulong shm_tot; +abi_ulong shm_rss; +abi_ulong shm_swp; +abi_ulong swap_attempts; +abi_ulong swap_successes; +}; + +static inline abi_long host_to_target_shm_info (abi_ulong target_addr, +struct shm_info *host_shm_info) +{ +struct target_shm_info *target_shm_info; +if (!lock_user_struct (VERIFY_WRITE , target_shm_info, target_addr,0 )) +return -TARGET_EFAULT ; +__put_user (host_shm_info->used_ids, &target_shm_info->used_ids); +__put_user (host_shm_info->shm_tot, &target_shm_info->shm_tot); +__put_user (host_shm_info->shm_rss, &target_shm_info->shm_rss); +__put_user (host_shm_info->shm_swp, &target_shm_info->shm_swp); +__put_user (host_shm_info->swap_attempts, &target_shm_info->swap_attempts); +__put_user (host_shm_info->swap_successes, &target_shm_info->swap_successes); +unlock_user_struct (target_shm_info, target_addr,1 ); +return 0 ; +} + +static inline abi_long do_shmctl (int shmid,int cmd,abi_long buf) +{ +struct shmid_ds dsarg; +struct shminfo shminfo; +struct shm_info shm_info; +abi_long ret = -TARGET_EINVAL ; + + cmd &=0xff ; + +switch (cmd) { +case IPC_STAT : +case IPC_SET : +case SHM_STAT : +if (target_to_host_shmid_ds (&dsarg, buf)) +return -TARGET_EFAULT ; + ret =get_errno (shmctl (shmid, cmd, &dsarg)); +if (host_to_target_shmid_ds (buf, &dsarg)) +return -TARGET_EFAULT ; +break ; +case IPC_INFO : + ret =get_errno (shmctl (shmid, cmd, (struct shmid_ds *)&shminfo)); +if (host_to_target_shminfo (buf, &shminfo)) +return -TARGET_EFAULT ; +break ; +case SHM_INFO : + ret =get_errno (shmctl (shmid, cmd, (struct shmid_ds *)&shm_info)); +if (host_to_target_shm_info (buf, &shm_info)) +return -TARGET_EFAULT ; +break ; +case IPC_RMID : +case SHM_LOCK : +case SHM_UNLOCK : + ret =get_errno (shmctl (shmid, cmd,NULL )); +break ; + } + +return ret; +} + +static inline abi_ulong do_shmat (int shmid,abi_ulong shmaddr,int shmflg) +{ +abi_long raddr; +void *host_raddr; +struct shmid_ds shm_info; +int i,ret; + +/* find out the length of the shared memory segment */ + ret =get_errno (shmctl (shmid,IPC_STAT , &shm_info)); +if (is_error (ret)) { +/* can't get length, bail out */ +return ret; + } + +mmap_lock (); + +if (shmaddr) + host_raddr =shmat (shmid, (void *)g2h (shmaddr), shmflg); +else { +abi_ulong mmap_start; + + mmap_start =mmap_find_vma (0 , shm_info.shm_segsz); + +if (mmap_start ==-1 ) { + errno =ENOMEM ; + host_raddr = (void *)-1 ; + }else + host_raddr =shmat (shmid,g2h (mmap_start), shmflg |SHM_REMAP ); + } + +if (host_raddr == (void *)-1 ) { +mmap_unlock (); +return get_errno ((long )host_raddr); + } + raddr=h2g ((unsigned long )host_raddr); + +page_set_flags (raddr, raddr + shm_info.shm_segsz, +PAGE_VALID |PAGE_READ | + ((shmflg &SHM_RDONLY )?0 :PAGE_WRITE )); + +for (i =0 ; i <N_SHM_REGIONS ; i++) { +if (shm_regions[i].start ==0 ) { + shm_regions[i].start = raddr; + shm_regions[i].size = shm_info.shm_segsz; +break ; + } + } + +mmap_unlock (); +return raddr; + +} + +static inline abi_long do_shmdt (abi_ulong shmaddr) +{ +int i; + +for (i =0 ; i <N_SHM_REGIONS ; ++i) { +if (shm_regions[i].start == shmaddr) { + shm_regions[i].start =0 ; +page_set_flags (shmaddr, shm_regions[i].size,0 ); +break ; + } + } + +return get_errno (shmdt (g2h (shmaddr))); +} +#ifdef TARGET_NR_ipc/* ??? This only works with linear mappings. */ /* do_ipc() must return target values and target errnos. */
@@ -2433,8 +2649,6 @@ static abi_long do_ipc(unsigned int call, int first, {int version;abi_long ret =0 ; -struct shmid_ds shm_info; -int i; version = call >>16 ; call &=0xffff ;
@@ -2489,48 +2703,24 @@ static abi_long do_ipc(unsigned int call, int first,break ;case IPCOP_shmat: +switch (version) { +default : {abi_ulong raddr; -void *host_addr; -/* SHM_* flags are the same on all linux platforms */ - host_addr =shmat (first, (void *)g2h (ptr), second); -if (host_addr == (void *)-1 ) { - ret =get_errno ((long )host_addr); -break ; - } - raddr =h2g ((unsigned long )host_addr); -/* find out the length of the shared memory segment */ - - ret =get_errno (shmctl (first,IPC_STAT , &shm_info)); -if (is_error (ret)) { -/* can't get length, bail out */ -shmdt (host_addr); -break ; - } -page_set_flags (raddr, raddr + shm_info.shm_segsz, -PAGE_VALID |PAGE_READ | - ((second &SHM_RDONLY )?0 :PAGE_WRITE )); -for (i =0 ; i <N_SHM_REGIONS ; ++i) { -if (shm_regions[i].start ==0 ) { - shm_regions[i].start = raddr; - shm_regions[i].size = shm_info.shm_segsz; -break ; - } - } + raddr =do_shmat (first, ptr, second); +if (is_error (raddr)) +return get_errno (raddr);if (put_user_ual (raddr, third))return -TARGET_EFAULT ; - ret =0 ; +break ; + } +case 1 : + ret = -TARGET_EINVAL ; +break ; }break ;case IPCOP_shmdt: -for (i =0 ; i <N_SHM_REGIONS ; ++i) { -if (shm_regions[i].start == ptr) { - shm_regions[i].start =0 ; -page_set_flags (ptr, shm_regions[i].size,0 ); -break ; - } - } - ret =get_errno (shmdt ((void *)g2h (ptr))); + ret =do_shmdt (ptr);break ;case IPCOP_shmget:
@@ -2540,18 +2730,9 @@ 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: -switch (second) { -case IPC_RMID : -case SHM_LOCK : -case SHM_UNLOCK : - ret =get_errno (shmctl (first, second,NULL )); -break ; -default : - goto unimplemented; - } + ret =do_shmctl (first, second, third);break ;default : - unimplemented:gemu_log ("Unsupported ipc call: %d (version %d)\n" , call, version); ret = -TARGET_ENOSYS ;break ;
@@ -5312,6 +5493,26 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =do_msgsnd (arg1, arg2, arg3, arg4);break ;#endif +#ifdef TARGET_NR_shmget +case TARGET_NR_shmget: + ret =get_errno (shmget (arg1, arg2, arg3)); +break ; +#endif +#ifdef TARGET_NR_shmctl +case TARGET_NR_shmctl: + ret =do_shmctl (arg1, arg2, arg3); +break ; +#endif +#ifdef TARGET_NR_shmat +case TARGET_NR_shmat: + ret =do_shmat (arg1, arg2, arg3); +break ; +#endif +#ifdef TARGET_NR_shmdt +case TARGET_NR_shmdt: + ret =do_shmdt (arg1); +break ; +#endif case TARGET_NR_fsync: ret =get_errno (fsync (arg1));break ;
Signature · 1 line
1.6.2.1
PATCH 3/21 linux-user: implemented ELF coredump support for ARM target
In reply to [email protected]From: Mika Westerberg <[email protected]>
When target process is killed with signal (such signal that should dump core) a coredump file is created. This file is similar than coredump generated by Linux (there are few exceptions though).
Riku Voipio: added support for rlimit
From: Mika Westerberg <[email protected]>
--- cpu-all.h | 2 + elf.h | 19 +- exec.c | 69 +++-- linux-user/elfload.c | 928 +++++++++++++++++++++++++++++++++++++++++++++++- linux-user/linuxload.c | 50 ++-- linux-user/main.c | 42 ++- linux-user/qemu.h | 13 +- linux-user/signal.c | 40 ++- linux-user/syscall.c | 6 + 9 files changed, 1101 insertions(+), 68 deletions(-)
cpu-all.h +2 -0
@@ -735,6 +735,8 @@ extern unsigned long qemu_host_page_mask;#define PAGE_RESERVED 0x0020void page_dump (FILE *f); +int walk_memory_regions (void *, +int (*fn)(void *,unsigned long ,unsigned long ,unsigned long ));int page_get_flags (target_ulong address);void page_set_flags (target_ulong start,target_ulong end,int flags);int page_check_range (target_ulong start,target_ulong len,int flags);
elf.h +18 -1
@@ -1081,7 +1081,23 @@ typedef struct elf64_shdr {#define EI_CLASS 4#define EI_DATA 5#define EI_VERSION 6 -#define EI_PAD 7 +#define EI_OSABI 7 +#define EI_PAD 8 + +#define ELFOSABI_NONE 0/* UNIX System V ABI */ +#define ELFOSABI_SYSV 0/* Alias. */ +#define ELFOSABI_HPUX 1/* HP-UX */ +#define ELFOSABI_NETBSD 2/* NetBSD. */ +#define ELFOSABI_LINUX 3/* Linux. */ +#define ELFOSABI_SOLARIS 6/* Sun Solaris. */ +#define ELFOSABI_AIX 7/* IBM AIX. */ +#define ELFOSABI_IRIX 8/* SGI Irix. */ +#define ELFOSABI_FREEBSD 9/* FreeBSD. */ +#define ELFOSABI_TRU64 10/* Compaq TRU64 UNIX. */ +#define ELFOSABI_MODESTO 11/* Novell Modesto. */ +#define ELFOSABI_OPENBSD 12/* OpenBSD. */ +#define ELFOSABI_ARM 97/* ARM */ +#define ELFOSABI_STANDALONE 255/* Standalone (embedded) application */ #define ELFMAG0 0x7f/* EI_MAG */ #define ELFMAG1 'E'
@@ -1108,6 +1124,7 @@ typedef struct elf64_shdr {#define NT_PRFPREG 2#define NT_PRPSINFO 3#define NT_TASKSTRUCT 4 +#define NT_AUXV 6#define NT_PRXFPREG 0x46e62b7f/* copied from gdb5.1/include/elf/common.h */
exec.c +46 -23
92 lines not on this page · raw message
linux-user/elfload.c +920 -8
1,021 lines not on this page · raw message
linux-user/linuxload.c +26 -24
97 lines not on this page · raw message
linux-user/main.c +35 -7
78 lines not on this page · raw message
linux-user/qemu.h +11 -2
@@ -18,6 +18,7 @@#include "syscall.h" #include "target_signal.h" #include "gdbstub.h" +#include "sys-queue.h" #if defined(USE_NPTL )#define THREAD __thread
@@ -44,6 +45,9 @@ struct image_info {abi_ulong entry;abi_ulong code_offset;abi_ulong data_offset; +abi_ulong saved_auxv; +abi_ulong arg_start; +abi_ulong arg_end;char **host_argv;int personality; };
@@ -87,7 +91,7 @@ struct emulated_sigtable {/* NOTE: we force a big alignment so that the stack stored after is aligned too */ typedef struct TaskState { - struct TaskState *next; + pid_t ts_tid; /* tid (or pid) of this task */ #ifdef TARGET_ARM /* FPA state */ FPA11 fpa;
@@ -114,6 +118,7 @@ typedef struct TaskState {#endif int used;/* non zero if used */ struct image_info *info; +struct linux_binprm *bprm;struct emulated_sigtable sigtab[TARGET_NSIG ];struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE ];/* siginfo queue */
@@ -125,6 +130,8 @@ typedef struct TaskState {extern char *exec_path;void init_task_state (TaskState *ts); +void task_settid (TaskState *); +void stop_all_tasks (void );extern const char *qemu_uname_release;/* ??? See if we can avoid exposing so much of the loader internals. */
@@ -149,13 +156,15 @@ struct linux_binprm {char **argv;char **envp;char * filename;/* Name of binary */ +int (*core_dump)(int ,const CPUState *);/* coredump routine */ };void do_init_thread (struct target_pt_regs *regs,struct image_info *infop);abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp,abi_ulong stringp,int push_ptr);int loader_exec (const char * filename,char ** argv,char ** envp, -struct target_pt_regs * regs,struct image_info *infop); +struct target_pt_regs * regs,struct image_info *infop, +struct linux_binprm *);int load_elf_binary (struct linux_binprm * bprm,struct target_pt_regs * regs,struct image_info * info);
linux-user/signal.c +37 -3
@@ -27,6 +27,7 @@#include <errno.h> #include <assert.h> #include <sys/ucontext.h> +#include <sys/resource.h> #include "qemu.h" #include "qemu-common.h"
@@ -287,6 +288,23 @@ static int fatal_signal (int sig) } } +/* returns 1 if given signal should dump core if not handled */ +static int core_dump_signal (int sig) +{ +switch (sig) { +case TARGET_SIGABRT : +case TARGET_SIGFPE : +case TARGET_SIGILL : +case TARGET_SIGQUIT : +case TARGET_SIGSEGV : +case TARGET_SIGTRAP : +case TARGET_SIGBUS : +return (1 ); +default : +return (0 ); + } +} +void signal_init (void ) {struct sigaction act;
@@ -352,13 +370,29 @@ static inline void free_sigqueue(CPUState *env, struct sigqueue *q)/* abort execution with signal */ static void QEMU_NORETURN force_sig(int sig) { -int host_sig; +TaskState *ts = (TaskState *)thread_env->opaque; +int host_sig, core_dumped =0 ;struct sigaction act; host_sig =target_to_host_signal (sig); -fprintf (stderr,"qemu: uncaught target signal %d (%s) - exiting\n" , - sig,strsignal (host_sig));gdb_signalled (thread_env, sig); +/* dump core if supported by target binary format */ +if (core_dump_signal (sig) && (ts->bprm->core_dump !=NULL )) { +stop_all_tasks (); + core_dumped = + ((*ts->bprm->core_dump)(sig, thread_env) ==0 ); + } +if (core_dumped) { +/* we already dumped the core of target process, we don't want +* a coredump of qemu itself */ +struct rlimit nodump; +getrlimit (RLIMIT_CORE , &nodump); + nodump.rlim_cur=0 ; +setrlimit (RLIMIT_CORE , &nodump); + (void )fprintf (stderr,"qemu: uncaught target signal %d (%s) - %s\n" , + sig,strsignal (host_sig),"core dumped" ); + } +/* The proper exit code for dieing from an uncaught signal is * -<signal>. The kernel doesn't allow exit() or _exit() to pass * a negative value. To get the proper exit code we need to
linux-user/syscall.c +6 -0
@@ -3379,11 +3379,14 @@ static void *clone_func(void *arg) {new_thread_info *info = arg;CPUState *env; +TaskState *ts; env = info->env; thread_env = env; + ts = (TaskState *)thread_env->opaque; info->tid =gettid (); env->host_tid = info->tid; +task_settid (ts);if (info->child_tidptr)put_user_u32 (info->tid, info->child_tidptr);if (info->parent_tidptr)
@@ -3435,6 +3438,7 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp, flags &= ~(CLONE_VFORK |CLONE_VM );if (flags &CLONE_VM ) { +TaskState *parent_ts = (TaskState *)env->opaque;#if defined(USE_NPTL )new_thread_info info;pthread_attr_t attr;
@@ -3447,6 +3451,8 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,/* Init regs that differ from the parent. */ cpu_clone_regs (new_env, newsp); new_env->opaque = ts; + ts->bprm = parent_ts->bprm; + ts->info = parent_ts->info;#if defined(USE_NPTL ) nptl_flags = flags; flags &= ~CLONE_NPTL_FLAGS2 ;
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 03/21] linux-user: implemented ELF coredump support for ARM target
Quoted 13 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Mika Westerberg <[email protected]>
When target process is killed with signal (such signal that should dump core) a coredump file is created. This file is similar than coredump generated by Linux (there are few exceptions though).
Riku Voipio: added support for rlimit
From: Mika Westerberg <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
PATCH 4/21 linux-user: added x86 and x86_64 support for ELF coredump
In reply to [email protected]From: Mika Westerberg <[email protected]>
From: Mika Westerberg <[email protected]>
--- linux-user/elfload.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 83 insertions(+), 0 deletions(-)
linux-user/elfload.c +83 -0
@@ -134,6 +134,52 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i regs->rip = infop->entry; } +typedef target_ulong elf_greg_t ; +typedef uint32_t target_uid_t ; +typedef uint32_t target_gid_t ; +typedef int32_t target_pid_t ; + +#define ELF_NREG 27 +typedef elf_greg_t elf_gregset_t [ELF_NREG ]; + +/* +* Note that ELF_NREG should be 29 as there should be place for +* TRAPNO and ERR "registers" as well but linux doesn't dump +* those. +* +* See linux kernel: arch/x86/include/asm/elf.h +*/ +static void elf_core_copy_regs (elf_gregset_t *regs,const CPUState *env) +{ + (*regs)[0 ] = env->regs[15 ]; + (*regs)[1 ] = env->regs[14 ]; + (*regs)[2 ] = env->regs[13 ]; + (*regs)[3 ] = env->regs[12 ]; + (*regs)[4 ] = env->regs[R_EBP ]; + (*regs)[5 ] = env->regs[R_EBX ]; + (*regs)[6 ] = env->regs[11 ]; + (*regs)[7 ] = env->regs[10 ]; + (*regs)[8 ] = env->regs[9 ]; + (*regs)[9 ] = env->regs[8 ]; + (*regs)[10 ] = env->regs[R_EAX ]; + (*regs)[11 ] = env->regs[R_ECX ]; + (*regs)[12 ] = env->regs[R_EDX ]; + (*regs)[13 ] = env->regs[R_ESI ]; + (*regs)[14 ] = env->regs[R_EDI ]; + (*regs)[15 ] = env->regs[R_EAX ];/* XXX */ + (*regs)[16 ] = env->eip; + (*regs)[17 ] = env->segs[R_CS ].selector &0xffff ; + (*regs)[18 ] = env->eflags; + (*regs)[19 ] = env->regs[R_ESP ]; + (*regs)[20 ] = env->segs[R_SS ].selector &0xffff ; + (*regs)[21 ] = env->segs[R_FS ].selector &0xffff ; + (*regs)[22 ] = env->segs[R_GS ].selector &0xffff ; + (*regs)[23 ] = env->segs[R_DS ].selector &0xffff ; + (*regs)[24 ] = env->segs[R_ES ].selector &0xffff ; + (*regs)[25 ] = env->segs[R_FS ].selector &0xffff ; + (*regs)[26 ] = env->segs[R_GS ].selector &0xffff ; +} +#else #define ELF_START_MMAP 0x80000000
@@ -164,8 +210,45 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *iA value of 0 tells we have no such handler. */ regs->edx =0 ; } + +typedef target_ulong elf_greg_t ; +typedef uint16_t target_uid_t ; +typedef uint16_t target_gid_t ; +typedef int32_t target_pid_t ; + +#define ELF_NREG 17 +typedef elf_greg_t elf_gregset_t [ELF_NREG ]; + +/* +* Note that ELF_NREG should be 19 as there should be place for +* TRAPNO and ERR "registers" as well but linux doesn't dump +* those. +* +* See linux kernel: arch/x86/include/asm/elf.h +*/ +static void elf_core_copy_regs (elf_gregset_t *regs,const CPUState *env) +{ + (*regs)[0 ] = env->regs[R_EBX ]; + (*regs)[1 ] = env->regs[R_ECX ]; + (*regs)[2 ] = env->regs[R_EDX ]; + (*regs)[3 ] = env->regs[R_ESI ]; + (*regs)[4 ] = env->regs[R_EDI ]; + (*regs)[5 ] = env->regs[R_EBP ]; + (*regs)[6 ] = env->regs[R_EAX ]; + (*regs)[7 ] = env->segs[R_DS ].selector &0xffff ; + (*regs)[8 ] = env->segs[R_ES ].selector &0xffff ; + (*regs)[9 ] = env->segs[R_FS ].selector &0xffff ; + (*regs)[10 ] = env->segs[R_GS ].selector &0xffff ; + (*regs)[11 ] = env->regs[R_EAX ];/* XXX */ + (*regs)[12 ] = env->eip; + (*regs)[13 ] = env->segs[R_CS ].selector &0xffff ; + (*regs)[14 ] = env->eflags; + (*regs)[15 ] = env->regs[R_ESP ]; + (*regs)[16 ] = env->segs[R_SS ].selector &0xffff ; +}#endif +#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096#endif
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 04/21] linux-user: added x86 and x86_64 support for ELF coredump
Quoted 7 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Mika Westerberg <[email protected]>
From: Mika Westerberg <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
Maybe it would be useful to get a core dump from a running emulated process. Since we have no monitor for user emulators, a GDB command could be used.
PATCH 5/21 linux-user: strace now handles guest strings correctly [v2]
In reply to [email protected]From: Mika Westerberg <[email protected]>
- to not to break strace with GUEST_BASE is set:
- Strace now can load and print guest strings correctly.
- Added printing support for commonly used flags in some syscalls (e.g open, creat, mmap etc.)
v2:
- fix strace.c build on etch
- add futex print to strace
From: Mika Westerberg <[email protected]>
--- linux-user/strace.c | 1072 ++++++++++++++++++++++++++++++++++++++++++++- linux-user/strace.list | 111 +++--- linux-user/syscall.c | 6 - linux-user/syscall_defs.h | 6 + 4 files changed, 1118 insertions(+), 77 deletions(-)
linux-user/strace.c +1054 -18
@@ -6,6 +6,9 @@#include <sys/shm.h> #include <sys/select.h> #include <sys/types.h> +#include <sys/mount.h> +#include <sys/mman.h> +#include <linux/futex.h> #include <unistd.h> #include "qemu.h"
@@ -21,6 +24,47 @@ struct syscallname {void (*result)(const struct syscallname *,abi_long ); }; +#ifdef __GNUC__ +/* +* It is possible that target doesn't have syscall that uses +* following flags but we don't want the compiler to warn +* us about them being unused. Same applies to utility print +* functions. It is ok to keep them while not used. +*/ +#define UNUSED __attribute__ ((unused)) +#else +#define UNUSED +#endif + +/* +* Structure used to translate flag values into strings. This is +* similar that is in the actual strace tool. +*/ +struct flags { +abi_long f_value;/* flag */ +const char *f_string;/* stringified flag */ +}; + +/* common flags for all architectures */ +#define FLAG_GENERIC (name) { name, #name } +/* target specific flags (syscall_defs.h has TARGET_<flag>) */ +#define FLAG_TARGET (name) { TARGET_ ## name, #name } +/* end of flags array */ +#define FLAG_END { 0, NULL } + +UNUSED static const char *get_comma(int); +UNUSED static void print_pointer(abi_long, int); +UNUSED static void print_flags(const struct flags *, abi_long, int); +UNUSED static void print_at_dirfd(abi_long, int); +UNUSED static void print_file_mode(abi_long, int); +UNUSED static void print_open_flags(abi_long, int); +UNUSED static void print_syscall_prologue(const struct syscallname *); +UNUSED static void print_syscall_epilogue(const struct syscallname *); +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); +/* * Utility functions */
@@ -100,22 +144,6 @@ print_fdset(int n, abi_ulong target_fds_addr) }gemu_log ("]" ); } - -static void -print_timeval (abi_ulong tv_addr) -{ -if ( tv_addr ) { -struct target_timeval *tv; - - tv =lock_user (VERIFY_READ , tv_addr,sizeof (*tv),1 ); -if (!tv) -return ; -gemu_log ("{" TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld"}" , - tv->tv_sec, tv->tv_usec); -unlock_user (tv, tv_addr,0 ); - }else -gemu_log ("NULL" ); -}#endif /*
@@ -142,7 +170,7 @@ print_newselect(const struct syscallname *name,gemu_log ("," );print_fdset (arg1, arg4);gemu_log ("," ); -print_timeval (arg5); +print_timeval (arg5,1 );gemu_log (")" );/* save for use in the return output function below */
@@ -250,11 +278,1019 @@ print_syscall_ret_newselect(const struct syscallname *name, abi_long ret)gemu_log ("," );print_fdset (newselect_arg1,newselect_arg4);gemu_log ("," ); -print_timeval (newselect_arg5); +print_timeval (newselect_arg5,1 );gemu_log (")\n" ); }#endif +UNUSED static struct flags access_flags[] = { +FLAG_GENERIC (F_OK ), +FLAG_GENERIC (R_OK ), +FLAG_GENERIC (W_OK ), +FLAG_GENERIC (X_OK ), +FLAG_END , +}; + +UNUSED static struct flags at_file_flags[] = { +#ifdef AT_EACCESS + FLAG_GENERIC(AT_EACCESS), +#endif +#ifdef AT_SYMLINK_NOFOLLOW + FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), +#endif + FLAG_END, +}; + +UNUSED static struct flags unlinkat_flags[] = { +#ifdef AT_REMOVEDIR + FLAG_GENERIC(AT_REMOVEDIR), +#endif + FLAG_END, +}; + +UNUSED static struct flags mode_flags[] = { + FLAG_GENERIC(S_IFSOCK), + FLAG_GENERIC(S_IFLNK), + FLAG_GENERIC(S_IFREG), + FLAG_GENERIC(S_IFBLK), + FLAG_GENERIC(S_IFDIR), + FLAG_GENERIC(S_IFCHR), + FLAG_GENERIC(S_IFIFO), + FLAG_END, +}; + +UNUSED static struct flags open_access_flags[] = { + FLAG_TARGET(O_RDONLY), + FLAG_TARGET(O_WRONLY), + FLAG_TARGET(O_RDWR), + FLAG_END, +}; + +UNUSED static struct flags open_flags[] = { + FLAG_TARGET(O_APPEND), + FLAG_TARGET(O_CREAT), + FLAG_TARGET(O_DIRECTORY), + FLAG_TARGET(O_EXCL), + FLAG_TARGET(O_LARGEFILE), + FLAG_TARGET(O_NOCTTY), + FLAG_TARGET(O_NOFOLLOW), + FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ + FLAG_TARGET(O_SYNC), + FLAG_TARGET(O_TRUNC), +#ifdef O_DIRECT + FLAG_TARGET(O_DIRECT), +#endif + FLAG_END, +}; + +UNUSED static struct flags mount_flags[] = { +#ifdef MS_BIND + FLAG_GENERIC(MS_BIND), +#endif +#ifdef MS_DIRSYNC + FLAG_GENERIC(MS_DIRSYNC), +#endif + FLAG_GENERIC(MS_MANDLOCK), +#ifdef MS_MOVE + FLAG_GENERIC(MS_MOVE), +#endif + FLAG_GENERIC(MS_NOATIME), + FLAG_GENERIC(MS_NODEV), + FLAG_GENERIC(MS_NODIRATIME), + FLAG_GENERIC(MS_NOEXEC), + FLAG_GENERIC(MS_NOSUID), + FLAG_GENERIC(MS_RDONLY), +#ifdef MS_RELATIME + FLAG_GENERIC(MS_RELATIME), +#endif + FLAG_GENERIC(MS_REMOUNT), + FLAG_GENERIC(MS_SYNCHRONOUS), + FLAG_END, +}; + +UNUSED static struct flags umount2_flags[] = { +#ifdef MNT_FORCE + FLAG_GENERIC(MNT_FORCE), +#endif +#ifdef MNT_DETACH + FLAG_GENERIC(MNT_DETACH), +#endif +#ifdef MNT_EXPIRE + FLAG_GENERIC(MNT_EXPIRE), +#endif + FLAG_END, +}; + +UNUSED static struct flags mmap_prot_flags[] = { + FLAG_GENERIC(PROT_NONE), + FLAG_GENERIC(PROT_EXEC), + FLAG_GENERIC(PROT_READ), + FLAG_GENERIC(PROT_WRITE), + FLAG_END, +}; + +UNUSED static struct flags mmap_flags[] = { + FLAG_TARGET(MAP_SHARED), + FLAG_TARGET(MAP_PRIVATE), + FLAG_TARGET(MAP_ANONYMOUS), + FLAG_TARGET(MAP_DENYWRITE), + FLAG_TARGET(MAP_FIXED), + FLAG_TARGET(MAP_GROWSDOWN), +#ifdef MAP_LOCKED + FLAG_TARGET(MAP_LOCKED), +#endif +#ifdef MAP_NONBLOCK + FLAG_TARGET(MAP_NONBLOCK), +#endif + FLAG_TARGET(MAP_NORESERVE), +#ifdef MAP_POPULATE + FLAG_TARGET(MAP_POPULATE), +#endif + 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, +}; + +/* + * print_xxx utility functions. These are used to print syscall + * parameters in certain format. All of these have parameter + * named 'last'. This parameter is used to add comma to output + * when last == 0. + */ + +static const char * +get_comma(int last) +{ + return ((last) ? "" : ","); +} + +static void +print_flags(const struct flags *f, abi_long tflags, int last) +{ + const char *sep = ""; + int flags; + int n; + + flags = (int)tswap32(tflags); + + if ((flags == 0) && (f->f_value == 0)) { + gemu_log("%s%s", f->f_string, get_comma(last)); + return; + } + for (n = 0; f->f_string != NULL; f++) { + if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { + gemu_log("%s%s", sep, f->f_string); + flags &= ~f->f_value; + sep = "|"; + n++; + } + } + + if (n > 0) { + /* print rest of the flags as numeric */ + if (flags != 0) { + gemu_log("%s%#x%s", sep, flags, get_comma(last)); + } else { + gemu_log("%s", get_comma(last)); + } + } else { + /* no string version of flags found, print them in hex then */ + gemu_log("%#x%s", flags, get_comma(last)); + } +} + +static void +print_at_dirfd(abi_long tdirfd, int last) +{ + int dirfd = tswap32(tdirfd); + +#ifdef AT_FDCWD + if (dirfd == AT_FDCWD) { + gemu_log("AT_FDCWD%s", get_comma(last)); + return; + } +#endif + gemu_log("%d%s", dirfd, get_comma(last)); +} + +static void +print_file_mode(abi_long tmode, int last) +{ + const char *sep = ""; + const struct flags *m; + mode_t mode = (mode_t)tswap32(tmode); + + for (m = &mode_flags[0]; m->f_string != NULL; m++) { + if ((m->f_value & mode) == m->f_value) { + gemu_log("%s%s", m->f_string, sep); + sep = "|"; + mode &= ~m->f_value; + break; + } + } + + mode &= ~S_IFMT; + /* print rest of the mode as octal */ + if (mode != 0) + gemu_log("%s%#o", sep, mode); + + gemu_log("%s", get_comma(last)); +} + +static void +print_open_flags(abi_long tflags, int last) +{ + int flags = tswap32(tflags); + + print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); + flags &= ~TARGET_O_ACCMODE; + if (flags == 0) { + gemu_log("%s", get_comma(last)); + return; + } + gemu_log("|"); + print_flags(open_flags, flags, last); +} + +static void +print_syscall_prologue(const struct syscallname *sc) +{ + gemu_log("%s(", sc->name); +} + +/*ARGSUSED*/ +static void +print_syscall_epilogue(const struct syscallname *sc) +{ + (void)sc; + gemu_log(")"); +} + +static void +print_string(abi_long addr, int last) +{ + char *s; + + if ((s = lock_user_string(addr)) != NULL) { + gemu_log("\"%s\"%s", s, get_comma(last)); + unlock_user(s, addr, 0); + } else { + /* can't get string out of it, so print it as pointer */ + print_pointer(addr, last); + } +} + +/* + * Prints out raw parameter using given format. Caller needs + * to do byte swapping if needed. + */ +static void +print_raw_param(const char *fmt, abi_long param, int last) +{ + char format[64]; + + (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); + gemu_log(format, param); +} + +static void +print_pointer(abi_long p, int last) +{ + if (p == 0) + gemu_log("NULL%s", get_comma(last)); + else + gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); +} + +/* + * Reads 32-bit (int) number from guest address space from + * address 'addr' and prints it. + */ +static void +print_number(abi_long addr, int last) +{ + if (addr == 0) { + gemu_log("NULL%s", get_comma(last)); + } else { + int num; + + get_user_s32(num, addr); + gemu_log("[%d]%s", num, get_comma(last)); + } +} + +static void +print_timeval(abi_ulong tv_addr, int last) +{ + if( tv_addr ) { + struct target_timeval *tv; + + tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); + if (!tv) + return; + gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", + tv->tv_sec, tv->tv_usec, get_comma(last)); + unlock_user(tv, tv_addr, 0); + } else + gemu_log("NULL%s", get_comma(last)); +} + +#undef UNUSED + +#ifdef TARGET_NR_accept +static void +print_accept(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", tswap32(arg0), 0); + print_pointer(arg1, 0); + print_number(arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_access +static void +print_access(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_string(arg0, 0); + print_flags(access_flags, arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_brk +static void +print_brk(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_chdir +static void +print_chdir(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_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_chmod +static void +print_chmod(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_string(arg0, 0); + print_file_mode(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_creat +static void +print_creat(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_string(arg0, 0); + print_file_mode(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_execv +static void +print_execv(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_string(arg0, 0); + print_raw_param("0x" TARGET_ABI_FMT_lx, tswapl(arg1), 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_faccessat +static void +print_faccessat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_flags(access_flags, arg2, 0); + print_flags(at_file_flags, arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_fchmodat +static void +print_fchmodat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_file_mode(arg2, 0); + print_flags(at_file_flags, arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_fchownat +static void +print_fchownat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); +#ifdef USE_UID16 + print_raw_param("%d", tswap16(arg2), 0); + print_raw_param("%d", tswap16(arg3), 0); +#else + print_raw_param("%d", tswap32(arg2), 0); + print_raw_param("%d", tswap32(arg3), 0); +#endif + print_flags(at_file_flags, arg4, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) +static void +print_fcntl(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", tswap32(arg0), 0); + print_flags(fcntl_flags, arg1, 0); + /* + * TODO: check flags and print following argument only + * when needed. + */ + print_pointer(arg2, 1); + print_syscall_epilogue(name); +} +#define print_fcntl64 print_fcntl +#endif + + +#ifdef TARGET_NR_futimesat +static void +print_futimesat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_timeval(arg2, 0); + print_timeval(arg2 + sizeof (struct target_timeval), 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_link +static void +print_link(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_string(arg0, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_linkat +static void +print_linkat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_at_dirfd(arg2, 0); + print_string(arg3, 0); + print_flags(at_file_flags, arg4, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ + defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) +static void +print_stat(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_string(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#define print_lstat print_stat +#define print_stat64 print_stat +#define print_lstat64 print_stat +#endif + +#if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) +static void +print_fstat(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", tswap32(arg0), 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#define print_fstat64 print_fstat +#endif + +#ifdef TARGET_NR_mkdir +static void +print_mkdir(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_string(arg0, 0); + print_file_mode(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mkdirat +static void +print_mkdirat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_file_mode(arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mknod +static void +print_mknod(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + int hasdev = (tswapl(arg1) & (S_IFCHR|S_IFBLK)); + + print_syscall_prologue(name); + print_string(arg0, 0); + print_file_mode(arg1, (hasdev == 0)); + if (hasdev) { + print_raw_param("makedev(%d", major(tswapl(arg2)), 0); + print_raw_param("%d)", minor(tswapl(arg2)), 1); + } + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mknodat +static void +print_mknodat(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + int hasdev = (tswapl(arg2) & (S_IFCHR|S_IFBLK)); + + print_syscall_prologue(name); + print_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_file_mode(arg2, (hasdev == 0)); + if (hasdev) { + print_raw_param("makedev(%d", major(tswapl(arg3)), 0); + print_raw_param("%d)", minor(tswapl(arg3)), 1); + } + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mq_open +static void +print_mq_open(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + int is_creat = (tswapl(arg1) & TARGET_O_CREAT); + + print_syscall_prologue(name); + print_string(arg0, 0); + print_open_flags(arg1, (is_creat == 0)); + if (is_creat) { + print_file_mode(arg2, 0); + print_pointer(arg3, 1); + } + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_open +static void +print_open(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + int is_creat = (tswap32(arg1) & TARGET_O_CREAT); + + print_syscall_prologue(name); + print_string(arg0, 0); + print_open_flags(arg1, (is_creat == 0)); + if (is_creat) + print_file_mode(arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_openat +static void +print_openat(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + int is_creat = (tswap32(arg2) & TARGET_O_CREAT); + + print_syscall_prologue(name); + print_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_open_flags(arg2, (is_creat == 0)); + if (is_creat) + print_file_mode(arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mq_unlink +static void +print_mq_unlink(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_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + +#if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) +static void +print_fstatat64(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_flags(at_file_flags, arg3, 1); + print_syscall_epilogue(name); +} +#define print_newfstatat print_fstatat64 +#endif + +#ifdef TARGET_NR_readlink +static void +print_readlink(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_string(arg0, 0); + print_pointer(arg1, 0); + print_raw_param("%u", tswapl(arg2), 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_readlinkat +static void +print_readlinkat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_raw_param("%u", tswapl(arg3), 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_rename +static void +print_rename(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_string(arg0, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_renameat +static void +print_renameat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_at_dirfd(arg2, 0); + print_string(arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_statfs +static void +print_statfs(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_string(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#define print_statfs64 print_statfs +#endif + +#ifdef TARGET_NR_symlink +static void +print_symlink(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_string(arg0, 0); + print_string(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_symlinkat +static void +print_symlinkat(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_string(arg0, 0); + print_at_dirfd(arg1, 0); + print_string(arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mount +static void +print_mount(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_string(arg0, 0); + print_string(arg1, 0); + print_string(arg2, 0); + print_flags(mount_flags, arg3, 0); + print_pointer(arg4, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_umount +static void +print_umount(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_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_umount2 +static void +print_umount2(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_string(arg0, 0); + print_flags(umount2_flags, arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_unlink +static void +print_unlink(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_string(arg0, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_unlinkat +static void +print_unlinkat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_flags(unlinkat_flags, arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_utime +static void +print_utime(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_string(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_utimes +static void +print_utimes(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_string(arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_utimensat +static void +print_utimensat(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_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_flags(at_file_flags, arg3, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_mmap +static void +print_mmap(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_pointer(arg0, 0); + print_raw_param("%d", tswapl(arg1), 0); + print_flags(mmap_prot_flags, arg2, 0); + print_flags(mmap_flags, arg3, 0); + print_raw_param("%d", tswapl(arg4), 0); + print_raw_param("%#x", tswapl(arg5), 1); + print_syscall_epilogue(name); +} +#define print_mmap2 print_mmap +#endif + +#ifdef TARGET_NR_mprotect +static void +print_mprotect(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_pointer(arg0, 0); + print_raw_param("%d", tswapl(arg1), 0); + print_flags(mmap_prot_flags, arg2, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_munmap +static void +print_munmap(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_pointer(arg0, 0); + print_raw_param("%d", tswapl(arg1), 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_futex +static void print_futex_op(abi_long tflag, int last) +{ +#define print_op(val) \ +if( cmd == val ) { \ + gemu_log(#val); \ + return; \ +} + + int cmd = (int)tswap32(tflag); +#ifdef FUTEX_PRIVATE_FLAG + if (cmd == FUTEX_PRIVATE_FLAG) + gemu_log("FUTEX_PRIVATE_FLAG|"); +#endif + print_op(FUTEX_WAIT) + print_op(FUTEX_WAKE) + print_op(FUTEX_FD) + print_op(FUTEX_REQUEUE) + print_op(FUTEX_CMP_REQUEUE) + print_op(FUTEX_WAKE_OP) + print_op(FUTEX_LOCK_PI) + print_op(FUTEX_UNLOCK_PI) + print_op(FUTEX_TRYLOCK_PI) +#ifdef FUTEX_WAIT_BITSET + print_op(FUTEX_WAIT_BITSET) +#endif +#ifdef FUTEX_WAKE_BITSET + print_op(FUTEX_WAKE_BITSET) +#endif + /* unknown values */ + gemu_log("%d",cmd); +} + +static void +print_futex(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_pointer(arg0, 0); + print_futex_op(arg1, 0); + print_raw_param(",%d", tswapl(arg2), 0); + print_pointer(arg3, 0); /* struct timespec */ + print_pointer(arg4, 0); + print_raw_param("%d", tswapl(arg4), 1); + print_syscall_epilogue(name); +} +#endif + /* * An array of all of the syscalls we know about */
linux-user/strace.list +58 -53
324 lines not on this page · raw message
linux-user/syscall.c +0 -6
@@ -93,12 +93,6 @@//#define DEBUG -#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_SPARC ) \ - || defined(TARGET_M68K ) || defined(TARGET_SH4 ) || defined(TARGET_CRIS ) -/* 16 bit uid wrappers emulation */ -#define USE_UID16 -#endif -//#include <linux/msdos_fs.h> #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct linux_dirent [2])#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct linux_dirent [2])
linux-user/syscall_defs.h +6 -0
@@ -48,6 +48,12 @@#define TARGET_IOC_NRBITS 8#define TARGET_IOC_TYPEBITS 8 +#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_SPARC ) \ + || defined(TARGET_M68K ) || defined(TARGET_SH4 ) || defined(TARGET_CRIS ) +/* 16 bit uid wrappers emulation */ +#define USE_UID16 +#endif +#if defined(TARGET_I386 ) || defined(TARGET_ARM ) || defined(TARGET_SH4 ) \ || defined(TARGET_M68K ) || defined(TARGET_CRIS )
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 05/21] linux-user: strace now handles guest strings correctly [v2]
Quoted 15 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Mika Westerberg <[email protected]>
- to not to break strace with
GUEST_BASEis set:
- Strace now can load and print guest strings correctly.
- Added printing support for commonly used flags in some syscalls (e.g open, creat, mmap etc.)v2:
- fixstrace.cbuild on etch
- add futex print to straceFrom: Mika Westerberg <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
PATCH 6/21 Revived GUEST_BASE support for usermode emulation targets [v5]
In reply to [email protected]From: Mika Westerberg <[email protected]>
From: Mika Westerberg <[email protected]>
- Now GUEST_BASE is dynamic and can be set from command line.
- Qemu checks /proc/sys/vm/mmap_min_addr and sets GUEST_BASE if needed.
- Code generation supports GUEST_BASE for i386 and x86_64 hosts.
[v3]: implemented GUEST_BASE with offset mods
Using malc's advice, instead of a mov or lea, just adjust the offset parameter of tcg_out_modrm_offset(). - Riku
[v5]: set a GUEST_BASE_MAX instead of supporting moving to arbitary ranges
From: Mika Westerberg <[email protected]>
--- configure | 9 +++++++ cpu-all.h | 7 ++++- linux-user/elfload.c | 24 +++++++++++++++++++ linux-user/main.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ linux-user/qemu.h | 3 ++ tcg/i386/tcg-target.c | 36 ++++++++++++++++------------ tcg/x86_64/tcg-target.c | 30 +++++++++++++---------- 7 files changed, 138 insertions(+), 30 deletions(-)
configure +9 -0
@@ -181,6 +181,7 @@ linux_user="no" darwin_user="no" bsd_user="no" build_docs="yes" +guest_base="no" uname_release="" curses="yes" curl="yes"
@@ -465,6 +466,8 @@ for opt do ;; --enable-bsd-user) bsd_user="yes" ;; + --enable-guest-base) guest_base="yes" + ;; --enable-uname-release=*) uname_release="$optarg" ;; --sparc_cpu=*)
@@ -628,6 +631,8 @@ echo " --enable-darwin-user enable all darwin usermode emulation targets" echo " --disable-darwin-user disable all darwin usermode emulation targets" echo " --enable-bsd-user enable all BSD usermode emulation targets" echo " --disable-bsd-user disable all BSD usermode emulation targets" +echo " --enable-guest-base enable GUEST_BASE support for usermode" +echo " emulation targets" echo " --fmod-lib path to FMOD library" echo " --fmod-inc path to FMOD includes" echo " --oss-lib path to OSS library"
@@ -1375,6 +1380,7 @@ echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \ echo "uname -r $uname_release" echo "NPTL support $nptl" +echo "GUEST_BASE $guest_base" echo "vde support $vde" echo "AIO support $aio" echo "IO thread $io_thread"
@@ -2127,6 +2133,9 @@ if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h fi +if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then + echo "#define CONFIG_USE_GUEST_BASE 1" >> $config_h +fi if test "$target_bsd_user" = "yes" ; then echo "CONFIG_BSD_USER=yes" >> $config_mak echo "#define CONFIG_BSD_USER 1" >> $config_h
cpu-all.h +6 -1
@@ -625,8 +625,13 @@ static inline void stfq_be_p(void *ptr, float64 v)/* On some host systems the guest address space is reserved on the host. * This allows the guest address space to be offset to a convenient location. */ -//#define GUEST_BASE 0x20000000 +#if defined(CONFIG_USE_GUEST_BASE ) +#define GUEST_BASE_MAX 0x38000000 +extern unsigned long guest_base; +#define GUEST_BASE guest_base +#else #define GUEST_BASE 0 +#endif /* All direct uses of g2h and h2g need to go away for usermode softmmu. */ #define g2h (x) ((void *)((unsigned long)(x) + GUEST_BASE))
linux-user/elfload.c +24 -0
@@ -1545,6 +1545,30 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, info->mmap =0 ; elf_entry = (abi_ulong ) elf_ex.e_entry; +#if defined(CONFIG_USE_GUEST_BASE ) +/* +* In case where user has not explicitly set the guest_base, we +* probe here that should we set it automatically. +*/ +if (guest_base ==0 ) { +/* +* Go through ELF program header table and find out whether +* any of the segments drop below our current mmap_min_addr and +* in that case set guest_base to corresponding address. +*/ +for (i =0 , elf_ppnt = elf_phdata; i < elf_ex.e_phnum; + i++, elf_ppnt++) { +if (elf_ppnt->p_type !=PT_LOAD ) +continue ; +if (HOST_PAGE_ALIGN (elf_ppnt->p_vaddr) < mmap_min_addr) { + guest_base =HOST_PAGE_ALIGN (mmap_min_addr); +qemu_log ("setting guest_base=0x%lx\n" , guest_base); +break ; + } + } + } +#endif /* CONFIG_USE_GUEST_BASE */ +/* Do this so that we can load the interpreter, if need be. We will change some of these later */ info->rss =0 ;
linux-user/main.c +59 -0
89 lines not on this page · raw message
linux-user/qemu.h +3 -0
@@ -133,6 +133,9 @@ void init_task_state(TaskState *ts);void task_settid (TaskState *);void stop_all_tasks (void );extern const char *qemu_uname_release; +#if defined(CONFIG_USE_GUEST_BASE ) +extern unsigned long mmap_min_addr; +#endif /* ??? See if we can avoid exposing so much of the loader internals. */ /*
tcg/i386/tcg-target.c +20 -16
@@ -22,6 +22,10 @@* THE SOFTWARE. */ +#ifndef CONFIG_USE_GUEST_BASE +#define GUEST_BASE 0 +#endif +#ifndef NDEBUG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS ] = { "%eax",
@@ -572,15 +576,15 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,switch (opc) {case 0 :/* movzbl */ -tcg_out_modrm_offset (s,0xb6 |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xb6 |P_EXT , data_reg, r0,GUEST_BASE );break ;case 0 |4 :/* movsbl */ -tcg_out_modrm_offset (s,0xbe |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xbe |P_EXT , data_reg, r0,GUEST_BASE );break ;case 1 :/* movzwl */ -tcg_out_modrm_offset (s,0xb7 |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xb7 |P_EXT , data_reg, r0,GUEST_BASE );if (bswap) {/* rolw $8, data_reg */ tcg_out8 (s,0x66 );
@@ -590,7 +594,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,break ;case 1 |4 :/* movswl */ -tcg_out_modrm_offset (s,0xbf |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xbf |P_EXT , data_reg, r0,GUEST_BASE );if (bswap) {/* rolw $8, data_reg */ tcg_out8 (s,0x66 );
@@ -603,7 +607,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,break ;case 2 :/* movl (r0), data_reg */ -tcg_out_modrm_offset (s,0x8b , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x8b , data_reg, r0,GUEST_BASE );if (bswap) {/* bswap */ tcg_out_opc (s, (0xc8 + data_reg) |P_EXT );
@@ -619,13 +623,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, r0 = r1; }if (!bswap) { -tcg_out_modrm_offset (s,0x8b , data_reg, r0,0 ); -tcg_out_modrm_offset (s,0x8b , data_reg2, r0,4 ); +tcg_out_modrm_offset (s,0x8b , data_reg, r0,GUEST_BASE ); +tcg_out_modrm_offset (s,0x8b , data_reg2, r0,GUEST_BASE +4 ); }else { -tcg_out_modrm_offset (s,0x8b , data_reg, r0,4 ); +tcg_out_modrm_offset (s,0x8b , data_reg, r0,GUEST_BASE +4 );tcg_out_opc (s, (0xc8 + data_reg) |P_EXT ); -tcg_out_modrm_offset (s,0x8b , data_reg2, r0,0 ); +tcg_out_modrm_offset (s,0x8b , data_reg2, r0,GUEST_BASE );/* bswap */ tcg_out_opc (s, (0xc8 + data_reg2) |P_EXT ); }
@@ -806,7 +810,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,switch (opc) {case 0 :/* movb */ -tcg_out_modrm_offset (s,0x88 , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x88 , data_reg, r0,GUEST_BASE );break ;case 1 :if (bswap) {
@@ -818,7 +822,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, }/* movw */ tcg_out8 (s,0x66 ); -tcg_out_modrm_offset (s,0x89 , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x89 , data_reg, r0,GUEST_BASE );break ;case 2 :if (bswap) {
@@ -828,21 +832,21 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, data_reg = r1; }/* movl */ -tcg_out_modrm_offset (s,0x89 , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x89 , data_reg, r0,GUEST_BASE );break ;case 3 :if (bswap) {tcg_out_mov (s, r1, data_reg2);/* bswap data_reg */ tcg_out_opc (s, (0xc8 + r1) |P_EXT ); -tcg_out_modrm_offset (s,0x89 , r1, r0,0 ); +tcg_out_modrm_offset (s,0x89 , r1, r0,GUEST_BASE );tcg_out_mov (s, r1, data_reg);/* bswap data_reg */ tcg_out_opc (s, (0xc8 + r1) |P_EXT ); -tcg_out_modrm_offset (s,0x89 , r1, r0,4 ); +tcg_out_modrm_offset (s,0x89 , r1, r0,GUEST_BASE +4 ); }else { -tcg_out_modrm_offset (s,0x89 , data_reg, r0,0 ); -tcg_out_modrm_offset (s,0x89 , data_reg2, r0,4 ); +tcg_out_modrm_offset (s,0x89 , data_reg, r0,GUEST_BASE ); +tcg_out_modrm_offset (s,0x89 , data_reg2, r0,GUEST_BASE +4 ); }break ;default :
tcg/x86_64/tcg-target.c +17 -13
@@ -22,6 +22,10 @@* THE SOFTWARE. */ +#ifndef CONFIG_USE_GUEST_BASE +#define GUEST_BASE 0 +#endif +#ifndef NDEBUG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS ] = { "%rax",
@@ -616,15 +620,15 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,switch (opc) {case 0 :/* movzbl */ -tcg_out_modrm_offset (s,0xb6 |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xb6 |P_EXT , data_reg, r0,GUEST_BASE );break ;case 0 |4 :/* movsbX */ -tcg_out_modrm_offset (s,0xbe |P_EXT | rexw, data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xbe |P_EXT | rexw, data_reg, r0,GUEST_BASE );break ;case 1 :/* movzwl */ -tcg_out_modrm_offset (s,0xb7 |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xb7 |P_EXT , data_reg, r0,GUEST_BASE );if (bswap) {/* rolw $8, data_reg */ tcg_out8 (s,0x66 );
@@ -635,7 +639,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,case 1 |4 :if (bswap) {/* movzwl */ -tcg_out_modrm_offset (s,0xb7 |P_EXT , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xb7 |P_EXT , data_reg, r0,GUEST_BASE );/* rolw $8, data_reg */ tcg_out8 (s,0x66 );tcg_out_modrm (s,0xc1 ,0 , data_reg);
@@ -645,12 +649,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,tcg_out_modrm (s,0xbf |P_EXT | rexw, data_reg, data_reg); }else {/* movswX */ -tcg_out_modrm_offset (s,0xbf |P_EXT | rexw, data_reg, r0,0 ); +tcg_out_modrm_offset (s,0xbf |P_EXT | rexw, data_reg, r0,GUEST_BASE ); }break ;case 2 :/* movl (r0), data_reg */ -tcg_out_modrm_offset (s,0x8b , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x8b , data_reg, r0,GUEST_BASE );if (bswap) {/* bswap */ tcg_out_opc (s, (0xc8 + (data_reg &7 )) |P_EXT ,0 , data_reg,0 );
@@ -659,19 +663,19 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,case 2 |4 :if (bswap) {/* movl (r0), data_reg */ -tcg_out_modrm_offset (s,0x8b , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x8b , data_reg, r0,GUEST_BASE );/* bswap */ tcg_out_opc (s, (0xc8 + (data_reg &7 )) |P_EXT ,0 , data_reg,0 );/* movslq */ tcg_out_modrm (s,0x63 |P_REXW , data_reg, data_reg); }else {/* movslq */ -tcg_out_modrm_offset (s,0x63 |P_REXW , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x63 |P_REXW , data_reg, r0,GUEST_BASE ); }break ;case 3 :/* movq (r0), data_reg */ -tcg_out_modrm_offset (s,0x8b |P_REXW , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x8b |P_REXW , data_reg, r0,GUEST_BASE );if (bswap) {/* bswap */ tcg_out_opc (s, (0xc8 + (data_reg &7 )) |P_EXT |P_REXW ,0 , data_reg,0 );
@@ -787,7 +791,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,switch (opc) {case 0 :/* movb */ -tcg_out_modrm_offset (s,0x88 |P_REXB , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x88 |P_REXB , data_reg, r0,GUEST_BASE );break ;case 1 :if (bswap) {
@@ -799,7 +803,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, }/* movw */ tcg_out8 (s,0x66 ); -tcg_out_modrm_offset (s,0x89 , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x89 , data_reg, r0,GUEST_BASE );break ;case 2 :if (bswap) {
@@ -809,7 +813,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, data_reg = r1; }/* movl */ -tcg_out_modrm_offset (s,0x89 , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x89 , data_reg, r0,GUEST_BASE );break ;case 3 :if (bswap) {
@@ -819,7 +823,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, data_reg = r1; }/* movq */ -tcg_out_modrm_offset (s,0x89 |P_REXW , data_reg, r0,0 ); +tcg_out_modrm_offset (s,0x89 |P_REXW , data_reg, r0,GUEST_BASE );break ;default :tcg_abort ();
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 06/21] Revived GUEST_BASE support for usermode emulation targets [v5]
Quoted 14 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Mika Westerberg <[email protected]>
From: Mika Westerberg <[email protected]>
- Now
GUEST_BASEis dynamic and can be set from command line.
- Qemu checks/proc/sys/vm/mmap_min_addrand setsGUEST_BASEif needed.
- Code generation supportsGUEST_BASEfor i386 andx86_64hosts.[v3]: implemented
GUEST_BASEwith offset modsUsing malc's advice, instead of a mov or lea, just adjust the offset parameter of
tcg_out_modrm_offset(). - Riku
Quoted 7 lines
[v5]: set a
GUEST_BASE_MAXinstead of supporting moving to arbitary rangesFrom: Mika Westerberg <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
There are two From lines in the beginning, I don't know if Git eats all of them.
PATCH 7/21 linux-user: fix utimensat
In reply to [email protected]From: Riku Voipio <[email protected]>
The glibc function for utimensat glibc returns -EINVAL when the path is null which is a different behaviour with the syscall.
path can be null because internally the glibc is using utimensat with path null when implmenting futimens. If path is null, call futimes instead.
don't try to copy timespec from user if is NULL.
Add configure check for older systems
--- configure | 22 ++++++++++++++++++++++ linux-user/syscall.c | 38 ++++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 14 deletions(-)
configure +22 -0
@@ -1281,6 +1281,25 @@ EOF fi fi +# check if utimensat and futimens are supported +utimens=no +cat > $TMPC << EOF +#define _ATFILE_SOURCE +#define _GNU_SOURCE +#include <stddef.h> +#include <fcntl.h> + +int main(void) +{ + utimensat(AT_FDCWD, "foo", NULL, 0); + futimens(0, NULL); + return 0; +} +EOF +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + utimens=yes +fi + # Check if tools are available to build documentation. if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then build_docs="no"
@@ -1679,6 +1698,9 @@ fi if test "$atfile" = "yes" ; then echo "#define CONFIG_ATFILE 1" >> $config_h fi +if test "$utimens" = "yes" ; then + echo "#define CONFIG_UTIMENSAT 1" >> $config_h +fi if test "$inotify" = "yes" ; then echo "#define CONFIG_INOTIFY 1" >> $config_h fi
linux-user/syscall.c +24 -14
@@ -406,13 +406,6 @@ static int sys_unlinkat(int dirfd, const char *pathname, int flags) return (unlinkat(dirfd, pathname, flags)); }#endif -#ifdef TARGET_NR_utimensat -static int sys_utimensat (int dirfd,const char *pathname, -const struct timespec times[2 ],int flags) -{ -return (utimensat (dirfd, pathname, times, flags)); -} -#endif #else /* !CONFIG_ATFILE */ /*
@@ -471,12 +464,24 @@ _syscall3(int,sys_symlinkat,const char *,oldpath,#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) _syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags)#endif + +#endif /* CONFIG_ATFILE */ + +#ifdef CONFIG_UTIMENSAT +static int sys_utimensat (int dirfd,const char *pathname, +const struct timespec times[2 ],int flags) +{ +if (pathname ==NULL ) +return futimens (dirfd, times); +else +return utimensat (dirfd, pathname, times, flags); +} +#else #if defined(TARGET_NR_utimensat) && defined(__NR_utimensat) _syscall4(int,sys_utimensat,int,dirfd,const char *,pathname, const struct timespec *,tsp,int,flags)#endif - -#endif /* CONFIG_ATFILE */ +#endif /* CONFIG_UTIMENSAT */ #ifdef CONFIG_INOTIFY #include <sys/inotify.h>
@@ -6669,17 +6674,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)case TARGET_NR_utimensat: { -struct timespec ts[2 ]; -target_to_host_timespec (ts, arg3); -target_to_host_timespec (ts+1 , arg3+sizeof (struct target_timespec )); +struct timespec *tsp, ts[2 ]; +if (!arg3) { + tsp =NULL ; + }else { +target_to_host_timespec (ts, arg3); +target_to_host_timespec (ts+1 , arg3+sizeof (struct target_timespec )); + tsp = ts; + }if (!arg2) - ret =get_errno (sys_utimensat (arg1,NULL , ts, arg4)); + ret =get_errno (sys_utimensat (arg1,NULL , tsp, arg4));else {if (!(p =lock_user_string (arg2))) { ret = -TARGET_EFAULT ; goto fail; } - ret =get_errno (sys_utimensat (arg1,path (p), ts, arg4)); + ret =get_errno (sys_utimensat (arg1,path (p), tsp, arg4));unlock_user (p, arg2,0 ); } }
Signature · 1 line
1.6.2.1
PATCH 8/21 Fix struct termios host - target translation
In reply to [email protected]From: Arnaud Patard <[email protected]>
When converting the termios structure between host and target in target_to_host_termios and host_to_target_termios, the c_cc[] array is never initialised.
Calling memset() before using it allows to run successfully "stty echo / stty -echo" on arm-linux-user target (host being x86 and mips).
From: Arnaud Patard <[email protected]>
--- linux-user/syscall.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
linux-user/syscall.c +2 -0
@@ -2977,6 +2977,7 @@ static void target_to_host_termios (void *dst, const void *src)target_to_host_bitmask (tswap32 (target->c_lflag), lflag_tbl); host->c_line = target->c_line; +memset (host->c_cc,0 ,sizeof (host->c_cc)); host->c_cc[VINTR ] = target->c_cc[TARGET_VINTR ]; host->c_cc[VQUIT ] = target->c_cc[TARGET_VQUIT ]; host->c_cc[VERASE ] = target->c_cc[TARGET_VERASE ];
@@ -3011,6 +3012,7 @@ static void host_to_target_termios (void *dst, const void *src)tswap32 (host_to_target_bitmask (host->c_lflag, lflag_tbl)); target->c_line = host->c_line; +memset (target->c_cc,0 ,sizeof (target->c_cc)); target->c_cc[TARGET_VINTR ] = host->c_cc[VINTR ]; target->c_cc[TARGET_VQUIT ] = host->c_cc[VQUIT ]; target->c_cc[TARGET_VERASE ] = host->c_cc[VERASE ];
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 08/21] Fix struct termios host - target translation
Quoted 12 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Arnaud Patard <[email protected]>
When converting the termios structure between host and target in
target_to_host_termiosandhost_to_target_termios, the c_cc[] array is never initialised.
Callingmemset()before using it allows to run successfully "stty echo / stty -echo" on arm-linux-user target (host being x86 and mips).From: Arnaud Patard <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
Re: [Qemu-devel] [PATCH 08/21] Fix struct termios host - target translation
Quoted 9 lines · Blue Swirl
Quoted 8 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Arnaud Patard <[email protected]>
When converting the termios structure between host and target in
target_to_host_termiosandhost_to_target_termios, the c_cc[] array is never initialised.
Callingmemset()before using it allows to run successfully "stty echo / stty -echo" on arm-linux-user target (host being x86 and mips).
Quoted 4 lines
Quoted 4 lines
From: Arnaud Patard <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
Arnaud, can you send your Signed-Off-By: for the patches you have sent?
Re: [Qemu-devel] [PATCH 08/21] Fix struct termios host - target translation
Riku Voipio <[email protected]> writes:
Hi,
Quoted 10 lines · Blue Swirl
Quoted 9 lines · On 6/12/09, [email protected] <[email protected]> wrote:
Quoted 8 lines
From: Arnaud Patard <[email protected]>
When converting the termios structure between host and target in
target_to_host_termiosandhost_to_target_termios, the c_cc[] array is never initialised.
Callingmemset()before using it allows to run successfully "stty echo / stty -echo" on arm-linux-user target (host being x86 and mips).
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
From: Arnaud Patard <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
Arnaud, can you send your Signed-Off-By: for the patches you have sent?
Also, do you want me to reply to all your mails with the patches I've sent or adding my SOB here is enough for all ?
Arnaud
Re: [Qemu-devel] [PATCH 08/21] Fix struct termios host - target translation
Quoted 16 lines · Arnaud Patard
Riku Voipio <[email protected]> writes:
Hi,Quoted 13 lines · Blue Swirl
Quoted 11 lines · On 6/12/09, [email protected] <[email protected]> wrote:
Quoted 10 lines
From: Arnaud Patard <[email protected]>
When converting the termios structure between host and target in
target_to_host_termiosandhost_to_target_termios, the c_cc[] array is never initialised.
Callingmemset()before using it allows to run successfully "stty echo / stty -echo" on arm-linux-user target (host being x86 and mips).From: Arnaud Patard <[email protected]>
Signed-off-by Riku Voipio <[email protected]>
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
From != SOB.
Arnaud, can you send your Signed-Off-By: for the patches you have sent?
Signed-off-by Arnaud Patard <[email protected]>Also, do you want me to reply to all your mails with the patches I've sent or adding my SOB here is enough for all ?
If you say this Signed-off-by: is covers all the patches in the series, it is enough for me. If you want to be pedantic, you can reply to all of them.
Re: [Qemu-devel] [PATCH 08/21] Fix struct termios host - target translation
Quoted 21 lines · Riku Voipio
Quoted 19 lines · Arnaud Patard
Riku Voipio <[email protected]> writes:
Hi,Quoted 16 lines · Blue Swirl
Quoted 9 lines · On 6/12/09, [email protected] <[email protected]> wrote:
Quoted 8 lines
From: Arnaud Patard <[email protected]>
When converting the termios structure between host and target in
target_to_host_termiosandhost_to_target_termios, the c_cc[] array is never initialised.
Callingmemset()before using it allows to run successfully "stty echo / stty -echo" on arm-linux-user target (host being x86 and mips).Quoted 4 lines
Quoted 4 lines
From: Arnaud Patard <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
Arnaud, can you send your Signed-Off-By: for the patches you have sent?
Quoted 8 lines
Quoted 4 lines
Signed-off-by Arnaud Patard <[email protected]>Also, do you want me to reply to all your mails with the patches I've sent or adding my SOB here is enough for all ?
If you say this Signed-off-by: is covers all the patches in the series, it is enough for me. If you want to be pedantic, you can reply to all of them.
well, I wanted to avoid going through the mails and replying to them so if saying that is enough, well... it's ok. This SOB applies to all of them :)
Arnaud
PATCH 9/21 Return EOPNOTSUPP instead of ENOSYS for *xattr* syscalls
In reply to [email protected]From: Arnaud Patard <[email protected]>
In current code, we're sending ENOSYS to target when a syscall for the xattrs is done. This makes applications like ls complain loudly about that and breaks scripts parsing the output. Moreover, iirc, implemented features of filesystems are are sending EOPNOTSUPP (I've not checked so I may be a little bit wrong on that...).
So, I'm proposing to return -EOPNOTSUPP and make ls happy
From: Arnaud Patard <[email protected]>
--- linux-user/syscall.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
linux-user/syscall.c +2 -1
@@ -6579,7 +6579,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_removexattr:case TARGET_NR_lremovexattr:case TARGET_NR_fremovexattr: - goto unimplemented_nowarn; + ret = -TARGET_EOPNOTSUPP ; +break ;#endif #ifdef TARGET_NR_set_thread_areacase TARGET_NR_set_thread_area:
Signature · 1 line
1.6.2.1
PATCH 10/21 linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
In reply to [email protected]From: Lionel Landwerlin <[email protected]>
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
From: Lionel Landwerlin <[email protected]>
--- linux-user/syscall.c | 30 ++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 15 +++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-)
linux-user/syscall.c +30 -0
@@ -943,6 +943,24 @@ static abi_long do_select(int n,return ret; } +static inline abi_long target_to_host_ip_mreq (struct ip_mreqn *mreqn, +abi_ulong target_addr, +socklen_t len) +{ +struct target_ip_mreqn *target_smreqn; + + target_smreqn =lock_user (VERIFY_READ , target_addr, len,1 ); +if (!target_smreqn) +return -TARGET_EFAULT ; + mreqn->imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; + mreqn->imr_address.s_addr = target_smreqn->imr_address.s_addr; +if (len ==sizeof (struct target_ip_mreqn )) + mreqn->imr_ifindex =tswapl (target_smreqn->imr_ifindex); +unlock_user (target_smreqn, target_addr,0 ); + +return 0 ; +} +static inline abi_long target_to_host_sockaddr (struct sockaddr *addr,abi_ulong target_addr,socklen_t len)
@@ -1118,6 +1136,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, {abi_long ret;int val; +struct ip_mreqn *ip_mreq;switch (level) {case SOL_TCP :
@@ -1156,6 +1175,17 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, } ret =get_errno (setsockopt (sockfd, level, optname, &val,sizeof (val)));break ; +case IP_ADD_MEMBERSHIP : +case IP_DROP_MEMBERSHIP : +if (optlen <sizeof (struct target_ip_mreq ) || + optlen >sizeof (struct target_ip_mreqn )) +return -TARGET_EINVAL ; + + ip_mreq = (struct ip_mreqn *)alloca (optlen); +target_to_host_ip_mreq (ip_mreq, optval_addr, optlen); + ret =get_errno (setsockopt (sockfd, level, optname, ip_mreq, optlen)); +break ; +default : goto unimplemented; }
linux-user/syscall_defs.h +15 -0
@@ -111,6 +111,21 @@ struct target_sockaddr {uint8_t sa_data[14 ]; }; +struct target_in_addr { +uint32_t s_addr;/* big endian */ +}; + +struct target_ip_mreq { +struct target_in_addr imr_multiaddr; +struct target_in_addr imr_address; +}; + +struct target_ip_mreqn { +struct target_in_addr imr_multiaddr; +struct target_in_addr imr_address; +abi_long imr_ifindex; +}; +struct target_timeval {abi_long tv_sec;abi_long tv_usec;
Signature · 1 line
1.6.2.1
PATCH 11/21 linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP flags to setsockopt
In reply to [email protected]From: Lionel Landwerlin <[email protected]>
linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP flags to setsockopt
From: Lionel Landwerlin <[email protected]>
--- linux-user/syscall.c | 13 +++++++++++++ linux-user/syscall_defs.h | 7 +++++++ 2 files changed, 20 insertions(+), 0 deletions(-)
linux-user/syscall.c +13 -0
@@ -1137,6 +1137,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,abi_long ret;int val;struct ip_mreqn *ip_mreq; +struct ip_mreq_source *ip_mreq_source;switch (level) {case SOL_TCP :
@@ -1186,6 +1187,18 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, ret =get_errno (setsockopt (sockfd, level, optname, ip_mreq, optlen));break ; +case IP_BLOCK_SOURCE : +case IP_UNBLOCK_SOURCE : +case IP_ADD_SOURCE_MEMBERSHIP : +case IP_DROP_SOURCE_MEMBERSHIP : +if (optlen !=sizeof (struct target_ip_mreq_source )) +return -TARGET_EINVAL ; + + ip_mreq_source =lock_user (VERIFY_READ , optval_addr, optlen,1 ); + ret =get_errno (setsockopt (sockfd, level, optname, ip_mreq_source, optlen)); +unlock_user (ip_mreq_source, optval_addr,0 ); +break ; +default : goto unimplemented; }
linux-user/syscall_defs.h +7 -0
@@ -126,6 +126,13 @@ struct target_ip_mreqn {abi_long imr_ifindex; }; +struct target_ip_mreq_source { +/* big endian */ +uint32_t imr_multiaddr; +uint32_t imr_interface; +uint32_t imr_sourceaddr; +}; +struct target_timeval {abi_long tv_sec;abi_long tv_usec;
Signature · 1 line
1.6.2.1
PATCH 12/21 linux-user: include linux/fs.h
In reply to [email protected]From: Martin Mohring <[email protected]>
defines FIGETBSZ FIBMAP, allowing the respective ioctl's to be implemented.
From: Martin Mohring <[email protected]>
--- linux-user/syscall.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
linux-user/syscall.c +1 -0
@@ -77,6 +77,7 @@#include <linux/soundcard.h> #include <linux/kd.h> #include <linux/mtio.h> +#include <linux/fs.h> #include "linux_loop.h" #include "qemu.h"
Signature · 1 line
1.6.2.1
PATCH 13/21 linux-user: support private futexes
In reply to [email protected]From: Martin Mohring <[email protected]>
Implemented the same way as in the kernel.
From: Martin Mohring <[email protected]>
--- linux-user/syscall.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-)
linux-user/syscall.c +9 -5
@@ -3926,7 +3926,11 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,/* ??? We assume FUTEX_* constants are the same on both host and target. */ +#ifdef FUTEX_CMD_MASK +switch ((op&FUTEX_CMD_MASK )) { +#else switch (op) { +#endif case FUTEX_WAIT :if (timeout) { pts = &ts;
@@ -3934,17 +3938,17 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, }else { pts =NULL ; } -return get_errno (sys_futex (g2h (uaddr),FUTEX_WAIT ,tswap32 (val), +return get_errno (sys_futex (g2h (uaddr), op,tswap32 (val), pts,NULL ,0 ));case FUTEX_WAKE : -return get_errno (sys_futex (g2h (uaddr),FUTEX_WAKE , val,NULL ,NULL ,0 )); +return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,NULL ,0 ));case FUTEX_FD : -return get_errno (sys_futex (g2h (uaddr),FUTEX_FD , val,NULL ,NULL ,0 )); +return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,NULL ,0 ));case FUTEX_REQUEUE : -return get_errno (sys_futex (g2h (uaddr),FUTEX_REQUEUE , val, +return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,g2h (uaddr2),0 ));case FUTEX_CMP_REQUEUE : -return get_errno (sys_futex (g2h (uaddr),FUTEX_CMP_REQUEUE , val, +return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,g2h (uaddr2),tswap32 (val3)));default :return -TARGET_ENOSYS ;
Signature · 1 line
1.6.2.1
PATCH 14/21 add futex wake op
In reply to [email protected]From: Riku Voipio <[email protected]>
--- linux-user/syscall.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
linux-user/syscall.c +2 -0
@@ -3942,6 +3942,8 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, pts, NULL, 0));case FUTEX_WAKE :return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,NULL ,0 )); +case FUTEX_WAKE_OP : +return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,g2h (uaddr2), val3 ));case FUTEX_FD :return get_errno (sys_futex (g2h (uaddr), op, val,NULL ,NULL ,0 ));case FUTEX_REQUEUE :
Signature · 1 line
1.6.2.1
PATCH 15/21 linux-user: update syscall list
In reply to [email protected]From: Riku Voipio <[email protected]>
In preparation for supporting pipe2()
--- linux-user/arm/syscall_nr.h | 9 +++++++++ linux-user/i386/syscall_nr.h | 8 ++++++++ linux-user/m68k/syscall_nr.h | 8 ++++++++ linux-user/mips/syscall_nr.h | 9 +++++++++ linux-user/mips64/syscall_nr.h | 9 +++++++++ linux-user/mipsn32/syscall_nr.h | 9 +++++++++ linux-user/ppc/syscall_nr.h | 9 +++++++++ linux-user/sh4/syscall_nr.h | 8 ++++++++ linux-user/sparc/syscall_nr.h | 9 +++++++++ linux-user/sparc64/syscall_nr.h | 9 +++++++++ linux-user/x86_64/syscall_nr.h | 9 +++++++++ 11 files changed, 96 insertions(+), 0 deletions(-)
linux-user/arm/syscall_nr.h +9 -0
@@ -356,3 +356,12 @@#define TARGET_NR_signalfd (349)#define TARGET_NR_timerfd (350)#define TARGET_NR_eventfd (351) +#define TARGET_NR_fallocate (352) +#define TARGET_NR_timerfd_settime (353) +#define TARGET_NR_timerfd_gettime (354) +#define TARGET_NR_signalfd4 (355) +#define TARGET_NR_eventfd2 (356) +#define TARGET_NR_epoll_create1 (357) +#define TARGET_NR_dup3 (358) +#define TARGET_NR_pipe2 (359) +#define TARGET_NR_inotify_init1 (360)
linux-user/i386/syscall_nr.h +8 -0
@@ -327,3 +327,11 @@#define TARGET_NR_timerfd 322#define TARGET_NR_eventfd 323#define TARGET_NR_fallocate 324 +#define TARGET_NR_timerfd_settime 325 +#define TARGET_NR_timerfd_gettime 326 +#define TARGET_NR_signalfd4 327 +#define TARGET_NR_eventfd2 328 +#define TARGET_NR_epoll_create1 329 +#define TARGET_NR_dup3 330 +#define TARGET_NR_pipe2 331 +#define TARGET_NR_inotify_init1 332
linux-user/m68k/syscall_nr.h +8 -0
@@ -320,3 +320,11 @@#define TARGET_NR_timerfd 318#define TARGET_NR_eventfd 319#define TARGET_NR_fallocate 320 +#define TARGET_NR_timerfd_settime 321 +#define TARGET_NR_timerfd_gettime 322 +#define TARGET_NR_signalfd4 323 +#define TARGET_NR_eventfd2 324 +#define TARGET_NR_epoll_create1 325 +#define TARGET_NR_dup3 326 +#define TARGET_NR_pipe2 327 +#define TARGET_NR_inotify_init1 328
linux-user/mips/syscall_nr.h +9 -0
@@ -323,3 +323,12 @@#define TARGET_NR_timerfd (TARGET_NR_Linux + 318)#define TARGET_NR_eventfd (TARGET_NR_Linux + 319)#define TARGET_NR_fallocate (TARGET_NR_Linux + 320) +#define TARGET_NR_timerfd_create (TARGET_NR_Linux + 321) +#define TARGET_NR_timerfd_gettime (TARGET_NR_Linux + 322) +#define TARGET_NR_timerfd_settime (TARGET_NR_Linux + 323) +#define TARGET_NR_signalfd4 (TARGET_NR_Linux + 324) +#define TARGET_NR_eventfd2 (TARGET_NR_Linux + 325) +#define TARGET_NR_epoll_create1 (TARGET_NR_Linux + 326) +#define TARGET_NR_dup3 (TARGET_NR_Linux + 327) +#define TARGET_NR_pipe2 (TARGET_NR_Linux + 328) +#define TARGET_NR_inotify_init1 (TARGET_NR_Linux + 329)
linux-user/mips64/syscall_nr.h +9 -0
@@ -282,3 +282,12 @@#define TARGET_NR_timerfd (TARGET_NR_Linux + 277)#define TARGET_NR_eventfd (TARGET_NR_Linux + 278)#define TARGET_NR_fallocate (TARGET_NR_Linux + 279) +#define TARGET_NR_timerfd_create (TARGET_NR_Linux + 280) +#define TARGET_NR_timerfd_gettime (TARGET_NR_Linux + 281) +#define TARGET_NR_timerfd_settime (TARGET_NR_Linux + 282) +#define TARGET_NR_signalfd4 (TARGET_NR_Linux + 283) +#define TARGET_NR_eventfd2 (TARGET_NR_Linux + 284) +#define TARGET_NR_epoll_create1 (TARGET_NR_Linux + 285) +#define TARGET_NR_dup3 (TARGET_NR_Linux + 286) +#define TARGET_NR_pipe2 (TARGET_NR_Linux + 287) +#define TARGET_NR_inotify_init1 (TARGET_NR_Linux + 288)
linux-user/mipsn32/syscall_nr.h +9 -0
@@ -286,3 +286,12 @@#define TARGET_NR_timerfd (TARGET_NR_Linux + 281)#define TARGET_NR_eventfd (TARGET_NR_Linux + 282)#define TARGET_NR_fallocate (TARGET_NR_Linux + 283) +#define TARGET_NR_timerfd_create (TARGET_NR_Linux + 284) +#define TARGET_NR_timerfd_gettime (TARGET_NR_Linux + 285) +#define TARGET_NR_timerfd_settime (TARGET_NR_Linux + 286) +#define TARGET_NR_signalfd4 (TARGET_NR_Linux + 287) +#define TARGET_NR_eventfd2 (TARGET_NR_Linux + 288) +#define TARGET_NR_epoll_create1 (TARGET_NR_Linux + 289) +#define TARGET_NR_dup3 (TARGET_NR_Linux + 290) +#define TARGET_NR_pipe2 (TARGET_NR_Linux + 291) +#define TARGET_NR_inotify_init1 (TARGET_NR_Linux + 292)
linux-user/ppc/syscall_nr.h +9 -0
@@ -323,3 +323,12 @@#define TARGET_NR_eventfd 307#define TARGET_NR_sync_file_range2 308#define TARGET_NR_fallocate 309 +#define TARGET_NR_subpage_prot 310 +#define TARGET_NR_timerfd_settime 311 +#define TARGET_NR_timerfd_gettime 312 +#define TARGET_NR_signalfd4 313 +#define TARGET_NR_eventfd2 314 +#define TARGET_NR_epoll_create1 315 +#define TARGET_NR_dup3 316 +#define TARGET_NR_pipe2 317 +#define TARGET_NR_inotify_init1 318
linux-user/sh4/syscall_nr.h +8 -0
@@ -326,3 +326,11 @@#define TARGET_NR_timerfd 322#define TARGET_NR_eventfd 323#define TARGET_NR_fallocate 324 +#define TARGET_NR_timerfd_settime 325 +#define TARGET_NR_timerfd_gettime 326 +#define TARGET_NR_signalfd4 327 +#define TARGET_NR_eventfd2 328 +#define TARGET_NR_epoll_create1 329 +#define TARGET_NR_dup3 330 +#define TARGET_NR_pipe2 331 +#define TARGET_NR_inotify_init1 332
linux-user/sparc/syscall_nr.h +9 -0
@@ -276,3 +276,12 @@#define TARGET_NR_timerfd 312#define TARGET_NR_eventfd 313#define TARGET_NR_fallocate 314 +#define TARGET_NR_timerfd_settime 315 +#define TARGET_NR_timerfd_gettime 316 +#define TARGET_NR_signalfd4 317 +#define TARGET_NR_eventfd2 318 +#define TARGET_NR_epoll_create1 319 +#define TARGET_NR_dup3 320 +#define TARGET_NR_pipe2 321 +#define TARGET_NR_inotify_init1 322 +#define TARGET_NR_accept4 323
linux-user/sparc64/syscall_nr.h +9 -0
@@ -313,3 +313,12 @@#define TARGET_NR_timerfd 312#define TARGET_NR_eventfd 313#define TARGET_NR_fallocate 314 +#define TARGET_NR_timerfd_settime 315 +#define TARGET_NR_timerfd_gettime 316 +#define TARGET_NR_signalfd4 317 +#define TARGET_NR_eventfd2 318 +#define TARGET_NR_epoll_create1 319 +#define TARGET_NR_dup3 320 +#define TARGET_NR_pipe2 321 +#define TARGET_NR_inotify_init1 322 +#define TARGET_NR_accept4 323
linux-user/x86_64/syscall_nr.h +9 -0
@@ -284,3 +284,12 @@#define TARGET_NR_timerfd 283#define TARGET_NR_eventfd 284#define TARGET_NR_fallocate 285 +#define TARGET_NR_timerfd_settime 286 +#define TARGET_NR_timerfd_gettime 287 +#define TARGET_NR_accept4 288 +#define TARGET_NR_signalfd4 289 +#define TARGET_NR_eventfd2 290 +#define TARGET_NR_epoll_create1 291 +#define TARGET_NR_dup3 292 +#define TARGET_NR_pipe2 293 +#define TARGET_NR_inotify_init1 294
Signature · 1 line
1.6.2.1
PATCH 16/21 linux-user: implement pipe2 [v3]
In reply to [email protected]From: Riku Voipio <[email protected]>
implement pipe2 syscall.
[v2] fix do_pipe on mips and sh4
[v3] use pipe2 to ensure atomicity, but only when it is available.
--- configure | 21 +++++++++++++++++++ linux-user/syscall.c | 55 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 58 insertions(+), 18 deletions(-)
configure +21 -0
@@ -1300,6 +1300,24 @@ if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then utimens=yes fi +# check if pipe2 is there +pipe2=no +cat > $TMPC << EOF +#define _GNU_SOURCE +#include <unistd.h> +#include <fcntl.h> + +int main(void) +{ + int pipefd[2]; + pipe2(pipefd, O_CLOEXEC); + return 0; +} +EOF +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + pipe2=yes +fi + # Check if tools are available to build documentation. if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then build_docs="no"
@@ -1701,6 +1719,9 @@ fi if test "$utimens" = "yes" ; then echo "#define CONFIG_UTIMENSAT 1" >> $config_h fi +if test "$pipe2" = "yes" ; then + echo "#define CONFIG_PIPE2 1" >> $config_h +fi if test "$inotify" = "yes" ; then echo "#define CONFIG_INOTIFY 1" >> $config_h fi
linux-user/syscall.c +37 -18
68 lines not on this page · raw message
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 16/21] linux-user: implement pipe2 [v3]
Quoted 4 lines · On Fri, Jun 12, 2009 at 04:50:26PM +0300, [email protected] wrote:
linux-user/syscall.c +4
-0+static abi_long do_pipe2 (int host_pipe[],int flags) +{ +#ifdef CONFIG_PIPE2 +return pipe2 (host_pipe, flags);
linux-user/syscall.c static abi_long do_select(int n, · line 960
Quoted 10 lines
linux-user/syscall.c +10
-0+#else +return -ENOSYS ; +#endif +} + +static abi_long do_pipe (void *cpu_env,int pipedes,int flags) +{ +int host_pipe[2 ]; +abi_long ret; + ret = flags ?do_pipe2 (host_pipe, flags) :pipe (host_pipe);
This worries me slightly -- surely syscalls should be consistently supported / not supported (where feasible), regardless of the precise arguments that are supplied? (Otherwise, any run-time check for pipe2 would get tricked if that check specifies 0 for flags.)
OTOH, I'm not sure what behaviour the library would provide for the pipe2() function, if the pipe2 syscall is not available. One could that the pipe2() function is another matter entirely, and that QEMU shouldn't be too concerned with its implementation, though.
Cheers,
Signature · 1 line
Stuart Brady
Re: [Qemu-devel] [PATCH 16/21] linux-user: implement pipe2 [v3]
Quoted 21 lines · Stuart Brady
Quoted 4 lines · On Fri, Jun 12, 2009 at 04:50:26PM +0300, [email protected] wrote:
linux-user/syscall.c +4
-0+static abi_long do_pipe2 (int host_pipe[],int flags) +{ +#ifdef CONFIG_PIPE2 +return pipe2 (host_pipe, flags);linux-user/syscall.c static abi_long do_select(int n, · line 960
Quoted 10 lines
linux-user/syscall.c +10
-0+#else +return -ENOSYS ; +#endif +} + +static abi_long do_pipe (void *cpu_env,int pipedes,int flags) +{ +int host_pipe[2 ]; +abi_long ret; + ret = flags ?do_pipe2 (host_pipe, flags) :pipe (host_pipe);This worries me slightly -- surely syscalls should be consistently supported / not supported (where feasible), regardless of the precise arguments that are supplied? (Otherwise, any run-time check for pipe2 would get tricked if that check specifies 0 for flags.)
Quoted 4 lines
OTOH, I'm not sure what behaviour the library would provide for the
pipe2()function, if the pipe2 syscall is not available. One could that thepipe2()function is another matter entirely, and that QEMU shouldn't be too concerned with its implementation, though.
As I've explained elsewhere, it is possible to emulate pipe2() and all the other tricksy *CLOEXEC syscalls, but it must be done carefully to provide the expected guarantees.
-- Jamie
PATCH 17/21 linux-user: add tee, splice and vmsplice
In reply to [email protected]From: vibisreenivasan <[email protected]>
Add support for tee, splice and vmsplice.
Originally from: vibi sreenivasan <[email protected]>
Riku: squashed patches together and added a test to configure
From: vibisreenivasan <[email protected]>
--- configure | 23 +++++++++++++++++++++++ linux-user/syscall.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 0 deletions(-)
configure +23 -0
@@ -1318,6 +1318,26 @@ if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then pipe2=yes fi +# check if tee/splice is there. vmsplice was added same time. +splice=no +cat > $TMPC << EOF +#define _GNU_SOURCE +#include <unistd.h> +#include <fcntl.h> +#include <limits.h> + +int main(void) +{ + int len, fd; + len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK); + splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE); + return 0; +} +EOF +if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then + splice=yes +fi + # Check if tools are available to build documentation. if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then build_docs="no"
@@ -1722,6 +1742,9 @@ fi if test "$pipe2" = "yes" ; then echo "#define CONFIG_PIPE2 1" >> $config_h fi +if test "$splice" = "yes" ; then + echo "#define CONFIG_SPLICE 1" >> $config_h +fi if test "$inotify" = "yes" ; then echo "#define CONFIG_INOTIFY 1" >> $config_h fi
linux-user/syscall.c +40 -0
@@ -6865,6 +6865,46 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ;#endif +#ifdef CONFIG_SPLICE +#ifdef TARGET_NR_tee +case TARGET_NR_tee: + { + ret =get_errno (tee (arg1,arg2,arg3,arg4)); + } +break ; +#endif +#ifdef TARGET_NR_splice +case TARGET_NR_splice: + { +long long int loff_in, loff_out; +long long int *ploff_in =NULL , *ploff_out =NULL ; +if (arg2) { +get_user_u64 (loff_in, arg2); + ploff_in = &loff_in; + } +if (arg4) { +get_user_u64 (loff_out, arg2); + ploff_out = &loff_out; + } + ret =get_errno (splice (arg1, ploff_in, arg3, ploff_out, arg5, arg6)); + } +break ; +#endif +#ifdef TARGET_NR_vmsplice +case TARGET_NR_vmsplice: + { +int count = arg3; +struct iovec *vec; + + vec =alloca (count *sizeof (struct iovec )); +if (lock_iovec (VERIFY_READ , vec, arg2, count,1 ) <0 ) + goto efault; + ret =get_errno (vmsplice (arg1, vec, count, arg4)); +unlock_iovec (vec, arg2, count,0 ); + } +break ; +#endif +#endif /* CONFIG_SPLICE */ default : unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num);
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 17/21] linux-user: add tee, splice and vmsplice
Quoted 4 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: vibisreenivasan <[email protected]>
Add support for tee, splice and vmsplice.
Quoted 8 lines
Originally from: vibi sreenivasan <[email protected]>
Riku: squashed patches together and added a test to configure
From: vibisreenivasan <[email protected]>
Signed-off-by Riku Voipio <[email protected]>From != SOB.
Also, I get this warning (which is now an error):
CC i386-linux-user/syscall.o
cc1: warnings being treated as errors /src/qemu/linux-user/syscall.c: In function 'do_syscall':
/src/qemu/linux-user/syscall.c:6927: error: passing argument 2 of 'splice' from incompatible pointer type /src/qemu/linux-user/syscall.c:6927: error: passing argument 4 of 'splice' from incompatible pointer type
make[1]: *** [syscall.o] Error 1
PATCH 18/21 RFC: fix fcntl support in linux-user - new try
In reply to [email protected]From: Arnaud Patard (Rtp) <[email protected]>
Hi,
This is a new try to fix the fcntl support in linux-user. I tried to adress all comments but as the previous version is several weeks old, it's possible that I've missed some.
This patch doesn't handle linux specific fcntl flags. My plan is to get this version of the patch reviewed/fixed and then, add them if wanted.
Thanks,
Arnaud
From: Arnaud Patard (Rtp) <[email protected]>
--- linux-user/syscall.c | 84 ++++++++++++++++++++++++++++++++------------ linux-user/syscall_defs.h | 13 ++++++- 2 files changed, 73 insertions(+), 24 deletions(-)
linux-user/syscall.c +61 -23
@@ -3622,6 +3622,44 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,return ret; } +/* warning : doesn't handle linux specific flags... */ +static int target_to_host_fcntl_cmd (int cmd) +{ +switch (cmd) { +case TARGET_F_DUPFD : +case TARGET_F_GETFD : +case TARGET_F_SETFD : +case TARGET_F_GETFL : +case TARGET_F_SETFL : +return cmd; +case TARGET_F_GETLK : +return F_GETLK ; +case TARGET_F_SETLK : +return F_SETLK ; +case TARGET_F_SETLKW : +return F_SETLKW ; +case TARGET_F_GETOWN : +return F_GETOWN ; +case TARGET_F_SETOWN : +return F_SETOWN ; +case TARGET_F_GETSIG : +return F_GETSIG ; +case TARGET_F_SETSIG : +return F_SETSIG ; +#if TARGET_ABI_BITS ==32 +case TARGET_F_GETLK64 : +return F_GETLK64 ; +case TARGET_F_SETLK64 : +return F_SETLK64 ; +case TARGET_F_SETLKW64 : +return F_SETLKW64 ; +#endif +default : +return -TARGET_EINVAL ; + } +return -TARGET_EINVAL ; +} +static abi_long do_fcntl (int fd,int cmd,abi_ulong arg) {struct flock fl;
@@ -3629,6 +3667,10 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)struct flock64 fl64;struct target_flock64 *target_fl64;abi_long ret; +int host_cmd =target_to_host_fcntl_cmd (cmd); + +if (host_cmd == -TARGET_EINVAL ) +return host_cmd;switch (cmd) {case TARGET_F_GETLK :
@@ -3640,7 +3682,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) fl.l_len =tswapl (target_fl->l_len); fl.l_pid =tswapl (target_fl->l_pid);unlock_user_struct (target_fl, arg,0 ); - ret =get_errno (fcntl (fd, cmd, &fl)); + ret =get_errno (fcntl (fd, host_cmd, &fl));if (ret ==0 ) {if (!lock_user_struct (VERIFY_WRITE , target_fl, arg,0 ))return -TARGET_EFAULT ;
@@ -3663,7 +3705,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) fl.l_len =tswapl (target_fl->l_len); fl.l_pid =tswapl (target_fl->l_pid);unlock_user_struct (target_fl, arg,0 ); - ret =get_errno (fcntl (fd, cmd, &fl)); + ret =get_errno (fcntl (fd, host_cmd, &fl));break ;case TARGET_F_GETLK64 :
@@ -3675,7 +3717,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) fl64.l_len =tswapl (target_fl64->l_len); fl64.l_pid =tswap16 (target_fl64->l_pid);unlock_user_struct (target_fl64, arg,0 ); - ret =get_errno (fcntl (fd, cmd >>1 , &fl64)); + ret =get_errno (fcntl (fd, host_cmd, &fl64));if (ret ==0 ) {if (!lock_user_struct (VERIFY_WRITE , target_fl64, arg,0 ))return -TARGET_EFAULT ;
@@ -3697,18 +3739,25 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) fl64.l_len =tswapl (target_fl64->l_len); fl64.l_pid =tswap16 (target_fl64->l_pid);unlock_user_struct (target_fl64, arg,0 ); - ret =get_errno (fcntl (fd, cmd >>1 , &fl64)); + ret =get_errno (fcntl (fd, host_cmd, &fl64));break ; -case F_GETFL : - ret =get_errno (fcntl (fd, cmd, arg)); +case TARGET_F_GETFL : + ret =get_errno (fcntl (fd, host_cmd, arg));if (ret >=0 ) { ret =host_to_target_bitmask (ret, fcntl_flags_tbl); }break ; -case F_SETFL : - ret =get_errno (fcntl (fd, cmd,target_to_host_bitmask (arg, fcntl_flags_tbl))); +case TARGET_F_SETFL : + ret =get_errno (fcntl (fd, host_cmd,target_to_host_bitmask (arg, fcntl_flags_tbl))); +break ; + +case TARGET_F_SETOWN : +case TARGET_F_GETOWN : +case TARGET_F_SETSIG : +case TARGET_F_GETSIG : + ret =get_errno (fcntl (fd, host_cmd, arg));break ;default :
@@ -6501,20 +6550,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,struct target_eabi_flock64 *target_efl;#endif -switch (arg2){ -case TARGET_F_GETLK64 : - cmd =F_GETLK64 ; -break ; -case TARGET_F_SETLK64 : - cmd =F_SETLK64 ; -break ; -case TARGET_F_SETLKW64 : - cmd =F_SETLK64 ; -break ; -default : - cmd = arg2; -break ; - } + cmd =target_to_host_fcntl_cmd (arg2); +if (cmd == -TARGET_EINVAL ) +return cmd;switch (arg2) {case TARGET_F_GETLK64 :
@@ -6594,7 +6632,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =get_errno (fcntl (arg1, cmd, &fl));break ;default : - ret =do_fcntl (arg1, cmd, arg3); + ret =do_fcntl (arg1, arg2, arg3);break ; }break ;
linux-user/syscall_defs.h +12 -1
@@ -1745,6 +1745,12 @@ struct target_statfs64 {#define TARGET_F_SETLKW 9#define TARGET_F_SETOWN 5/* for sockets. */ #define TARGET_F_GETOWN 6/* for sockets. */ +#elif defined(TARGET_MIPS ) +#define TARGET_F_GETLK 14 +#define TARGET_F_SETLK 6 +#define TARGET_F_SETLKW 7 +#define TARGET_F_SETOWN 24/* for sockets. */ +#define TARGET_F_GETOWN 25/* for sockets. */ #else #define TARGET_F_GETLK 5#define TARGET_F_SETLK 6
@@ -1756,10 +1762,15 @@ struct target_statfs64 {#define TARGET_F_SETSIG 10/* for sockets. */ #define TARGET_F_GETSIG 11/* for sockets. */ +#if defined(TARGET_MIPS ) +#define TARGET_F_GETLK64 33/* using 'struct flock64' */ +#define TARGET_F_SETLK64 34 +#define TARGET_F_SETLKW64 35 +#else #define TARGET_F_GETLK64 12/* using 'struct flock64' */ #define TARGET_F_SETLK64 13#define TARGET_F_SETLKW64 14 - +#endif #if defined (TARGET_ARM )#define TARGET_O_ACCMODE 0003#define TARGET_O_RDONLY 00
Signature · 1 line
1.6.2.1
Re: [Qemu-devel] [PATCH 18/21] RFC: fix fcntl support in linux-user - new try
Quoted 8 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Arnaud Patard (Rtp) <[email protected]>
Hi,
This is a new try to fix the fcntl support in linux-user. I tried to adress all comments but as the previous version is several weeks old, it's possible that I've missed some.
Quoted 8 lines
This patch doesn't handle linux specific fcntl flags. My plan is to get this version of the patch reviewed/fixed and then, add them if wanted.
Thanks,
ArnaudFrom: Arnaud Patard (Rtp) <[email protected]>
Signed-off-by Riku Voipio <[email protected]>
I think SOB: Arnaud Patard is what is needed here.
PATCH 19/21 linux-user: initialize mmap_mutex properly
In reply to [email protected]From: Nathan Froyd <[email protected]>
We initialize mmap_mutex in any child threads/processes, but we need to correctly statically initialize it for the original process.
From: Nathan Froyd <[email protected]>
--- linux-user/mmap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
linux-user/mmap.c +1 -1
@@ -36,7 +36,7 @@//#define DEBUG_MMAP #if defined(USE_NPTL ) -pthread_mutex_t mmap_mutex; +pthread_mutex_t mmap_mutex =PTHREAD_MUTEX_INITIALIZER ;static int __thread mmap_lock_count;void mmap_lock (void )
Signature · 1 line
1.6.2.1
PATCH 20/21 linux-user/syscall.c: define _ATFILE_SOURCE
In reply to [email protected]From: Eduardo Habkost <[email protected]>
Needed to make sure the xxxat() functions are available.
From: Eduardo Habkost <[email protected]>
--- linux-user/syscall.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
linux-user/syscall.c +1 -0
@@ -18,6 +18,7 @@* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, * MA 02110-1301, USA. */ +#define _ATFILE_SOURCE#include <stdlib.h> #include <stdio.h> #include <stdarg.h>
Signature · 1 line
1.6.2.1
PATCH 21/21 linux-user: remove duplicate tswap32() from do_getsockopt()
In reply to [email protected]From: Laurent Vivier <[email protected]>
This issue has been detected with tests/linux-tests.c:
linux-test.c:330: getsockopt
327 len = sizeof(val); 328 chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len)); 329 if (val != SOCK_STREAM)
330 error("getsockopt");
In linux-user/syscall.c:do_getsockopt(), we have:
...
val = tswap32(val);
...
if (put_user_u32(val, optval_addr))...
whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".
So the "val = tswap32(val);" is useless and wrong.
This patch removes it.
From: Laurent Vivier <[email protected]>
--- linux-user/syscall.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
linux-user/syscall.c +0 -1
@@ -1348,7 +1348,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, ret =get_errno (getsockopt (sockfd, level, optname, &val, &lv));if (ret <0 )return ret; - val =tswap32 (val);if (len > lv) len = lv;if (len ==4 ) {
Signature · 1 line
1.6.2.1
Quoted 10 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Riku Voipio <[email protected]>
All the things in linux-user tree at the moment:
https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream
Since the maemo git hosting regrettably only provides https transport, you can download the git tree faster if you already have a git tree:
Quoted 8 lines
git clone
git://git.sv.gnu.org/qemu.git
cd qemu
git remote add maemo https://git.maemo.org/projects/qemu
git fetch maemo
git checkout -b linux-user maemo/linux-user-for-upstreamThis tree is constantly rebased against upstream git HEAD, so avoid basing your work on this branch.
Constantly? It's already three days old. :-)
Anyway, I pulled the patches with the intention of possibly committing them. But it looks some of them are not ready yet.
Quoted 17 lines · Blue Swirl
Quoted 16 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Riku Voipio <[email protected]>
All the things in linux-user tree at the moment:
https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream
Since the maemo git hosting regrettably only provides https transport, you can download the git tree faster if you already have a git tree:
git clone
git://git.sv.gnu.org/qemu.git
cd qemu
git remote add maemo https://git.maemo.org/projects/qemu
git fetch maemo
git checkout -b linux-user maemo/linux-user-for-upstream
Quoted 4 lines
Quoted 2 lines
This tree is constantly rebased against upstream git HEAD, so avoid basing your work on this branch.
Constantly? It's already three days old. :-)
More accurate would be "whenever there is updates in the upstream linux-user/ subdir that require rebasing", but that might give some people the impression that it is actually rabased quite rarely ;-)
Quoted 2 lines
Anyway, I pulled the patches with the intention of possibly committing them. But it looks some of them are not ready yet.
The "From:" fields were not intended as signed-off-by replacements, but rather to ensure that the authorship info is not lost. With the current mailer setup the email header "From:" on the patches sent to the mailing list shows my address, and I don't want to take anyones credit away.
I'll have the look at the compiler warning, I didn't see any warnings on my build env(s) before mailing.
Quoted 37 lines · Riku Voipio
Quoted 18 lines · Blue Swirl
Quoted 16 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Riku Voipio <[email protected]>
All the things in linux-user tree at the moment:
https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream
Since the maemo git hosting regrettably only provides https transport, you can download the git tree faster if you already have a git tree:
git clone
git://git.sv.gnu.org/qemu.git
cd qemu
git remote add maemo https://git.maemo.org/projects/qemu
git fetch maemo
git checkout -b linux-user maemo/linux-user-for-upstreamQuoted 7 lines
Quoted 3 lines
This tree is constantly rebased against upstream git HEAD, so avoid basing your work on this branch.
Constantly? It's already three days old. :-)
More accurate would be "whenever there is updates in the upstream linux-user/ subdir that require rebasing", but that might give some people the impression that it is actually rabased quite rarely ;-)
Quoted 3 lines
Anyway, I pulled the patches with the intention of possibly committing them. But it looks some of them are not ready yet.
Quoted 8 lines
The "From:" fields were not intended as signed-off-by replacements, but rather to ensure that the authorship info is not lost. With the current mailer setup the email header "From:" on the patches sent to the mailing list shows my address, and I don't want to take anyones credit away.
I'll have the look at the compiler warning, I didn't see any warnings on my build env(s) before mailing.
Is there any chance to accept the bunch of these changes or any reason to reject them? I was told by some maintainers that currently there is no maintainer for user mode anymore. Is this true, and is this the reason? Or is the user mode support "officially" dropped / running out?
I am just a bit confused about the slow acceptance of the user mode patches.
To sum it up: due to changes in the host linux systems, currently you cannot run binaries anymore - even for ARM (e.g. because address 0 is not mapped anymore in the host). Also, to run more recent glibc code, the pending updates are needed to run these binaries in user mode.
Martin
Quoted 43 lines · Martin Mohring
Quoted 42 lines · Riku Voipio
Quoted 18 lines · Blue Swirl
Quoted 16 lines · On 6/12/09, [email protected] <[email protected]> wrote:
From: Riku Voipio <[email protected]>
All the things in linux-user tree at the moment:
https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream
Since the maemo git hosting regrettably only provides https transport, you can download the git tree faster if you already have a git tree:
git clone
git://git.sv.gnu.org/qemu.git
cd qemu
git remote add maemo https://git.maemo.org/projects/qemu
git fetch maemo
git checkout -b linux-user maemo/linux-user-for-upstreamQuoted 7 lines
Quoted 3 lines
This tree is constantly rebased against upstream git HEAD, so avoid basing your work on this branch.
Constantly? It's already three days old. :-)
More accurate would be "whenever there is updates in the upstream linux-user/ subdir that require rebasing", but that might give some people the impression that it is actually rabased quite rarely ;-)
Quoted 3 lines
Anyway, I pulled the patches with the intention of possibly committing them. But it looks some of them are not ready yet.
The "From:" fields were not intended as signed-off-by replacements, but rather to ensure that the authorship info is not lost. With the current mailer setup the email header "From:" on the patches sent to the mailing list shows my address, and I don't want to take anyones credit away.
Quoted 8 lines
Quoted 3 lines
I'll have the look at the compiler warning, I didn't see any warnings on my build env(s) before mailing.
Is there any chance to accept the bunch of these changes or any reason
to reject them? I was told by some maintainers that currently there is no maintainer for user mode anymore. Is this true, and is this the reason? Or is the user mode support "officially" dropped / running out?
After the problems are fixed, I'll commit the fixed ones unless there are objections.
Quoted 8 lines · Blue Swirl
Quoted 4 lines · Martin Mohring
Is there any chance to accept the bunch of these changes or any reason
to reject them? I was told by some maintainers that currently there is no maintainer for user mode anymore. Is this true, and is this the reason? Or is the user mode support "officially" dropped / running out?After the problems are fixed, I'll commit the fixed ones unless there are objections.
I've collected the Signed-off-by:s and fixed the compiler warning. I also decided to drop the guest_base patch to a separate branch, as it touches TCG files. Although it is the "most wanted" patch, it should still be commited by someone more closer to tcg in general.
The updated tree is available at the same place[1], after I have tested that the refreshing hasn't broken anything, I'll send a pull request to the list. Meanwhile, if you have any concerns on the individual patches, please comment on this thread. The only functionally changed patch is splice/tee/vmsplice patch.
[1] https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=shortlog;h=refs/heads/linux-user-for-upstream