* [Qemu-devel] [PATCH 00/17] linux-user patches in maemo
@ 2009-03-31 20:40 riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 01/17] Fix fstatat64()/newfstatat() syscall implementation riku.voipio
` (17 more replies)
0 siblings, 18 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Riku Voipio <riku.voipio@iki.fi>
This some of the more cleaner linux-user patches maemo version
of qemu carries. The idea was to setup a "linux-user-for-upstream"
branch to git.maemo.org, but unfortunately the server is refusink
my git pushes ATM.
Most of these patches have been sent to the list earlier, without
much of response.
Kirill A. Shutemov (7):
Fix fstatat64()/newfstatat() syscall implementation
Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit
targets
Fix and cleanup IPCOP_sem* ipc calls handling
Implement sem* syscalls
Fix and cleanup IPCOP_shm* ipc calls handling
Implement shm* syscalls
shmat(): use mmap_find_vma to find free memory area
Lionel Landwerlin (3):
Added posix message queue syscalls except mq_notify
Format mq_open strace arguments
More strace formatting for posix message queues syscalls
Mika Westerberg (4):
Strace is now working again with GUEST_BASE support.
linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket
syscalls
Revived GUEST_BASE support for usermode emulation targets.
Add support for passing contents of argv0
Riku Voipio (3):
linux-user: unix sockets - fix running dbus
Prefer glibc over direct syscalls
linux-user: Proper exit code for uncaught signals
configure | 62 +++
cpu-all.h | 6 +-
linux-user/elfload.c | 24 +
linux-user/main.c | 101 ++++-
linux-user/mmap.c | 81 ++--
linux-user/qemu.h | 3 +
linux-user/signal.c | 37 +-
linux-user/strace.c | 170 +++++++
linux-user/strace.list | 109 +++--
linux-user/syscall.c | 1157 +++++++++++++++++++++++++++++++++++----------
linux-user/syscall_defs.h | 7 +
tcg/i386/tcg-target.c | 12 +
tcg/x86_64/tcg-target.c | 12 +
13 files changed, 1433 insertions(+), 348 deletions(-)
^ permalink raw reply [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 01/17] Fix fstatat64()/newfstatat() syscall implementation
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 02/17] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets riku.voipio
` (16 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
There are two different syscall names for the same goal.
On systems with sizeof(long) == 64 it calls newfstatat.
On systems with sizeof(long) == 32 it calls fstatat64.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 226ee6c..16cf89c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -169,6 +169,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
#define __NR_sys_linkat __NR_linkat
#define __NR_sys_mkdirat __NR_mkdirat
#define __NR_sys_mknodat __NR_mknodat
+#define __NR_sys_newfstatat __NR_newfstatat
#define __NR_sys_openat __NR_openat
#define __NR_sys_readlinkat __NR_readlinkat
#define __NR_sys_renameat __NR_renameat
@@ -209,7 +210,8 @@ _syscall4(int,sys_fchmodat,int,dirfd,const char *,pathname,
_syscall5(int,sys_fchownat,int,dirfd,const char *,pathname,
uid_t,owner,gid_t,group,int,flags)
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ defined(__NR_fstatat64)
_syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname,
struct stat *,buf,int,flags)
#endif
@@ -240,6 +242,11 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
_syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
mode_t,mode,dev_t,dev)
#endif
+#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
+ defined(__NR_newfstatat)
+_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
+ struct stat *,buf,int,flags)
+#endif
#if defined(TARGET_NR_openat) && defined(__NR_openat)
_syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
#endif
@@ -3280,7 +3287,7 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr,
return 0;
}
-#ifdef TARGET_NR_stat64
+#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
static inline abi_long host_to_target_stat64(void *cpu_env,
abi_ulong target_addr,
struct stat *host_st)
@@ -3312,11 +3319,15 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
} else
#endif
{
+#if TARGET_LONG_BITS == 64
+ struct target_stat *target_st;
+#else
struct target_stat64 *target_st;
+#endif
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0))
return -TARGET_EFAULT;
- memset(target_st, 0, sizeof(struct target_stat64));
+ memset(target_st, 0, sizeof(*target_st));
__put_user(host_st->st_dev, &target_st->st_dev);
__put_user(host_st->st_ino, &target_st->st_ino);
#ifdef TARGET_STAT64_HAS_BROKEN_ST_INO
@@ -5459,11 +5470,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
-#if defined(TARGET_NR_fstatat64) && defined(__NR_fstatat64)
+#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
+ (defined(__NR_fstatat64) || defined(__NR_newfstatat))
+#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
+#endif
+#ifdef TARGET_NR_newfstatat
+ case TARGET_NR_newfstatat:
+#endif
if (!(p = lock_user_string(arg2)))
goto efault;
+#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
+#else
+ ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
+#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 02/17] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 01/17] Fix fstatat64()/newfstatat() syscall implementation riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 03/17] Fix and cleanup IPCOP_sem* ipc calls handling riku.voipio
` (15 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
qemu's page table can be incomple if /proc/self/maps is unavailable or
host allocating a memory with mmap(), so we can't use it to find free
memory area.
New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
memory.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/mmap.c | 81 ++++++++++++++++++++++++++++------------------------
1 files changed, 44 insertions(+), 37 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 6f300a0..8cec230 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -275,52 +275,59 @@ static abi_ulong mmap_next_start = 0x40000000;
unsigned long last_brk;
-/* find a free memory area of size 'size'. The search starts at
- 'start'. If 'start' == 0, then a default start address is used.
- Return -1 if error.
-*/
-/* 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)
+/*
+ * Find and reserve a free memory area of size 'size'. The search
+ * starts at 'start'.
+ * It must be called with mmap_lock() held.
+ * Return -1 if error.
+ */
+abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
- abi_ulong addr, addr1, addr_start;
- int prot;
- unsigned long new_brk;
-
- new_brk = (unsigned long)sbrk(0);
- if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
- /* This is a hack to catch the host allocating memory with brk().
- If it uses mmap then we loose.
- FIXME: We really want to avoid the host allocating memory in
- the first place, and maybe leave some slack to avoid switching
- to mmap. */
- page_set_flags(last_brk & TARGET_PAGE_MASK,
- TARGET_PAGE_ALIGN(new_brk),
- PAGE_RESERVED);
- }
- last_brk = new_brk;
+ void *ptr;
+ abi_ulong addr;
size = HOST_PAGE_ALIGN(size);
- start = start & qemu_host_page_mask;
+ start &= qemu_host_page_mask;
+
+ /* If 'start' == 0, then a default start address is used. */
+ if (start == 0)
+ start = mmap_next_start;
+
addr = start;
- if (addr == 0)
- addr = mmap_next_start;
- addr_start = addr;
+
for(;;) {
- prot = 0;
- for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) {
- prot |= page_get_flags(addr1);
- }
- if (prot == 0)
+ /*
+ * Reserve needed memory area to avoid a race.
+ * It should be discarded using:
+ * - mmap() with MAP_FIXED flag
+ * - mremap() with MREMAP_FIXED flag
+ * - shmat() with SHM_REMAP flag
+ */
+ ptr = mmap((void *)(unsigned long)addr, size, PROT_NONE,
+ MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
+
+ /* ENOMEM, if host address space has no memory */
+ if (ptr == MAP_FAILED)
+ return (abi_ulong)-1;
+
+ /* If address fits target address space we've found what we need */
+ if ((unsigned long)ptr + size - 1 <= (abi_ulong)-1)
break;
+
+ /* Unmap and try again with new page */
+ munmap(ptr, size);
addr += qemu_host_page_size;
- /* we found nothing */
- if (addr == addr_start)
+
+ /* ENOMEM if we check whole of target address space */
+ if (addr == start)
return (abi_ulong)-1;
}
- if (start == 0)
- mmap_next_start = addr + size;
- return addr;
+
+ /* Update default start address */
+ if (start == mmap_next_start)
+ mmap_next_start = (unsigned long)ptr + size;
+
+ return h2g(ptr);
}
/* NOTE: all the constants are the HOST ones */
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 03/17] Fix and cleanup IPCOP_sem* ipc calls handling
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 01/17] Fix fstatat64()/newfstatat() syscall implementation riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 02/17] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 04/17] Implement sem* syscalls riku.voipio
` (14 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 319 +++++++++++++++++++++++++++++++-------------------
1 files changed, 198 insertions(+), 121 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 16cf89c..84b6f21 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1678,14 +1678,14 @@ struct target_ipc_perm
struct target_semid_ds
{
- struct target_ipc_perm sem_perm;
- abi_ulong sem_otime;
- abi_ulong __unused1;
- abi_ulong sem_ctime;
- abi_ulong __unused2;
- abi_ulong sem_nsems;
- abi_ulong __unused3;
- abi_ulong __unused4;
+ struct target_ipc_perm sem_perm;
+ abi_ulong sem_otime;
+ abi_ulong __unused1;
+ abi_ulong sem_ctime;
+ abi_ulong __unused2;
+ abi_ulong sem_nsems;
+ abi_ulong __unused3;
+ abi_ulong __unused4;
};
static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip,
@@ -1733,7 +1733,8 @@ static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1))
return -TARGET_EFAULT;
- target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr);
+ if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr))
+ return -TARGET_EFAULT;
host_sd->sem_nsems = tswapl(target_sd->sem_nsems);
host_sd->sem_otime = tswapl(target_sd->sem_otime);
host_sd->sem_ctime = tswapl(target_sd->sem_ctime);
@@ -1748,7 +1749,8 @@ static inline abi_long host_to_target_semid_ds(abi_ulong target_addr,
if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0))
return -TARGET_EFAULT;
- host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm));
+ if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm)))
+ return -TARGET_EFAULT;;
target_sd->sem_nsems = tswapl(host_sd->sem_nsems);
target_sd->sem_otime = tswapl(host_sd->sem_otime);
target_sd->sem_ctime = tswapl(host_sd->sem_ctime);
@@ -1756,135 +1758,215 @@ static inline abi_long host_to_target_semid_ds(abi_ulong target_addr,
return 0;
}
+struct target_seminfo {
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+static inline abi_long host_to_target_seminfo(abi_ulong target_addr,
+ struct seminfo *host_seminfo)
+{
+ struct target_seminfo *target_seminfo;
+ if (!lock_user_struct(VERIFY_WRITE, target_seminfo, target_addr, 0))
+ return -TARGET_EFAULT;
+ __put_user(host_seminfo->semmap, &target_seminfo->semmap);
+ __put_user(host_seminfo->semmni, &target_seminfo->semmni);
+ __put_user(host_seminfo->semmns, &target_seminfo->semmns);
+ __put_user(host_seminfo->semmnu, &target_seminfo->semmnu);
+ __put_user(host_seminfo->semmsl, &target_seminfo->semmsl);
+ __put_user(host_seminfo->semopm, &target_seminfo->semopm);
+ __put_user(host_seminfo->semume, &target_seminfo->semume);
+ __put_user(host_seminfo->semusz, &target_seminfo->semusz);
+ __put_user(host_seminfo->semvmx, &target_seminfo->semvmx);
+ __put_user(host_seminfo->semaem, &target_seminfo->semaem);
+ unlock_user_struct(target_seminfo, target_addr, 1);
+ return 0;
+}
+
union semun {
- int val;
- struct semid_ds *buf;
- unsigned short *array;
+ int val;
+ struct semid_ds *buf;
+ unsigned short *array;
+ struct seminfo *__buf;
};
union target_semun {
- int val;
- abi_long buf;
- unsigned short int *array;
+ int val;
+ abi_ulong buf;
+ abi_ulong array;
+ abi_ulong __buf;
};
-static inline abi_long target_to_host_semun(int cmd,
- union semun *host_su,
- abi_ulong target_addr,
- struct semid_ds *ds)
+static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array,
+ abi_ulong target_addr)
{
- union target_semun *target_su;
-
- switch( cmd ) {
- case IPC_STAT:
- case IPC_SET:
- if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
- return -TARGET_EFAULT;
- target_to_host_semid_ds(ds,target_su->buf);
- host_su->buf = ds;
- unlock_user_struct(target_su, target_addr, 0);
- break;
- case GETVAL:
- case SETVAL:
- if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
- return -TARGET_EFAULT;
- host_su->val = tswapl(target_su->val);
- unlock_user_struct(target_su, target_addr, 0);
- break;
- case GETALL:
- case SETALL:
- if (!lock_user_struct(VERIFY_READ, target_su, target_addr, 1))
- return -TARGET_EFAULT;
- *host_su->array = tswap16(*target_su->array);
- unlock_user_struct(target_su, target_addr, 0);
- break;
- default:
- gemu_log("semun operation not fully supported: %d\n", (int)cmd);
+ int nsems;
+ unsigned short *array;
+ union semun semun;
+ struct semid_ds semid_ds;
+ int i, ret;
+
+ semun.buf = &semid_ds;
+
+ ret = semctl(semid, 0, IPC_STAT, semun);
+ if (ret == -1)
+ return get_errno(ret);
+
+ nsems = semid_ds.sem_nsems;
+
+ *host_array = malloc(nsems*sizeof(unsigned short));
+ array = lock_user(VERIFY_READ, target_addr,
+ nsems*sizeof(unsigned short), 1);
+ if (!array)
+ return -TARGET_EFAULT;
+
+ for(i=0; i<nsems; i++) {
+ __get_user((*host_array)[i], &array[i]);
}
+ unlock_user(array, target_addr, 0);
+
return 0;
}
-static inline abi_long host_to_target_semun(int cmd,
- abi_ulong target_addr,
- union semun *host_su,
- struct semid_ds *ds)
+static inline abi_long host_to_target_semarray(int semid, abi_ulong target_addr,
+ unsigned short **host_array)
{
- union target_semun *target_su;
-
- switch( cmd ) {
- case IPC_STAT:
- case IPC_SET:
- if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
- return -TARGET_EFAULT;
- host_to_target_semid_ds(target_su->buf,ds);
- unlock_user_struct(target_su, target_addr, 1);
- break;
- case GETVAL:
- case SETVAL:
- if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
- return -TARGET_EFAULT;
- target_su->val = tswapl(host_su->val);
- unlock_user_struct(target_su, target_addr, 1);
- break;
- case GETALL:
- case SETALL:
- if (lock_user_struct(VERIFY_WRITE, target_su, target_addr, 0))
- return -TARGET_EFAULT;
- *target_su->array = tswap16(*host_su->array);
- unlock_user_struct(target_su, target_addr, 1);
- break;
- default:
- gemu_log("semun operation not fully supported: %d\n", (int)cmd);
+ int nsems;
+ unsigned short *array;
+ union semun semun;
+ struct semid_ds semid_ds;
+ int i, ret;
+
+ semun.buf = &semid_ds;
+
+ ret = semctl(semid, 0, IPC_STAT, semun);
+ if (ret == -1)
+ return get_errno(ret);
+
+ nsems = semid_ds.sem_nsems;
+
+ array = lock_user(VERIFY_WRITE, target_addr,
+ nsems*sizeof(unsigned short), 0);
+ if (!array)
+ return -TARGET_EFAULT;
+
+ for(i=0; i<nsems; i++) {
+ __put_user((*host_array)[i], &array[i]);
}
+ free(*host_array);
+ unlock_user(array, target_addr, 1);
+
return 0;
}
-static inline abi_long do_semctl(int first, int second, int third,
- abi_long ptr)
+static inline abi_long do_semctl(int semid, int semnum, int cmd,
+ union target_semun target_su)
{
union semun arg;
struct semid_ds dsarg;
- int cmd = third&0xff;
- abi_long ret = 0;
+ unsigned short *array;
+ struct seminfo seminfo;
+ abi_long ret = -TARGET_EINVAL;
+ abi_long err;
- switch( cmd ) {
- case GETVAL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case SETVAL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case GETALL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case SETALL:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case IPC_STAT:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- case IPC_SET:
- target_to_host_semun(cmd,&arg,ptr,&dsarg);
- ret = get_errno(semctl(first, second, cmd, arg));
- host_to_target_semun(cmd,ptr,&arg,&dsarg);
- break;
- default:
- ret = get_errno(semctl(first, second, cmd, arg));
+ cmd &= 0xff;
+
+ switch (cmd) {
+ case IPC_STAT:
+ case IPC_SET:
+ case SEM_STAT:
+ err = target_to_host_semid_ds(&dsarg, target_su.buf);
+ if (err)
+ return err;
+ arg.buf = &dsarg;
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ err = host_to_target_semid_ds(target_su.buf, &dsarg);
+ if (err)
+ return err;
+ break;
+ case GETVAL:
+ case SETVAL:
+ arg.val = tswapl(target_su.val);
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ target_su.val = tswapl(arg.val);
+ break;
+ case GETALL:
+ case SETALL:
+ err = target_to_host_semarray(semid, &array, target_su.array);
+ if (err)
+ return err;
+ arg.array = array;
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ err = host_to_target_semarray(semid, target_su.array, &array);
+ if (err)
+ return err;
+ break;
+ case IPC_INFO:
+ case SEM_INFO:
+ arg.__buf = &seminfo;
+ ret = get_errno(semctl(semid, semnum, cmd, arg));
+ err = host_to_target_seminfo(target_su.__buf, &seminfo);
+ if (err)
+ return err;
+ break;
+ case IPC_RMID:
+ case GETPID:
+ case GETNCNT:
+ case GETZCNT:
+ ret = get_errno(semctl(semid, semnum, cmd, NULL));
+ break;
}
return ret;
}
+struct target_sembuf {
+ unsigned short sem_num;
+ short sem_op;
+ short sem_flg;
+};
+
+static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,
+ abi_ulong target_addr,
+ unsigned nsops)
+{
+ struct target_sembuf *target_sembuf;
+ int i;
+
+ target_sembuf = lock_user(VERIFY_READ, target_addr,
+ nsops*sizeof(struct target_sembuf), 1);
+ if (!target_sembuf)
+ return -TARGET_EFAULT;
+
+ for(i=0; i<nsops; i++) {
+ __put_user(target_sembuf[i].sem_num, &host_sembuf[i].sem_num);
+ __put_user(target_sembuf[i].sem_op, &host_sembuf[i].sem_op);
+ __put_user(target_sembuf[i].sem_flg, &host_sembuf[i].sem_flg);
+ }
+
+ unlock_user(target_sembuf, target_addr, 0);
+
+ return 0;
+}
+
+static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops)
+{
+ struct sembuf sops[nsops];
+
+ if (target_to_host_sembuf(sops, ptr, nsops))
+ return -TARGET_EFAULT;
+
+ return semop(semid, sops, nsops);
+}
+
struct target_msqid_ds
{
struct target_ipc_perm msg_perm;
@@ -2088,7 +2170,7 @@ static abi_long do_ipc(unsigned int call, int first,
switch (call) {
case IPCOP_semop:
- ret = get_errno(semop(first,(struct sembuf *)g2h(ptr), second));
+ ret = do_semop(first, ptr, second);
break;
case IPCOP_semget:
@@ -2096,12 +2178,7 @@ static abi_long do_ipc(unsigned int call, int first,
break;
case IPCOP_semctl:
- ret = do_semctl(first, second, third, ptr);
- break;
-
- case IPCOP_semtimedop:
- gemu_log("Unsupported ipc call: %d (version %d)\n", call, version);
- ret = -TARGET_ENOSYS;
+ ret = do_semctl(first, second, third, (union target_semun)(abi_ulong) ptr);
break;
case IPCOP_msgget:
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 04/17] Implement sem* syscalls
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (2 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 03/17] Fix and cleanup IPCOP_sem* ipc calls handling riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 05/17] Fix and cleanup IPCOP_shm* ipc calls handling riku.voipio
` (13 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 84b6f21..926b111 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5009,7 +5009,21 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
-
+#ifdef TARGET_NR_semget
+ case TARGET_NR_semget:
+ ret = get_errno(semget(arg1, arg2, arg3));
+ break;
+#endif
+#ifdef TARGET_NR_semop
+ case TARGET_NR_semop:
+ ret = get_errno(do_semop(arg1, arg2, arg3));
+ break;
+#endif
+#ifdef TARGET_NR_semctl
+ case TARGET_NR_semctl:
+ ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
+ break;
+#endif
#ifdef TARGET_NR_msgctl
case TARGET_NR_msgctl:
ret = do_msgctl(arg1, arg2, arg3);
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 05/17] Fix and cleanup IPCOP_shm* ipc calls handling
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (3 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 04/17] Implement sem* syscalls riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 22:08 ` Paul Brook
2009-03-31 20:40 ` [Qemu-devel] [PATCH 06/17] Implement shm* syscalls riku.voipio
` (12 subsequent siblings)
17 siblings, 1 reply; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 286 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 226 insertions(+), 60 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 926b111..21ac587 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1652,14 +1652,12 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
}
#endif
-#ifdef TARGET_NR_ipc
#define N_SHM_REGIONS 32
static struct shm_region {
abi_ulong start;
abi_ulong size;
} shm_regions[N_SHM_REGIONS];
-#endif
struct target_ipc_perm
{
@@ -2153,6 +2151,208 @@ 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;
+ __put_user(target_sd->shm_segsz, &host_sd->shm_segsz);
+ __put_user(target_sd->shm_atime, &host_sd->shm_atime);
+ __put_user(target_sd->shm_dtime, &host_sd->shm_dtime);
+ __put_user(target_sd->shm_ctime, &host_sd->shm_ctime);
+ __put_user(target_sd->shm_cpid, &host_sd->shm_cpid);
+ __put_user(target_sd->shm_lpid, &host_sd->shm_lpid);
+ __put_user(target_sd->shm_nattch, &host_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_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
+ unsigned long *raddr)
+{
+ abi_long ret;
+ struct shmid_ds shm_info;
+ int i;
+
+ /* SHM_* flags are the same on all linux platforms */
+ *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
+
+ if (*raddr == -1) {
+ return get_errno(*raddr);
+ }
+
+ /* 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 */
+ shmdt((void *) *raddr);
+ return get_errno(ret);
+ }
+
+ page_set_flags(h2g(*raddr), h2g(*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 = h2g(*raddr);
+ shm_regions[i].size = shm_info.shm_segsz;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+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. */
@@ -2162,8 +2362,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;
@@ -2218,72 +2416,40 @@ static abi_long do_ipc(unsigned int call, int first,
break;
case IPCOP_shmat:
- {
- 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;
+ switch (version) {
+ default:
+ {
+ unsigned long raddr;
+
+ ret = do_shmat(first, ptr, second, &raddr);
+ if (ret)
break;
- }
+
+ ret = put_user_ual(raddr, third);
+ break;
}
- if (put_user_ual(raddr, third))
- return -TARGET_EFAULT;
- ret = 0;
+ case 1:
+ ret = -TARGET_EINVAL;
+ break;
}
- 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)));
- break;
+ ret = do_shmdt(ptr);
+ break;
case IPCOP_shmget:
- /* IPC_* flag values are the same on all linux platforms */
- ret = get_errno(shmget(first, second, third));
- break;
+ ret = get_errno(shmget(first, second, third));
+ break;
- /* 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;
+ gemu_log("Unsupported ipc call: %d (version %d)\n", call, version);
+ ret = -TARGET_ENOSYS;
+ break;
}
return ret;
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 06/17] Implement shm* syscalls
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (4 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 05/17] Fix and cleanup IPCOP_shm* ipc calls handling riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 07/17] shmat(): use mmap_find_vma to find free memory area riku.voipio
` (11 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 21ac587..7ebb36d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5210,6 +5210,32 @@ 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:
+ {
+ abi_long err;
+ unsigned long _ret;
+
+ err = do_shmat(arg1, arg2, arg3, &_ret);
+ ret = err ? err : _ret;
+ }
+ 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;
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 07/17] shmat(): use mmap_find_vma to find free memory area
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (5 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 06/17] Implement shm* syscalls riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 08/17] Added posix message queue syscalls except mq_notify riku.voipio
` (10 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Kirill A. Shutemov <kirill@shutemov.name>
This patch depends on new implementation of mmap_find_vma().
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7ebb36d..b2ffe3a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2304,25 +2304,40 @@ static inline abi_long do_shmctl(int shmid, int cmd, abi_long buf)
static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
unsigned long *raddr)
{
+ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size);
abi_long ret;
struct shmid_ds shm_info;
int i;
- /* SHM_* flags are the same on all linux platforms */
- *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
-
- if (*raddr == -1) {
- return get_errno(*raddr);
- }
-
/* 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 */
- shmdt((void *) *raddr);
return get_errno(ret);
}
+ mmap_lock();
+
+ if (shmaddr)
+ *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
+ else {
+ abi_ulong mmap_start;
+
+ mmap_start = mmap_find_vma(0, shm_info.shm_segsz);
+
+ if (mmap_start == -1) {
+ errno = ENOMEM;
+ *raddr = -1;
+ } else
+ *raddr = (unsigned long) shmat(shmid, g2h(mmap_start),
+ shmflg | SHM_REMAP);
+ }
+
+ if (*raddr == -1) {
+ mmap_unlock();
+ return get_errno(*raddr);
+ }
+
page_set_flags(h2g(*raddr), h2g(*raddr) + shm_info.shm_segsz,
PAGE_VALID | PAGE_READ |
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
@@ -2335,6 +2350,7 @@ static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
}
}
+ mmap_unlock();
return 0;
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 08/17] Added posix message queue syscalls except mq_notify
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (6 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 07/17] shmat(): use mmap_find_vma to find free memory area riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 09/17] Format mq_open strace arguments riku.voipio
` (9 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 113 +++++++++++++++++++++++++++++++++++++++++++++
linux-user/syscall_defs.h | 7 +++
2 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b2ffe3a..56868ff 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include <time.h>
#include <limits.h>
+#include <mqueue.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
@@ -635,6 +636,43 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,
return 0;
}
+static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr,
+ abi_ulong target_mq_attr_addr)
+{
+ struct target_mq_attr *target_mq_attr;
+
+ if (!lock_user_struct(VERIFY_READ, target_mq_attr,
+ target_mq_attr_addr, 1))
+ return -TARGET_EFAULT;
+
+ __get_user(attr->mq_flags, &target_mq_attr->mq_flags);
+ __get_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg);
+ __get_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize);
+ __get_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs);
+
+ unlock_user_struct(target_mq_attr, target_mq_attr_addr, 0);
+
+ return 0;
+}
+
+static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr,
+ const struct mq_attr *attr)
+{
+ struct target_mq_attr *target_mq_attr;
+
+ if (!lock_user_struct(VERIFY_WRITE, target_mq_attr,
+ target_mq_attr_addr, 0))
+ return -TARGET_EFAULT;
+
+ __put_user(attr->mq_flags, &target_mq_attr->mq_flags);
+ __put_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg);
+ __put_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize);
+ __put_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs);
+
+ unlock_user_struct(target_mq_attr, target_mq_attr_addr, 1);
+
+ return 0;
+}
/* do_select() must return target values and target errnos. */
static abi_long do_select(int n,
@@ -6447,6 +6485,81 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
#endif
+#ifdef TARGET_NR_mq_open
+ case TARGET_NR_mq_open:
+ {
+ struct mq_attr posix_mq_attr;
+
+ p = lock_user_string(arg1 - 1);
+ if (arg4 != 0)
+ copy_from_user_mq_attr (&posix_mq_attr, arg4);
+ ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr));
+ unlock_user (p, arg1, 0);
+ break;
+ }
+
+ case TARGET_NR_mq_unlink:
+ p = lock_user_string(arg1 - 1);
+ ret = get_errno(mq_unlink(p));
+ unlock_user (p, arg1, 0);
+ break;
+
+ case TARGET_NR_mq_timedsend:
+ {
+ struct timespec ts;
+
+ p = lock_user (VERIFY_READ, arg2, arg3, 1);
+ if (arg5 != 0) {
+ target_to_host_timespec(&ts, arg5);
+ ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts));
+ host_to_target_timespec(arg5, &ts);
+ }
+ else
+ ret = get_errno(mq_send(arg1, p, arg3, arg4));
+ unlock_user (p, arg2, arg3);
+ break;
+ }
+
+ case TARGET_NR_mq_timedreceive:
+ {
+ struct timespec ts;
+ unsigned int prio;
+
+ p = lock_user (VERIFY_READ, arg2, arg3, 1);
+ if (arg5 != 0) {
+ target_to_host_timespec(&ts, arg5);
+ ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts));
+ host_to_target_timespec(arg5, &ts);
+ }
+ else
+ ret = get_errno(mq_receive(arg1, p, arg3, &prio));
+ unlock_user (p, arg2, arg3);
+ if (arg4 != 0)
+ put_user_u32(prio, arg4);
+ break;
+ }
+
+ /* Not implemented for now... */
+/* case TARGET_NR_mq_notify: */
+/* break; */
+
+ case TARGET_NR_mq_getsetattr:
+ {
+ struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
+ ret = 0;
+ if (arg3 != 0) {
+ ret = mq_getattr(arg1, &posix_mq_attr_out);
+ copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
+ }
+ if (arg2 != 0) {
+ copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
+ ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
+ }
+
+ break;
+ }
+#endif
+
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 7db7a8c..a373690 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1998,6 +1998,13 @@ struct linux_dirent64 {
char d_name[256];
};
+struct target_mq_attr {
+ abi_long mq_flags;
+ abi_long mq_maxmsg;
+ abi_long mq_msgsize;
+ abi_long mq_curmsgs;
+};
+
#include "socket.h"
#include "errno_defs.h"
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 09/17] Format mq_open strace arguments
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (7 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 08/17] Added posix message queue syscalls except mq_notify riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 10/17] More strace formatting for posix message queues syscalls riku.voipio
` (8 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/strace.list | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 09a801f..45eb24d 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -530,7 +530,7 @@
{ TARGET_NR_mq_notify, "mq_notify" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mq_open
-{ TARGET_NR_mq_open, "mq_open" , NULL, NULL, NULL },
+{ TARGET_NR_mq_open, "mq_open" , "%s(\"/%s\",%#x,%#o,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_timedreceive
{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , NULL, NULL, NULL },
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 10/17] More strace formatting for posix message queues syscalls
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (8 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 09/17] Format mq_open strace arguments riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 11/17] Add support for passing contents of argv0 riku.voipio
` (7 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/strace.list | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 45eb24d..3f688db 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -524,22 +524,22 @@
{ TARGET_NR_mpx, "mpx" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mq_getsetattr
-{ TARGET_NR_mq_getsetattr, "mq_getsetattr" , NULL, NULL, NULL },
+{ TARGET_NR_mq_getsetattr, "mq_getsetattr" , "%s(%d,%p,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_notify
-{ TARGET_NR_mq_notify, "mq_notify" , NULL, NULL, NULL },
+{ TARGET_NR_mq_notify, "mq_notify" , "%s(%d,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_open
{ TARGET_NR_mq_open, "mq_open" , "%s(\"/%s\",%#x,%#o,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_timedreceive
-{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , NULL, NULL, NULL },
+{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_timedsend
-{ TARGET_NR_mq_timedsend, "mq_timedsend" , NULL, NULL, NULL },
+{ TARGET_NR_mq_timedsend, "mq_timedsend" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_unlink
-{ TARGET_NR_mq_unlink, "mq_unlink" , NULL, NULL, NULL },
+{ TARGET_NR_mq_unlink, "mq_unlink" , "%s(%s)", NULL, NULL },
#endif
#ifdef TARGET_NR_mremap
{ TARGET_NR_mremap, "mremap" , NULL, NULL, NULL },
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 11/17] Add support for passing contents of argv0
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (9 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 10/17] More strace formatting for posix message queues syscalls riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix running dbus riku.voipio
` (6 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Mika Westerberg <mika.westerberg@iki.fi>
From: Mika Westerberg
Added switch -0 (zero) which can be used to pass argv[0] to
target process. The main use is for a binfmt_misc wrapper when
the "P - preserve-argv[0]" setting is used.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/main.c | 38 +++++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index feb3036..40308aa 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2213,6 +2213,7 @@ static void usage(void)
"-drop-ld-preload drop LD_PRELOAD for target process\n"
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
+ "-0 argv0 forces target process argv[0] to be argv0\n"
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
@@ -2263,7 +2264,11 @@ int main(int argc, char **argv, char **envp)
const char *r;
int gdbstub_port = 0;
char **target_environ, **wrk;
+ char **target_argv;
+ int target_argc;
envlist_t *envlist = NULL;
+ const char *argv0 = NULL;
+ int i;
if (argc <= 1)
usage();
@@ -2320,6 +2325,9 @@ int main(int argc, char **argv, char **envp)
r = argv[optind++];
if (envlist_unsetenv(envlist, r) != 0)
usage();
+ } else if (!strcmp(r, "0")) {
+ r = argv[optind++];
+ argv0 = r;
} else if (!strcmp(r, "s")) {
if (optind >= argc)
break;
@@ -2430,11 +2438,39 @@ int main(int argc, char **argv, char **envp)
target_environ = envlist_to_environ(envlist, NULL);
envlist_free(envlist);
- if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
+ /*
+ * Prepare copy of argv vector for target.
+ */
+ target_argc = argc - optind;
+ target_argv = calloc(target_argc + 1, sizeof (char *));
+ if (target_argv == NULL) {
+ (void) fprintf(stderr, "Unable to allocate memory for target_argv\n");
+ exit(1);
+ }
+
+ /*
+ * If argv0 is specified (using '-0' switch) we replace
+ * argv[0] pointer with the given one.
+ */
+ i = 0;
+ if (argv0 != NULL) {
+ target_argv[i++] = strdup(argv0);
+ }
+ for (; i < target_argc; i++) {
+ target_argv[i] = strdup(argv[optind + i]);
+ }
+ target_argv[target_argc] = NULL;
+
+ if (loader_exec(filename, target_argv, target_environ, regs, info) != 0) {
printf("Error loading %s\n", filename);
_exit(1);
}
+ for (i = 0; i < target_argc; i++) {
+ free(target_argv[i]);
+ }
+ free(target_argv);
+
for (wrk = target_environ; *wrk; wrk++) {
free(*wrk);
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix running dbus
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (10 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 11/17] Add support for passing contents of argv0 riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 23:36 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix runningdbus Krumme, Chris
2009-03-31 20:40 ` [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support riku.voipio
` (5 subsequent siblings)
17 siblings, 1 reply; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Riku Voipio <riku.voipio@iki.fi>
dbus sends too short (according to man 7 unix) addrlen for it's
unix socket. I've been told that happens with other applications
as well. Linux kernel doesn't appear to mind, so I guess
we whould be tolerant as well. Expand sockaddr with +1 to fit
the \0 of the pathname passed.
(scratchbox1 qemu had a very different workaround for the same issue).
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 56868ff..c6b0b74 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -44,6 +44,7 @@
#include <signal.h>
#include <sched.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include <sys/uio.h>
#include <sys/poll.h>
#include <sys/times.h>
@@ -735,13 +736,37 @@ static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
abi_ulong target_addr,
socklen_t len)
{
+ const socklen_t unix_maxlen = sizeof (struct sockaddr_un);
+ sa_family_t sa_family;
struct target_sockaddr *target_saddr;
target_saddr = lock_user(VERIFY_READ, target_addr, len, 1);
if (!target_saddr)
return -TARGET_EFAULT;
+
+ sa_family = tswap16(target_saddr->sa_family);
+
+ /* Oops. The caller might send a incomplete sun_path; sun_path
+ * must be terminated by \0 (see the manual page), but
+ * unfortunately it is quite common to specify sockaddr_un
+ * length as "strlen(x->sun_path)" while it should be
+ * "strlen(...) + 1". We'll fix that here if needed.
+ * Linux kernel has a similar feature.
+ */
+
+ if (sa_family == AF_UNIX) {
+ if (len < unix_maxlen) {
+ char *cp = (char*)target_saddr;
+
+ if ( cp[len-1] && !cp[len] )
+ len++;
+ }
+ if (len > unix_maxlen)
+ len = unix_maxlen;
+ }
+
memcpy(addr, target_saddr, len);
- addr->sa_family = tswap16(target_saddr->sa_family);
+ addr->sa_family = sa_family;
unlock_user(target_saddr, target_addr, 0);
return 0;
@@ -1195,7 +1220,7 @@ static abi_long do_bind(int sockfd, abi_ulong target_addr,
if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
return -TARGET_EINVAL;
- addr = alloca(addrlen);
+ addr = alloca(addrlen+1);
target_to_host_sockaddr(addr, target_addr, addrlen);
return get_errno(bind(sockfd, addr, addrlen));
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support.
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (11 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix running dbus riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 21:31 ` Paul Brook
2009-03-31 20:40 ` [Qemu-devel] [PATCH 14/17] Revived GUEST_BASE support for usermode emulation targets riku.voipio
` (4 subsequent siblings)
17 siblings, 1 reply; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/strace.c | 170 ++++++++++++++++++++++++++++++++++++++++++++++++
linux-user/strace.list | 101 +++++++++++++++++-----------
2 files changed, 232 insertions(+), 39 deletions(-)
diff --git a/linux-user/strace.c b/linux-user/strace.c
index b4caffe..2ec1030 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -255,6 +255,172 @@ print_syscall_ret_newselect(const struct syscallname *name, abi_long ret)
}
#endif
+#define LOCKED_ARG0 (1 << 0)
+#define LOCKED_ARG1 (1 << 1)
+#define LOCKED_ARG2 (1 << 2)
+#define LOCKED_ARG3 (1 << 3)
+#define LOCKED_ARG4 (1 << 4)
+#define LOCKED_ARG5 (1 << 5)
+
+struct args {
+ abi_long arg_guest; /* guest argument */
+ uintptr_t arg_host; /* host argument */
+ int arg_locked; /* is this argument locked? */
+};
+
+/*
+ * This function locks strings from guest memory and prints
+ * strace output according to format specified in strace.list.
+ *
+ * First parameter specifies, which guest arguments should be
+ * locked (LOCKED_ARG0 - LOCKED_ARG5).
+ */
+static void
+print_locked(unsigned int locked, const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ struct args args[6] = {
+ { arg0, 0, (locked & LOCKED_ARG0) },
+ { arg1, 0, (locked & LOCKED_ARG1) },
+ { arg2, 0, (locked & LOCKED_ARG2) },
+ { arg3, 0, (locked & LOCKED_ARG3) },
+ { arg4, 0, (locked & LOCKED_ARG4) },
+ { arg5, 0, (locked & LOCKED_ARG5) },
+ };
+ struct args *a;
+ int i;
+
+ for (i = 0; i < 6; i++) {
+ a = &args[i];
+ if (a->arg_locked) {
+ a->arg_host = (uintptr_t)lock_user_string(a->arg_guest);
+ if (a->arg_host == 0)
+ goto out;
+ } else {
+ a->arg_host = (uintptr_t)a->arg_guest;
+ }
+ }
+
+ /*
+ * Now we can have all strings locked and converted into host
+ * addresses.
+ */
+ gemu_log(name->format,
+ name->name,
+ args[0].arg_host,
+ args[1].arg_host,
+ args[2].arg_host,
+ args[3].arg_host,
+ args[4].arg_host,
+ args[5].arg_host);
+
+out:
+ for (i = 0; i < 6; i++) {
+ a = &args[i];
+ if (a->arg_locked)
+ unlock_user((void *)a->arg_host, a->arg_guest, 0);
+ }
+}
+
+static void
+print_1st_locked(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_locked(LOCKED_ARG0, name, arg0, arg1, arg2, arg3, arg4, arg5);
+}
+
+static void
+print_2nd_locked(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_locked(LOCKED_ARG1, name, arg0, arg1, arg2, arg3, arg4, arg5);
+}
+
+static void
+print_1st_and_2nd_locked(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_locked(LOCKED_ARG0 | LOCKED_ARG1, name, arg0, arg1, arg2,
+ arg3, arg4, arg5);
+}
+
+static void
+print_1st_and_3rd_locked(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_locked(LOCKED_ARG0 | LOCKED_ARG2, name, arg0, arg1, arg2,
+ arg3, arg4, arg5);
+}
+
+static void
+print_1st_2nd_and_3rd_locked(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_locked(LOCKED_ARG0 | LOCKED_ARG1 | LOCKED_ARG2, name,
+ arg0, arg1, arg2, arg3, arg4, arg5);
+}
+
+static void
+print_2nd_and_4th_locked(const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ print_locked(LOCKED_ARG1 | LOCKED_ARG3, name, arg0, arg1, arg2,
+ arg3, arg4, arg5);
+}
+
+/*
+ * Here is list of syscalls that we support reading in (locking)
+ * strings from guest addresses. Every syscall that has "%s" in its
+ * parameter list and doesn't have specific print function, should
+ * be defined here.
+ */
+#define print_access print_1st_locked
+#define print_chdir print_1st_locked
+#define print_chmod print_1st_locked
+#define print_creat print_1st_locked
+#define print_execv print_1st_locked
+#define print_faccessat print_2nd_locked
+#define print_fchmodat print_2nd_locked
+#define print_fchown print_1st_locked
+#define print_fchownat print_2nd_locked
+#define print_futimesat print_2nd_locked
+#define print_link print_1st_and_2nd_locked
+#define print_linkat print_2nd_and_4th_locked
+#define print_lstat print_1st_locked
+#define print_lstat64 print_1st_locked
+#define print_mkdir print_1st_locked
+#define print_mkdirat print_2nd_locked
+#define print_mknod print_1st_locked
+#define print_mknodat print_2nd_locked
+#define print_mq_open print_1st_locked
+#define print_mq_unlink print_1st_locked
+#define print_fstatat64 print_2nd_locked
+#define print_newfstatat print_2nd_locked
+#define print_open print_1st_locked
+#define print_openat print_2nd_locked
+#define print_readlink print_1st_locked
+#define print_readlinkat print_2nd_locked
+#define print_rename print_1st_and_2nd_locked
+#define print_renameat print_2nd_and_4th_locked
+#define print_stat print_1st_locked
+#define print_stat64 print_1st_locked
+#define print_statfs print_1st_locked
+#define print_statfs64 print_1st_locked
+#define print_symlink print_1st_and_2nd_locked
+#define print_symlinkat print_1st_and_3rd_locked
+#define print_umount print_1st_2nd_and_3rd_locked
+#define print_unlink print_1st_locked
+#define print_unlinkat print_2nd_locked
+#define print_utime print_1st_locked
+#define print_utimensat print_2nd_locked
+
/*
* An array of all of the syscalls we know about
*/
@@ -285,6 +451,10 @@ print_syscall(int num,
} else {
/* XXX: this format system is broken because it uses
host types and host pointers for strings */
+ /*
+ * It now works when it has print_xxx_locked function
+ * as its printing function.
+ */
if( scnames[i].format != NULL )
format = scnames[i].format;
gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6);
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 3f688db..5f59115 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1,8 +1,13 @@
+/*
+ * Note that if you change format strings in these, check also
+ * that corresponding print functions are able to handle string
+ * locking correctly (see strace.c).
+ */
#ifdef TARGET_NR_accept
{ TARGET_NR_accept, "accept" , "%s(%d,%#x,%#x)", NULL, NULL },
#endif
#ifdef TARGET_NR_access
-{ TARGET_NR_access, "access" , "%s(\"%s\",%#o)", NULL, NULL },
+{ TARGET_NR_access, "access" , "%s(\"%s\",%#o)", print_access, NULL },
#endif
#ifdef TARGET_NR_acct
{ TARGET_NR_acct, "acct" , NULL, NULL, NULL },
@@ -53,10 +58,10 @@
{ TARGET_NR_capset, "capset" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_chdir
-{ TARGET_NR_chdir, "chdir" , "%s(\"%s\")", NULL, NULL },
+{ TARGET_NR_chdir, "chdir" , "%s(\"%s\")", print_chdir, NULL },
#endif
#ifdef TARGET_NR_chmod
-{ TARGET_NR_chmod, "chmod" , "%s(\"%s\",%#o)", NULL, NULL },
+{ TARGET_NR_chmod, "chmod" , "%s(\"%s\",%#o)", print_chmod, NULL },
#endif
#ifdef TARGET_NR_chown
{ TARGET_NR_chown, "chown" , NULL, NULL, NULL },
@@ -89,7 +94,7 @@
{ TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
#endif
#ifdef TARGET_NR_creat
-{ TARGET_NR_creat, "creat" , "%s(\"%s\",%#o)", NULL, NULL },
+{ TARGET_NR_creat, "creat" , "%s(\"%s\",%#o)", print_creat, NULL },
#endif
#ifdef TARGET_NR_create_module
{ TARGET_NR_create_module, "create_module" , NULL, NULL, NULL },
@@ -122,7 +127,8 @@
{ TARGET_NR_epoll_wait_old, "epoll_wait_old" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_execv
-{ TARGET_NR_execv, "execv" , "%s(\"%s\",%ld,%ld,%ld,%ld,%ld)\n", NULL, NULL },
+{ TARGET_NR_execv, "execv" , "%s(\"%s\",%ld,%ld,%ld,%ld,%ld)\n",
+ print_execv, NULL },
#endif
#ifdef TARGET_NR_execve
{ TARGET_NR_execve, "execve" , NULL, print_execve, NULL },
@@ -140,7 +146,8 @@
{ TARGET_NR_exit_group, "exit_group" , "%s(%d)\n", NULL, NULL },
#endif
#ifdef TARGET_NR_faccessat
-{ TARGET_NR_faccessat, "faccessat" , "%s(%d,\"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_NR_faccessat, "faccessat" , "%s(%d,\"%s\",%#o,%#x)",
+ print_faccessat, NULL },
#endif
#ifdef TARGET_NR_fadvise64
{ TARGET_NR_fadvise64, "fadvise64" , NULL, NULL, NULL },
@@ -155,16 +162,18 @@
{ TARGET_NR_fchmod, "fchmod" , "%s(%d,%#o)", NULL, NULL },
#endif
#ifdef TARGET_NR_fchmodat
-{ TARGET_NR_fchmodat, "fchmodat" , "%s(%d,\"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_NR_fchmodat, "fchmodat" , "%s(%d,\"%s\",%#o,%#x)",
+ print_fchmodat, NULL },
#endif
#ifdef TARGET_NR_fchown
-{ TARGET_NR_fchown, "fchown" , "%s(\"%s\",%d,%d)", NULL, NULL },
+{ TARGET_NR_fchown, "fchown" , "%s(\"%s\",%d,%d)", print_fchown, NULL },
#endif
#ifdef TARGET_NR_fchown32
{ TARGET_NR_fchown32, "fchown32" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_fchownat
-{ TARGET_NR_fchownat, "fchownat" , "%s(%d,\"%s\",%d,%d,%#x)", NULL, NULL },
+{ TARGET_NR_fchownat, "fchownat" , "%s(%d,\"%s\",%d,%d,%#x)",
+ print_fchownat, NULL },
#endif
#ifdef TARGET_NR_fcntl
{ TARGET_NR_fcntl, "fcntl" , NULL, NULL, NULL },
@@ -221,7 +230,8 @@
{ TARGET_NR_futex, "futex" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_futimesat
-{ TARGET_NR_futimesat, "futimesat" , "%s(%d,\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_futimesat, "futimesat" , "%s(%d,\"%s\",%p)",
+ print_futimesat, NULL },
#endif
#ifdef TARGET_NR_getcwd
{ TARGET_NR_getcwd, "getcwd" , "%s(%p,%d)", NULL, NULL },
@@ -425,10 +435,11 @@
{ TARGET_NR_lgetxattr, "lgetxattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_link
-{ TARGET_NR_link, "link" , "%s(\"%s\",\"%s\")", NULL, NULL },
+{ TARGET_NR_link, "link" , "%s(\"%s\",\"%s\")", print_link, NULL },
#endif
#ifdef TARGET_NR_linkat
-{ TARGET_NR_linkat, "linkat" , "%s(%d,\"%s\",%d,\"%s\",%#x)", NULL, NULL },
+{ TARGET_NR_linkat, "linkat" , "%s(%d,\"%s\",%d,\"%s\",%#x)",
+ print_linkat, NULL },
#endif
#ifdef TARGET_NR_Linux
{ TARGET_NR_Linux, "Linux" , NULL, NULL, NULL },
@@ -461,10 +472,10 @@
{ TARGET_NR_lsetxattr, "lsetxattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_lstat
-{ TARGET_NR_lstat, "lstat" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_lstat, "lstat" , "%s(\"%s\",%p)", print_lstat, NULL },
#endif
#ifdef TARGET_NR_lstat64
-{ TARGET_NR_lstat64, "lstat64" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_lstat64, "lstat64" , "%s(\"%s\",%p)", print_lstat64, NULL },
#endif
#ifdef TARGET_NR_madvise
{ TARGET_NR_madvise, "madvise" , NULL, NULL, NULL },
@@ -485,16 +496,17 @@
{ TARGET_NR_mincore, "mincore" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_mkdir
-{ TARGET_NR_mkdir, "mkdir" , "%s(\"%s\",%#o)", NULL, NULL },
+{ TARGET_NR_mkdir, "mkdir" , "%s(\"%s\",%#o)", print_mkdir, NULL },
#endif
#ifdef TARGET_NR_mkdirat
-{ TARGET_NR_mkdirat, "mkdirat" , "%s(%d,\"%s\",%#o)", NULL, NULL },
+{ TARGET_NR_mkdirat, "mkdirat" , "%s(%d,\"%s\",%#o)", print_mkdirat, NULL },
#endif
#ifdef TARGET_NR_mknod
-{ TARGET_NR_mknod, "mknod" , "%s(\"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_NR_mknod, "mknod" , "%s(\"%s\",%#o,%#x)", print_mknod, NULL },
#endif
#ifdef TARGET_NR_mknodat
-{ TARGET_NR_mknodat, "mknodat" , "%s(%d,\"%s\",%#o,%#x)", NULL, NULL },
+{ TARGET_NR_mknodat, "mknodat" , "%s(%d,\"%s\",%#o,%#x)",
+ print_mknodat, NULL },
#endif
#ifdef TARGET_NR_mlock
{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL },
@@ -530,7 +542,8 @@
{ TARGET_NR_mq_notify, "mq_notify" , "%s(%d,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_open
-{ TARGET_NR_mq_open, "mq_open" , "%s(\"/%s\",%#x,%#o,%p)", NULL, NULL },
+{ TARGET_NR_mq_open, "mq_open" , "%s(\"/%s\",%#x,%#o,%p)",
+ print_mq_open, NULL },
#endif
#ifdef TARGET_NR_mq_timedreceive
{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
@@ -539,7 +552,7 @@
{ TARGET_NR_mq_timedsend, "mq_timedsend" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_mq_unlink
-{ TARGET_NR_mq_unlink, "mq_unlink" , "%s(%s)", NULL, NULL },
+{ TARGET_NR_mq_unlink, "mq_unlink" , "%s(%s)", print_mq_unlink, NULL },
#endif
#ifdef TARGET_NR_mremap
{ TARGET_NR_mremap, "mremap" , NULL, NULL, NULL },
@@ -575,10 +588,12 @@
{ TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_fstatat64
-{ TARGET_NR_fstatat64, "fstatat64" , "%s(%d,\"%s\",%p,%#x)", NULL, NULL },
+{ TARGET_NR_fstatat64, "fstatat64" , "%s(%d,\"%s\",%p,%#x)",
+ print_fstatat64, NULL },
#endif
#ifdef TARGET_NR_newfstatat
-{ TARGET_NR_newfstatat, "newfstatat" , "%s(%d,\"%s\",%p,%#x)", NULL, NULL },
+{ TARGET_NR_newfstatat, "newfstatat" , "%s(%d,\"%s\",%p,%#x)",
+ print_newfstatat, NULL },
#endif
#ifdef TARGET_NR__newselect
{ TARGET_NR__newselect, "_newselect" , NULL, print_newselect, print_syscall_ret_newselect },
@@ -611,10 +626,11 @@
{ TARGET_NR_olduname, "olduname" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_open
-{ TARGET_NR_open, "open" , "%s(\"%s\",%#x,%#o)", NULL, NULL },
+{ TARGET_NR_open, "open" , "%s(\"%s\",%#x,%#o)", print_open, NULL },
#endif
#ifdef TARGET_NR_openat
-{ TARGET_NR_openat, "openat" , "%s(%d,\"%s\",%#x,%#o)", NULL, NULL },
+{ TARGET_NR_openat, "openat" , "%s(%d,\"%s\",%#x,%#o)",
+ print_openat, NULL },
#endif
#ifdef TARGET_NR_osf_adjtime
{ TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL },
@@ -1007,10 +1023,12 @@
{ TARGET_NR_readdir, "readdir" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_readlink
-{ TARGET_NR_readlink, "readlink" , "%s(\"%s\",%p,%d)", NULL, NULL },
+{ TARGET_NR_readlink, "readlink" , "%s(\"%s\",%p,%d)",
+ print_readlink, NULL },
#endif
#ifdef TARGET_NR_readlinkat
-{ TARGET_NR_readlinkat, "readlinkat" , "%s(%d,\"%s\",%p,%d)", NULL, NULL },
+{ TARGET_NR_readlinkat, "readlinkat" , "%s(%d,\"%s\",%p,%d)",
+ print_readlinkat, NULL },
#endif
#ifdef TARGET_NR_readv
{ TARGET_NR_readv, "readv" , NULL, NULL, NULL },
@@ -1034,10 +1052,11 @@
{ TARGET_NR_removexattr, "removexattr" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_rename
-{ TARGET_NR_rename, "rename" , "%s(\"%s\",\"%s\")", NULL, NULL },
+{ TARGET_NR_rename, "rename" , "%s(\"%s\",\"%s\")", print_rename, NULL },
#endif
#ifdef TARGET_NR_renameat
-{ TARGET_NR_renameat, "renameat" , "%s(%d,\"%s\",%d,\"%s\")", NULL, NULL },
+{ TARGET_NR_renameat, "renameat" , "%s(%d,\"%s\",%d,\"%s\")",
+ print_renameat, NULL },
#endif
#ifdef TARGET_NR_request_key
{ TARGET_NR_request_key, "request_key" , NULL, NULL, NULL },
@@ -1301,16 +1320,16 @@
{ TARGET_NR_ssetmask, "ssetmask" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_stat
-{ TARGET_NR_stat, "stat" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_stat, "stat" , "%s(\"%s\",%p)", print_stat, NULL },
#endif
#ifdef TARGET_NR_stat64
-{ TARGET_NR_stat64, "stat64" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_stat64, "stat64" , "%s(\"%s\",%p)", print_stat64, NULL },
#endif
#ifdef TARGET_NR_statfs
-{ TARGET_NR_statfs, "statfs" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_statfs, "statfs" , "%s(\"%s\",%p)", print_statfs, NULL },
#endif
#ifdef TARGET_NR_statfs64
-{ TARGET_NR_statfs64, "statfs64" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_statfs64, "statfs64" , "%s(\"%s\",%p)", print_statfs64, NULL },
#endif
#ifdef TARGET_NR_stime
{ TARGET_NR_stime, "stime" , NULL, NULL, NULL },
@@ -1334,10 +1353,12 @@
{ TARGET_NR_swapon, "swapon" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_symlink
-{ TARGET_NR_symlink, "symlink" , "%s(\"%s\",\"%s\")", NULL, NULL },
+{ TARGET_NR_symlink, "symlink" , "%s(\"%s\",\"%s\")",
+ print_symlink, NULL },
#endif
#ifdef TARGET_NR_symlinkat
-{ TARGET_NR_symlinkat, "symlinkat" , "%s(\"%s\",%d,\"%s\")", NULL, NULL },
+{ TARGET_NR_symlinkat, "symlinkat" , "%s(\"%s\",%d,\"%s\")",
+ print_symlinkat, NULL },
#endif
#ifdef TARGET_NR_sync
{ TARGET_NR_sync, "sync" , NULL, NULL, NULL },
@@ -1427,7 +1448,8 @@
{ TARGET_NR_umask, "umask" , "%s(%#o)", NULL, NULL },
#endif
#ifdef TARGET_NR_umount
-{ TARGET_NR_umount, "umount" , "%s(\"%s\",\"%s\",\"%s\",%#x,%p)", NULL, NULL },
+{ TARGET_NR_umount, "umount" , "%s(\"%s\",\"%s\",\"%s\",%#x,%p)",
+ print_umount, NULL },
#endif
#ifdef TARGET_NR_umount2
{ TARGET_NR_umount2, "umount2" , NULL, NULL, NULL },
@@ -1436,10 +1458,10 @@
{ TARGET_NR_uname, "uname" , "%s(%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_unlink
-{ TARGET_NR_unlink, "unlink" , "%s(\"%s\")", NULL, NULL },
+{ TARGET_NR_unlink, "unlink" , "%s(\"%s\")", print_unlink, NULL },
#endif
#ifdef TARGET_NR_unlinkat
-{ TARGET_NR_unlinkat, "unlinkat" , "%s(%d,\"%s\",%#x)", NULL, NULL },
+{ TARGET_NR_unlinkat, "unlinkat" , "%s(%d,\"%s\",%#x)", print_unlinkat, NULL },
#endif
#ifdef TARGET_NR_unshare
{ TARGET_NR_unshare, "unshare" , NULL, NULL, NULL },
@@ -1469,7 +1491,7 @@
{ TARGET_NR_ustat, "ustat" , "%s(%#x,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_utime
-{ TARGET_NR_utime, "utime" , "%s(\"%s\",%p)", NULL, NULL },
+{ TARGET_NR_utime, "utime" , "%s(\"%s\",%p)", print_utime, NULL },
#endif
#ifdef TARGET_NR_utimes
{ TARGET_NR_utimes, "utimes" , NULL, NULL, NULL },
@@ -1511,5 +1533,6 @@
{ TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL },
#endif
#ifdef TARGET_NR_utimensat
-{ TARGET_NR_utimensat, "utimensat", "%s(%d,\"%s\",%p,%#x)", NULL, NULL },
+{ TARGET_NR_utimensat, "utimensat", "%s(%d,\"%s\",%p,%#x)",
+ print_utimensat, NULL },
#endif
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 14/17] Revived GUEST_BASE support for usermode emulation targets.
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (12 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 21:51 ` Paul Brook
2009-03-31 20:40 ` [Qemu-devel] [PATCH 15/17] linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket syscalls riku.voipio
` (3 subsequent siblings)
17 siblings, 1 reply; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Riku Voipio <riku.voipio@iki.fi>
From: Mika Westerberg <mika.westerberg@iki.fi>
- 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.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
configure | 9 ++++++
cpu-all.h | 6 +++-
linux-user/elfload.c | 24 ++++++++++++++++++
linux-user/main.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++
linux-user/qemu.h | 3 ++
linux-user/syscall.c | 2 +
tcg/i386/tcg-target.c | 12 +++++++++
tcg/x86_64/tcg-target.c | 12 +++++++++
8 files changed, 130 insertions(+), 1 deletions(-)
diff --git a/configure b/configure
index 5c62c59..8b0a378 100755
--- a/configure
+++ b/configure
@@ -176,6 +176,7 @@ softmmu="yes"
linux_user="no"
darwin_user="no"
bsd_user="no"
+guest_base="no"
build_docs="no"
uname_release=""
curses="yes"
@@ -437,6 +438,8 @@ for opt do
;;
--enable-bsd-user) bsd_user="yes"
;;
+ --enable-guest-base) guest_base="yes"
+ ;;
--enable-uname-release=*) uname_release="$optarg"
;;
--sparc_cpu=*)
@@ -570,6 +573,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"
@@ -1202,6 +1207,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 "Install blobs $blobs"
@@ -1848,6 +1854,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
diff --git a/cpu-all.h b/cpu-all.h
index 366f47e..0e6efae 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -629,8 +629,12 @@ 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)
+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))
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 6de30f4..ea012e0 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1337,6 +1337,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;
diff --git a/linux-user/main.c b/linux-user/main.c
index 40308aa..912d68d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -39,6 +39,11 @@
char *exec_path;
+#if defined(CONFIG_USE_GUEST_BASE)
+unsigned long mmap_min_addr = 0;
+unsigned long guest_base = 0;
+#endif
+
static const char *interp_prefix = CONFIG_QEMU_PREFIX;
const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
@@ -2214,6 +2219,9 @@ static void usage(void)
"-E var=value sets/modifies targets environment variable(s)\n"
"-U var unsets targets environment variable(s)\n"
"-0 argv0 forces target process argv[0] to be argv0\n"
+#if defined(CONFIG_USE_GUEST_BASE)
+ "-B address set guest_base address to address\n"
+#endif
"\n"
"Debug options:\n"
"-d options activate log (logfile=%s)\n"
@@ -2229,6 +2237,15 @@ static void usage(void)
" -E var1=val2 -E var2=val2 -U LD_PRELOAD -U LD_DEBUG\n"
"Note that if you provide several changes to single variable\n"
"last change will stay in effect.\n"
+#if defined(CONFIG_USE_GUEST_BASE)
+ "\n"
+ "You can use -B option to load target binary into different\n"
+ "address that is specified in elf headers. This can be useful\n"
+ "when target binary would be loaded to low addresses and\n"
+ "/proc/sys/vm/mmap_min_addr is set to higher. For example\n"
+ " qemu-" TARGET_ARCH " -B 0x100000 ...\n"
+ "loads target binary starting from the first meg.\n"
+#endif
,
TARGET_ARCH,
interp_prefix,
@@ -2365,6 +2382,10 @@ int main(int argc, char **argv, char **envp)
#endif
exit(1);
}
+#if defined(CONFIG_USE_GUEST_BASE)
+ } else if (!strcmp(r, "B")) {
+ guest_base = strtol(argv[optind++], NULL, 0);
+#endif
} else if (!strcmp(r, "drop-ld-preload")) {
(void) envlist_unsetenv(envlist, "LD_PRELOAD");
} else if (!strcmp(r, "strace")) {
@@ -2438,6 +2459,36 @@ int main(int argc, char **argv, char **envp)
target_environ = envlist_to_environ(envlist, NULL);
envlist_free(envlist);
+#if defined(CONFIG_USE_GUEST_BASE)
+ /*
+ * Now that page sizes are configured in cpu_init() we can do
+ * proper page alignment for guest_base.
+ */
+ guest_base = HOST_PAGE_ALIGN(guest_base);
+
+ /*
+ * Read in mmap_min_addr kernel parameter and check
+ * whether it is set to some value > 0. This value is used
+ * later on when doing mmap(2)s to calculate where guest_base
+ * is to set, if needed.
+ *
+ * When user has explicitly set the quest base, we skip this
+ * test.
+ */
+ if (guest_base == 0) {
+ FILE *fp;
+
+ if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) {
+ unsigned long tmp;
+ if (fscanf(fp, "%lu", &tmp) == 1) {
+ mmap_min_addr = tmp;
+ qemu_log("kernel mmap_min_addr=%lu\n", mmap_min_addr);
+ }
+ fclose(fp);
+ }
+ }
+#endif /* CONFIG_USE_GUEST_BASE */
+
/*
* Prepare copy of argv vector for target.
*/
@@ -2478,6 +2529,18 @@ int main(int argc, char **argv, char **envp)
free(target_environ);
if (qemu_log_enabled()) {
+#if defined(CONFIG_USE_GUEST_BASE)
+ if (guest_base > 0) {
+ qemu_log("guest_base is set to 0x%lx\n", guest_base);
+ qemu_log(
+ "==========================================================\n"
+ "Note that all target addresses below are given in target\n"
+ "address space which is different from host by guest_base.\n"
+ "For example: target address 0x%x becomes 0x%x and so on.\n"
+ "==========================================================\n",
+ (uintptr_t)0x8000, (uintptr_t)g2h(0x8000));
+ }
+#endif
log_page_dump();
qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 94ae333..5b9abc7 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -126,6 +126,9 @@ typedef struct TaskState {
extern char *exec_path;
void init_task_state(TaskState *ts);
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. */
/*
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c6b0b74..ef2bf55 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2413,6 +2413,8 @@ static inline abi_long do_shmat(int shmid, abi_ulong shmaddr, int shmflg,
}
}
+ *raddr = h2g(*raddr);
+
mmap_unlock();
return 0;
}
diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index e0fd434..7cb51b5 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -560,6 +560,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
/* add x(r1), r0 */
tcg_out_modrm_offset(s, 0x03, r0, r1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_read));
+#elif defined(CONFIG_USE_GUEST_BASE)
+ /*
+ * Add guest_base to all loads.
+ */
+ tcg_out_mov(s, r0, addr_reg); /* movl addr_reg, r0 */
+ tcg_out_addi(s, r0, GUEST_BASE); /* addl $GUEST_BASE, r0 */
#else
r0 = addr_reg;
#endif
@@ -794,6 +800,12 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
/* add x(r1), r0 */
tcg_out_modrm_offset(s, 0x03, r0, r1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_write));
+#elif defined(CONFIG_USE_GUEST_BASE)
+ /*
+ * Add guest_base to all stores.
+ */
+ tcg_out_mov(s, r0, addr_reg); /* movl addr_reg, r0 */
+ tcg_out_addi(s, r0, GUEST_BASE); /* addl $GUEST_BASE, r0 */
#else
r0 = addr_reg;
#endif
diff --git a/tcg/x86_64/tcg-target.c b/tcg/x86_64/tcg-target.c
index 92f0733..204ab2a 100644
--- a/tcg/x86_64/tcg-target.c
+++ b/tcg/x86_64/tcg-target.c
@@ -605,6 +605,12 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
/* add x(r1), r0 */
tcg_out_modrm_offset(s, 0x03 | P_REXW, r0, r1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_read));
+#elif defined(CONFIG_USE_GUEST_BASE)
+ /*
+ * Add guest_base to all loads.
+ */
+ tcg_out_modrm(s, 0x8b | rexw, r0, addr_reg); /* movq addr_reg, r0 */
+ tcg_out_addi(s, r0, GUEST_BASE); /* addq $GUEST_BASE, r0 */
#else
r0 = addr_reg;
#endif
@@ -776,6 +782,12 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
/* add x(r1), r0 */
tcg_out_modrm_offset(s, 0x03 | P_REXW, r0, r1, offsetof(CPUTLBEntry, addend) -
offsetof(CPUTLBEntry, addr_write));
+#elif defined(CONFIG_USE_GUEST_BASE)
+ /*
+ * Add guest_base to all stores.
+ */
+ tcg_out_modrm(s, 0x8b | rexw, r0, addr_reg); /* movq addr_reg, r0 */
+ tcg_out_addi(s, r0, GUEST_BASE); /* addq $GUEST_BASE, r0 */
#else
r0 = addr_reg;
#endif
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 15/17] linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket syscalls
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (13 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 14/17] Revived GUEST_BASE support for usermode emulation targets riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 16/17] Prefer glibc over direct syscalls riku.voipio
` (2 subsequent siblings)
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Mika Westerberg <mika.westerberg@iki.fi>
- This check is not needed because kernel will check whether given
buffer is too small and there is no upper limit for size of the buffer.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/syscall.c | 17 +++++++----------
1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ef2bf55..81366f7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1208,16 +1208,13 @@ static abi_long do_socket(int domain, int type, int protocol)
return get_errno(socket(domain, type, protocol));
}
-/* MAX_SOCK_ADDR from linux/net/socket.c */
-#define MAX_SOCK_ADDR 128
-
/* do_bind() Must return target values and target errnos. */
static abi_long do_bind(int sockfd, abi_ulong target_addr,
socklen_t addrlen)
{
void *addr;
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
+ if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen+1);
@@ -1232,7 +1229,7 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr,
{
void *addr;
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
+ if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen);
@@ -1307,7 +1304,7 @@ static abi_long do_accept(int fd, abi_ulong target_addr,
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
+ if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen);
@@ -1332,7 +1329,7 @@ static abi_long do_getpeername(int fd, abi_ulong target_addr,
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
+ if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen);
@@ -1360,7 +1357,7 @@ static abi_long do_getsockname(int fd, abi_ulong target_addr,
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
+ if (addrlen < 0)
return -TARGET_EINVAL;
addr = alloca(addrlen);
@@ -1398,7 +1395,7 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,
void *host_msg;
abi_long ret;
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
+ if (addrlen < 0)
return -TARGET_EINVAL;
host_msg = lock_user(VERIFY_READ, msg, len, 1);
@@ -1433,7 +1430,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
ret = -TARGET_EFAULT;
goto fail;
}
- if (addrlen < 0 || addrlen > MAX_SOCK_ADDR) {
+ if (addrlen < 0) {
ret = -TARGET_EINVAL;
goto fail;
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 16/17] Prefer glibc over direct syscalls
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (14 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 15/17] linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket syscalls riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 17/17] linux-user: Proper exit code for uncaught signals riku.voipio
2009-03-31 22:31 ` [Qemu-devel] [PATCH 00/17] linux-user patches in maemo Paul Brook
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Riku Voipio <riku.voipio@nokia.com>
The openat/*at syscalls are incredibly common with modern coreutils,
calling them directly via syscalls breaks for example fakeroot. Use
glibc stubs whenever directly available and provide old syscall
calling for people still using older libc.
Patch originally from Mika Westerberg, Adapted to
apply to current trunk and cleaned up by Riku Voipio.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
configure | 53 +++++++++
linux-user/syscall.c | 314 ++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 306 insertions(+), 61 deletions(-)
diff --git a/configure b/configure
index 8b0a378..9b882f8 100755
--- a/configure
+++ b/configure
@@ -1111,6 +1111,53 @@ EOF
fi
fi
+#
+# Check for xxxat() functions when we are building linux-user
+# emulator. This is done because older glibc versions don't
+# have syscall stubs for these implemented.
+#
+atfile=no
+if [ "$linux_user" = "yes" ] ; then
+ cat > $TMPC << EOF
+#define _ATFILE_SOURCE
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ /* try to unlink nonexisting file */
+ return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
+}
+EOF
+ if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+ atfile=yes
+ fi
+fi
+
+# Check for initofy functions when we are building linux-user
+# emulator. This is done because older glibc versions don't
+# have syscall stubs for these implemented. In that case we
+# don't provide them even if kernel supports them.
+#
+inotify=no
+if [ "$linux_user" = "yes" ] ; then
+ cat > $TMPC << EOF
+#include <sys/inotify.h>
+
+int
+main(void)
+{
+ /* try to start inotify */
+ return inotify_init(void);
+}
+EOF
+ if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+ inotify=yes
+ fi
+fi
+
# Check if tools are available to build documentation.
if [ -x "`which texi2html 2>/dev/null`" ] && \
[ -x "`which pod2man 2>/dev/null`" ]; then
@@ -1491,6 +1538,12 @@ if test "$curses" = "yes" ; then
echo "CONFIG_CURSES=yes" >> $config_mak
echo "CURSES_LIBS=-lcurses" >> $config_mak
fi
+if test "$atfile" = "yes" ; then
+ echo "#define CONFIG_ATFILE 1" >> $config_h
+fi
+if test "$inotify" = "yes" ; then
+ echo "#define CONFIG_INOTIFY 1" >> $config_h
+fi
if test "$brlapi" = "yes" ; then
echo "CONFIG_BRLAPI=yes" >> $config_mak
echo "#define CONFIG_BRLAPI 1" >> $config_h
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 81366f7..17f7cdb 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -53,6 +53,7 @@
#include <sys/statfs.h>
#include <utime.h>
#include <sys/sysinfo.h>
+#include <sys/utsname.h>
//#include <sys/user.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
@@ -200,7 +201,229 @@ static int gettid(void) {
return -ENOSYS;
}
#endif
-_syscall1(int,sys_uname,struct new_utsname *,buf)
+#if TARGET_ABI_BITS == 32
+_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count);
+#endif
+#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
+_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count);
+#endif
+_syscall2(int, sys_getpriority, int, which, int, who);
+#if !defined (__x86_64__)
+_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
+ loff_t *, res, uint, wh);
+#endif
+_syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo)
+_syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
+#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
+_syscall3(int,sys_tgkill,int,tgid,int,pid,int,sig)
+#endif
+#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
+_syscall2(int,sys_tkill,int,tid,int,sig)
+#endif
+#ifdef __NR_exit_group
+_syscall1(int,exit_group,int,error_code)
+#endif
+#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
+_syscall1(int,set_tid_address,int *,tidptr)
+#endif
+#if defined(USE_NPTL)
+#if defined(TARGET_NR_futex) && defined(__NR_futex)
+_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
+ const struct timespec *,timeout,int *,uaddr2,int,val3)
+#endif
+#endif
+
+static bitmask_transtbl fcntl_flags_tbl[] = {
+ { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
+ { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, },
+ { TARGET_O_CREAT, TARGET_O_CREAT, O_CREAT, O_CREAT, },
+ { TARGET_O_EXCL, TARGET_O_EXCL, O_EXCL, O_EXCL, },
+ { TARGET_O_NOCTTY, TARGET_O_NOCTTY, O_NOCTTY, O_NOCTTY, },
+ { TARGET_O_TRUNC, TARGET_O_TRUNC, O_TRUNC, O_TRUNC, },
+ { TARGET_O_APPEND, TARGET_O_APPEND, O_APPEND, O_APPEND, },
+ { TARGET_O_NONBLOCK, TARGET_O_NONBLOCK, O_NONBLOCK, O_NONBLOCK, },
+ { TARGET_O_SYNC, TARGET_O_SYNC, O_SYNC, O_SYNC, },
+ { TARGET_FASYNC, TARGET_FASYNC, FASYNC, FASYNC, },
+ { TARGET_O_DIRECTORY, TARGET_O_DIRECTORY, O_DIRECTORY, O_DIRECTORY, },
+ { TARGET_O_NOFOLLOW, TARGET_O_NOFOLLOW, O_NOFOLLOW, O_NOFOLLOW, },
+ { TARGET_O_LARGEFILE, TARGET_O_LARGEFILE, O_LARGEFILE, O_LARGEFILE, },
+#if defined(O_DIRECT)
+ { TARGET_O_DIRECT, TARGET_O_DIRECT, O_DIRECT, O_DIRECT, },
+#endif
+ { 0, 0, 0, 0 }
+};
+
+#define COPY_UTSNAME_FIELD(dest, src) \
+ do { \
+ /* __NEW_UTS_LEN doesn't include terminating null */ \
+ (void) strncpy((dest), (src), __NEW_UTS_LEN); \
+ (dest)[__NEW_UTS_LEN] = '\0'; \
+ } while (0)
+
+static int sys_uname(struct new_utsname *buf)
+{
+ struct utsname uts_buf;
+
+ if (uname(&uts_buf) < 0)
+ return (-1);
+
+ /*
+ * Just in case these have some differences, we
+ * translate utsname to new_utsname (which is the
+ * struct linux kernel uses).
+ */
+
+ bzero(buf, sizeof (*buf));
+ COPY_UTSNAME_FIELD(buf->sysname, uts_buf.sysname);
+ COPY_UTSNAME_FIELD(buf->nodename, uts_buf.nodename);
+ COPY_UTSNAME_FIELD(buf->release, uts_buf.release);
+ COPY_UTSNAME_FIELD(buf->version, uts_buf.version);
+ COPY_UTSNAME_FIELD(buf->machine, uts_buf.machine);
+#ifdef _GNU_SOURCE
+ COPY_UTSNAME_FIELD(buf->domainname, uts_buf.domainname);
+#endif
+ return (0);
+
+#undef COPY_UTSNAME_FIELD
+}
+
+static int sys_getcwd1(char *buf, size_t size)
+{
+ if (getcwd(buf, size) == NULL) {
+ /* getcwd() sets errno */
+ return (-1);
+ }
+ return (0);
+}
+
+#ifdef CONFIG_ATFILE
+/*
+ * Host system seems to have atfile syscall stubs available. We
+ * now enable them one by one as specified by target syscall_nr.h.
+ */
+
+#ifdef TARGET_NR_faccessat
+static int sys_faccessat(int dirfd, const char *pathname, int mode, int flags)
+{
+ return (faccessat(dirfd, pathname, mode, flags));
+}
+#endif
+#ifdef TARGET_NR_fchmodat
+static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
+{
+ return (fchmodat(dirfd, pathname, mode, flags));
+}
+#endif
+#ifdef TARGET_NR_fchownat
+static int sys_fchownat(int dirfd, const char *pathname, uid_t owner,
+ gid_t group, int flags)
+{
+ return (fchownat(dirfd, pathname, owner, group, flags));
+}
+#endif
+#ifdef __NR_fstatat64
+static int sys_fstatat64(int dirfd, const char *pathname, struct stat *buf,
+ int flags)
+{
+ return (fstatat(dirfd, pathname, buf, flags));
+}
+#endif
+#ifdef __NR_newfstatat
+static int sys_newfstatat(int dirfd, const char *pathname, struct stat *buf,
+ int flags)
+{
+ return (fstatat(dirfd, pathname, buf, flags));
+}
+#endif
+#ifdef TARGET_NR_futimesat
+static int sys_futimesat(int dirfd, const char *pathname,
+ const struct timeval times[2])
+{
+ return (futimesat(dirfd, pathname, times));
+}
+#endif
+#ifdef TARGET_NR_linkat
+static int sys_linkat(int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath, int flags)
+{
+ return (linkat(olddirfd, oldpath, newdirfd, newpath, flags));
+}
+#endif
+#ifdef TARGET_NR_mkdirat
+static int sys_mkdirat(int dirfd, const char *pathname, mode_t mode)
+{
+ return (mkdirat(dirfd, pathname, mode));
+}
+#endif
+#ifdef TARGET_NR_mknodat
+static int sys_mknodat(int dirfd, const char *pathname, mode_t mode,
+ dev_t dev)
+{
+ return (mknodat(dirfd, pathname, mode, dev));
+}
+#endif
+#ifdef TARGET_NR_openat
+static int sys_openat(int dirfd, const char *pathname, int flags, ...)
+{
+ /*
+ * open(2) has extra parameter 'mode' when called with
+ * flag O_CREAT.
+ */
+ if ((flags & O_CREAT) != 0) {
+ va_list ap;
+ mode_t mode;
+
+ /*
+ * Get the 'mode' parameter and translate it to
+ * host bits.
+ */
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ mode = target_to_host_bitmask(mode, fcntl_flags_tbl);
+ va_end(ap);
+
+ return (openat(dirfd, pathname, flags, mode));
+ }
+ return (openat(dirfd, pathname, flags));
+}
+#endif
+#ifdef TARGET_NR_readlinkat
+static int sys_readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz)
+{
+ return (readlinkat(dirfd, pathname, buf, bufsiz));
+}
+#endif
+#ifdef TARGET_NR_renameat
+static int sys_renameat(int olddirfd, const char *oldpath,
+ int newdirfd, const char *newpath)
+{
+ return (renameat(olddirfd, oldpath, newdirfd, newpath));
+}
+#endif
+#ifdef TARGET_NR_symlinkat
+static int sys_symlinkat(const char *oldpath, int newdirfd, const char *newpath)
+{
+ return (symlinkat(oldpath, newdirfd, newpath));
+}
+#endif
+#ifdef TARGET_NR_unlinkat
+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 */
+
+/*
+ * Try direct syscalls instead
+ */
#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
_syscall4(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode,int,flags)
#endif
@@ -221,21 +444,14 @@ _syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname,
_syscall3(int,sys_futimesat,int,dirfd,const char *,pathname,
const struct timeval *,times)
#endif
-_syscall2(int,sys_getcwd1,char *,buf,size_t,size)
-#if TARGET_ABI_BITS == 32
-_syscall3(int, sys_getdents, uint, fd, struct linux_dirent *, dirp, uint, count);
-#endif
-#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
-_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint, count);
-#endif
-_syscall2(int, sys_getpriority, int, which, int, who);
-#if !defined (__x86_64__)
-_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
- loff_t *, res, uint, wh);
+#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
+ defined(__NR_newfstatat)
+_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
+ struct stat *,buf,int,flags)
#endif
#if defined(TARGET_NR_linkat) && defined(__NR_linkat)
_syscall5(int,sys_linkat,int,olddirfd,const char *,oldpath,
- int,newdirfd,const char *,newpath,int,flags)
+ int,newdirfd,const char *,newpath,int,flags)
#endif
#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)
_syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
@@ -244,11 +460,6 @@ _syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode)
_syscall4(int,sys_mknodat,int,dirfd,const char *,pathname,
mode_t,mode,dev_t,dev)
#endif
-#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \
- defined(__NR_newfstatat)
-_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname,
- struct stat *,buf,int,flags)
-#endif
#if defined(TARGET_NR_openat) && defined(__NR_openat)
_syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode)
#endif
@@ -260,24 +471,10 @@ _syscall4(int,sys_readlinkat,int,dirfd,const char *,pathname,
_syscall4(int,sys_renameat,int,olddirfd,const char *,oldpath,
int,newdirfd,const char *,newpath)
#endif
-_syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo)
#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)
_syscall3(int,sys_symlinkat,const char *,oldpath,
int,newdirfd,const char *,newpath)
#endif
-_syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
-#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
-_syscall3(int,sys_tgkill,int,tgid,int,pid,int,sig)
-#endif
-#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
-_syscall2(int,sys_tkill,int,tid,int,sig)
-#endif
-#ifdef __NR_exit_group
-_syscall1(int,exit_group,int,error_code)
-#endif
-#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
-_syscall1(int,set_tid_address,int *,tidptr)
-#endif
#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)
_syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags)
#endif
@@ -285,21 +482,36 @@ _syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags)
_syscall4(int,sys_utimensat,int,dirfd,const char *,pathname,
const struct timespec *,tsp,int,flags)
#endif
+
+#endif /* CONFIG_ATFILE */
+
+#ifdef CONFIG_INOTIFY
+
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
-_syscall0(int,sys_inotify_init)
+static int sys_inotify_init(void)
+{
+ return (inotify_init());
+}
#endif
#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
-_syscall3(int,sys_inotify_add_watch,int,fd,const char *,pathname,uint32_t,mask)
+static int sys_inotify_add_watch(int fd,const char *pathname, int32_t mask)
+{
+ return (inotify_add_watch(fd, pathname, mask));
+}
#endif
#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
-_syscall2(int,sys_inotify_rm_watch,int,fd,uint32_t,wd)
-#endif
-#if defined(USE_NPTL)
-#if defined(TARGET_NR_futex) && defined(__NR_futex)
-_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
- const struct timespec *,timeout,int *,uaddr2,int,val3)
-#endif
+static int sys_inotify_rm_watch(int fd, int32_t wd)
+{
+ return (inotify_rm_watch(fd,pathname, wd));
+}
#endif
+#else
+/* Userspace can usually survive runtime without inotify */
+#undef TARGET_NR_inotify_init
+#undef TARGET_NR_inotify_add_watch
+#undef TARGET_NR_inotify_rm_watch
+#endif /* CONFIG_INOTIFY */
+
extern int personality(int);
extern int flock(int, int);
@@ -2841,26 +3053,6 @@ static bitmask_transtbl mmap_flags_tbl[] = {
{ 0, 0, 0, 0 }
};
-static bitmask_transtbl fcntl_flags_tbl[] = {
- { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
- { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, },
- { TARGET_O_CREAT, TARGET_O_CREAT, O_CREAT, O_CREAT, },
- { TARGET_O_EXCL, TARGET_O_EXCL, O_EXCL, O_EXCL, },
- { TARGET_O_NOCTTY, TARGET_O_NOCTTY, O_NOCTTY, O_NOCTTY, },
- { TARGET_O_TRUNC, TARGET_O_TRUNC, O_TRUNC, O_TRUNC, },
- { TARGET_O_APPEND, TARGET_O_APPEND, O_APPEND, O_APPEND, },
- { TARGET_O_NONBLOCK, TARGET_O_NONBLOCK, O_NONBLOCK, O_NONBLOCK, },
- { TARGET_O_SYNC, TARGET_O_SYNC, O_SYNC, O_SYNC, },
- { TARGET_FASYNC, TARGET_FASYNC, FASYNC, FASYNC, },
- { TARGET_O_DIRECTORY, TARGET_O_DIRECTORY, O_DIRECTORY, O_DIRECTORY, },
- { TARGET_O_NOFOLLOW, TARGET_O_NOFOLLOW, O_NOFOLLOW, O_NOFOLLOW, },
- { TARGET_O_LARGEFILE, TARGET_O_LARGEFILE, O_LARGEFILE, O_LARGEFILE, },
-#if defined(O_DIRECT)
- { TARGET_O_DIRECT, TARGET_O_DIRECT, O_DIRECT, O_DIRECT, },
-#endif
- { 0, 0, 0, 0 }
-};
-
#if defined(TARGET_I386)
/* NOTE: there is really one LDT for all the threads */
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [Qemu-devel] [PATCH 17/17] linux-user: Proper exit code for uncaught signals
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (15 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 16/17] Prefer glibc over direct syscalls riku.voipio
@ 2009-03-31 20:40 ` riku.voipio
2009-03-31 22:31 ` [Qemu-devel] [PATCH 00/17] linux-user patches in maemo Paul Brook
17 siblings, 0 replies; 27+ messages in thread
From: riku.voipio @ 2009-03-31 20:40 UTC (permalink / raw)
To: qemu-devel
From: Riku Voipio <riku.voipio@iki.fi>
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 actually die from an uncaught signal.
A default signal handler is installed, we send ourself a signal
and we wait for it to arrive.
Patch originates from Scratchbox
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
linux-user/signal.c | 37 +++++++++++++++++++++++++------------
1 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index fc37dc1..7504725 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <errno.h>
+#include <assert.h>
#include <sys/ucontext.h>
#include "qemu.h"
@@ -352,22 +353,34 @@ static inline void free_sigqueue(CPUState *env, struct sigqueue *q)
static void QEMU_NORETURN force_sig(int sig)
{
int host_sig;
+ struct sigaction act;
host_sig = target_to_host_signal(sig);
fprintf(stderr, "qemu: uncaught target signal %d (%s) - exiting\n",
sig, strsignal(host_sig));
-#if 1
gdb_signalled(thread_env, sig);
- _exit(-host_sig);
-#else
- {
- struct sigaction act;
- sigemptyset(&act.sa_mask);
- act.sa_flags = SA_SIGINFO;
- act.sa_sigaction = SIG_DFL;
- sigaction(SIGABRT, &act, NULL);
- abort();
- }
-#endif
+
+ /* 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
+ * actually die from an uncaught signal. Here the default signal
+ * handler is installed, we send ourself a signal and we wait for
+ * it to arrive. */
+ sigfillset(&act.sa_mask);
+ act.sa_handler = SIG_DFL;
+ sigaction(host_sig, &act, NULL);
+
+ /* For some reason raise(host_sig) doesn't send the signal when
+ * statically linked on x86-64. */
+ kill(getpid(), host_sig);
+
+ /* Make sure the signal isn't masked (just reuse the mask inside
+ of act) */
+ sigdelset(&act.sa_mask, host_sig);
+ sigsuspend(&act.sa_mask);
+
+ /* unreachable */
+ assert(0);
+
}
/* queue a signal so that it will be send to the virtual CPU as soon
--
1.6.2.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support.
2009-03-31 20:40 ` [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support riku.voipio
@ 2009-03-31 21:31 ` Paul Brook
2009-04-01 6:49 ` Mika Westerberg
0 siblings, 1 reply; 27+ messages in thread
From: Paul Brook @ 2009-03-31 21:31 UTC (permalink / raw)
To: qemu-devel; +Cc: riku.voipio
On Tuesday 31 March 2009, riku.voipio@iki.fi wrote:
> From: Mika Westerberg <mika.westerberg@iki.fi>
>
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> ---
> linux-user/strace.c | 170
> ++++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list |
> 101 +++++++++++++++++-----------
> 2 files changed, 232 insertions(+), 39 deletions(-)
It would help if you included a description of what the patch actually does.
> + * This function locks strings from guest memory and prints
> + * strace output according to format specified in strace.list.
This seems a poor way of implementing this. Much better would be to parse the
format string and make this happen automatically for %s arguments and/or add
a new format specifier.
Paul
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 14/17] Revived GUEST_BASE support for usermode emulation targets.
2009-03-31 20:40 ` [Qemu-devel] [PATCH 14/17] Revived GUEST_BASE support for usermode emulation targets riku.voipio
@ 2009-03-31 21:51 ` Paul Brook
0 siblings, 0 replies; 27+ messages in thread
From: Paul Brook @ 2009-03-31 21:51 UTC (permalink / raw)
To: qemu-devel; +Cc: riku.voipio
On Tuesday 31 March 2009, riku.voipio@iki.fi wrote:
> + "You can use -B option to load target binary into different\n"
> + "address that is specified in elf headers. This can be
> useful\n" + "when target binary would be loaded to low addresses
> and\n" + "/proc/sys/vm/mmap_min_addr is set to higher. For
> example\n" + " qemu-" TARGET_ARCH " -B 0x100000 ...\n"
> + "loads target binary starting from the first meg.\n"
This is wrong. -B is completely transparent to the guest application and
offsets the whole guest address space.
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index c6b0b74..ef2bf55 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2413,6 +2413,8 @@ static inline abi_long do_shmat(int shmid, abi_ulong
> shmaddr, int shmflg, }
> }
>
> + *raddr = h2g(*raddr);
> +
This is wrong. host and guest addresses are different sizes.
This sort of bugfix should also be separated from the host support. Especially
as the bogus code comes from one of your earlier patches.
Paul
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 05/17] Fix and cleanup IPCOP_shm* ipc calls handling
2009-03-31 20:40 ` [Qemu-devel] [PATCH 05/17] Fix and cleanup IPCOP_shm* ipc calls handling riku.voipio
@ 2009-03-31 22:08 ` Paul Brook
0 siblings, 0 replies; 27+ messages in thread
From: Paul Brook @ 2009-03-31 22:08 UTC (permalink / raw)
To: qemu-devel; +Cc: riku.voipio
On Tuesday 31 March 2009, riku.voipio@iki.fi wrote:
> + *raddr = (unsigned long) shmat(shmid, g2h(shmaddr), shmflg);
This is wrong. You need to handle NULL properly.
Paul
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 00/17] linux-user patches in maemo
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
` (16 preceding siblings ...)
2009-03-31 20:40 ` [Qemu-devel] [PATCH 17/17] linux-user: Proper exit code for uncaught signals riku.voipio
@ 2009-03-31 22:31 ` Paul Brook
2009-04-01 9:31 ` Riku Voipio
17 siblings, 1 reply; 27+ messages in thread
From: Paul Brook @ 2009-03-31 22:31 UTC (permalink / raw)
To: qemu-devel; +Cc: riku.voipio
> This some of the more cleaner linux-user patches maemo version
> of qemu carries. The idea was to setup a "linux-user-for-upstream"
> branch to git.maemo.org, but unfortunately the server is refusink
> my git pushes ATM.
These patches don't seem particularly coherent.
Some of them actually depend on preceding patches, others implement completely
independent features.
In some places you modify code, only to change that code again in a later
patch. For example patch #7 appears to be purely a fix for bugs introduced by
patch #5
Paul
^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix runningdbus
2009-03-31 20:40 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix running dbus riku.voipio
@ 2009-03-31 23:36 ` Krumme, Chris
2009-04-05 18:04 ` Riku Voipio
0 siblings, 1 reply; 27+ messages in thread
From: Krumme, Chris @ 2009-03-31 23:36 UTC (permalink / raw)
To: qemu-devel
Hello Riku,
> -----Original Message-----
> From:
> qemu-devel-bounces+chris.krumme=windriver.com@nongnu.org
> [mailto:qemu-devel-bounces+chris.krumme=windriver.com@nongnu.o
> rg] On Behalf Of riku.voipio@iki.fi
> Sent: Tuesday, March 31, 2009 3:41 PM
> To: qemu-devel@nongnu.org
> Subject: [Qemu-devel] [PATCH 12/17] linux-user: unix sockets
> - fix runningdbus
>
> From: Riku Voipio <riku.voipio@iki.fi>
>
> dbus sends too short (according to man 7 unix) addrlen for it's
> unix socket. I've been told that happens with other applications
> as well. Linux kernel doesn't appear to mind, so I guess
> we whould be tolerant as well. Expand sockaddr with +1 to fit
> the \0 of the pathname passed.
>
> (scratchbox1 qemu had a very different workaround for the same issue).
>
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> ---
> linux-user/syscall.c | 29 +++++++++++++++++++++++++++--
> 1 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 56868ff..c6b0b74 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -44,6 +44,7 @@
> #include <signal.h>
> #include <sched.h>
> #include <sys/socket.h>
> +#include <sys/un.h>
> #include <sys/uio.h>
> #include <sys/poll.h>
> #include <sys/times.h>
> @@ -735,13 +736,37 @@ static inline abi_long
> target_to_host_sockaddr(struct sockaddr *addr,
> abi_ulong target_addr,
> socklen_t len)
> {
> + const socklen_t unix_maxlen = sizeof (struct sockaddr_un);
> + sa_family_t sa_family;
> struct target_sockaddr *target_saddr;
>
> target_saddr = lock_user(VERIFY_READ, target_addr, len, 1);
> if (!target_saddr)
> return -TARGET_EFAULT;
> +
> + sa_family = tswap16(target_saddr->sa_family);
> +
> + /* Oops. The caller might send a incomplete sun_path; sun_path
> + * must be terminated by \0 (see the manual page), but
> + * unfortunately it is quite common to specify sockaddr_un
> + * length as "strlen(x->sun_path)" while it should be
> + * "strlen(...) + 1". We'll fix that here if needed.
> + * Linux kernel has a similar feature.
> + */
> +
> + if (sa_family == AF_UNIX) {
> + if (len < unix_maxlen) {
> + char *cp = (char*)target_saddr;
> +
> + if ( cp[len-1] && !cp[len] )
This could be a little weird if len were 0.
Thanks
Chris
> + len++;
> + }
> + if (len > unix_maxlen)
> + len = unix_maxlen;
> + }
> +
> memcpy(addr, target_saddr, len);
> - addr->sa_family = tswap16(target_saddr->sa_family);
> + addr->sa_family = sa_family;
> unlock_user(target_saddr, target_addr, 0);
>
> return 0;
> @@ -1195,7 +1220,7 @@ static abi_long do_bind(int sockfd,
> abi_ulong target_addr,
> if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
> return -TARGET_EINVAL;
>
> - addr = alloca(addrlen);
> + addr = alloca(addrlen+1);
>
> target_to_host_sockaddr(addr, target_addr, addrlen);
> return get_errno(bind(sockfd, addr, addrlen));
> --
> 1.6.2.1
>
>
>
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support.
2009-03-31 21:31 ` Paul Brook
@ 2009-04-01 6:49 ` Mika Westerberg
0 siblings, 0 replies; 27+ messages in thread
From: Mika Westerberg @ 2009-04-01 6:49 UTC (permalink / raw)
To: qemu-devel; +Cc: riku.voipio
[-- Attachment #1: Type: text/plain, Size: 1128 bytes --]
Hi,
On Wed, Apr 1, 2009 at 12:31 AM, Paul Brook <paul@codesourcery.com> wrote:
> On Tuesday 31 March 2009, riku.voipio@iki.fi wrote:
> > From: Mika Westerberg <mika.westerberg@iki.fi>
> >
> > Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> > ---
> > linux-user/strace.c | 170
> > ++++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list |
> > 101 +++++++++++++++++-----------
> > 2 files changed, 232 insertions(+), 39 deletions(-)
>
> It would help if you included a description of what the patch actually
> does.
>
> > + * This function locks strings from guest memory and prints
> > + * strace output according to format specified in strace.list.
>
> This seems a poor way of implementing this. Much better would be to parse
> the
> format string and make this happen automatically for %s arguments and/or
> add
> a new format specifier.
This patch came from me and even I didn't like it when I wrote it :)
How about adding per syscall print function like in actual strace? This way
we can get
more accurate (and correct format for flags etc.) output.
I will re-implement this asap.
Thanks,
MW
[-- Attachment #2: Type: text/html, Size: 1765 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 00/17] linux-user patches in maemo
2009-03-31 22:31 ` [Qemu-devel] [PATCH 00/17] linux-user patches in maemo Paul Brook
@ 2009-04-01 9:31 ` Riku Voipio
2009-04-01 12:07 ` Aurelien Jarno
0 siblings, 1 reply; 27+ messages in thread
From: Riku Voipio @ 2009-04-01 9:31 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
On Tue, Mar 31, 2009 at 10:31:42PM +0000, Paul Brook wrote:
> > This some of the more cleaner linux-user patches maemo version
> > of qemu carries. The idea was to setup a "linux-user-for-upstream"
> > branch to git.maemo.org, but unfortunately the server is refusink
> > my git pushes ATM.
> These patches don't seem particularly coherent.
> Some of them actually depend on preceding patches, others implement completely
> independent features.
No problem, I can split these to smaller series.
> In some places you modify code, only to change that code again in a later
> patch. For example patch #7 appears to be purely a fix for bugs introduced by
> patch #5
These specific patches are unmodified patches submitted by Kirill in October
last year, without anyone complaining.. I'll squash patches together where
newer ones changes code of older patches.
--
"rm -rf" only sounds scary if you don't have backups
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 00/17] linux-user patches in maemo
2009-04-01 9:31 ` Riku Voipio
@ 2009-04-01 12:07 ` Aurelien Jarno
0 siblings, 0 replies; 27+ messages in thread
From: Aurelien Jarno @ 2009-04-01 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook
On Wed, Apr 01, 2009 at 12:31:17PM +0300, Riku Voipio wrote:
> On Tue, Mar 31, 2009 at 10:31:42PM +0000, Paul Brook wrote:
> > > This some of the more cleaner linux-user patches maemo version
> > > of qemu carries. The idea was to setup a "linux-user-for-upstream"
> > > branch to git.maemo.org, but unfortunately the server is refusink
> > > my git pushes ATM.
>
> > These patches don't seem particularly coherent.
> > Some of them actually depend on preceding patches, others implement completely
> > independent features.
>
> No problem, I can split these to smaller series.
>
> > In some places you modify code, only to change that code again in a later
> > patch. For example patch #7 appears to be purely a fix for bugs introduced by
> > patch #5
>
> These specific patches are unmodified patches submitted by Kirill in October
> last year, without anyone complaining.. I'll squash patches together where
> newer ones changes code of older patches.
>
The one from October are actually a resent of an earlier series. I
haven't look at the one you selected, but from what I remember they have
a lot of unrelated indentation change, making them difficult to review.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix runningdbus
2009-03-31 23:36 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix runningdbus Krumme, Chris
@ 2009-04-05 18:04 ` Riku Voipio
0 siblings, 0 replies; 27+ messages in thread
From: Riku Voipio @ 2009-04-05 18:04 UTC (permalink / raw)
To: qemu-devel
On Tue, Mar 31, 2009 at 04:36:58PM -0700, Krumme, Chris wrote:
> > + if (sa_family == AF_UNIX) {
> > + if (len < unix_maxlen) {
> > + char *cp = (char*)target_saddr;
> > +
> > + if ( cp[len-1] && !cp[len] )
> This could be a little weird if len were 0.
Oops, patch fixed.
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2009-04-05 18:04 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-31 20:40 [Qemu-devel] [PATCH 00/17] linux-user patches in maemo riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 01/17] Fix fstatat64()/newfstatat() syscall implementation riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 02/17] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 03/17] Fix and cleanup IPCOP_sem* ipc calls handling riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 04/17] Implement sem* syscalls riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 05/17] Fix and cleanup IPCOP_shm* ipc calls handling riku.voipio
2009-03-31 22:08 ` Paul Brook
2009-03-31 20:40 ` [Qemu-devel] [PATCH 06/17] Implement shm* syscalls riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 07/17] shmat(): use mmap_find_vma to find free memory area riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 08/17] Added posix message queue syscalls except mq_notify riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 09/17] Format mq_open strace arguments riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 10/17] More strace formatting for posix message queues syscalls riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 11/17] Add support for passing contents of argv0 riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix running dbus riku.voipio
2009-03-31 23:36 ` [Qemu-devel] [PATCH 12/17] linux-user: unix sockets - fix runningdbus Krumme, Chris
2009-04-05 18:04 ` Riku Voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 13/17] Strace is now working again with GUEST_BASE support riku.voipio
2009-03-31 21:31 ` Paul Brook
2009-04-01 6:49 ` Mika Westerberg
2009-03-31 20:40 ` [Qemu-devel] [PATCH 14/17] Revived GUEST_BASE support for usermode emulation targets riku.voipio
2009-03-31 21:51 ` Paul Brook
2009-03-31 20:40 ` [Qemu-devel] [PATCH 15/17] linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket syscalls riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 16/17] Prefer glibc over direct syscalls riku.voipio
2009-03-31 20:40 ` [Qemu-devel] [PATCH 17/17] linux-user: Proper exit code for uncaught signals riku.voipio
2009-03-31 22:31 ` [Qemu-devel] [PATCH 00/17] linux-user patches in maemo Paul Brook
2009-04-01 9:31 ` Riku Voipio
2009-04-01 12:07 ` Aurelien Jarno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).