Updated RFC: linux user problems]]
-------- Forwarded Message --------
Quoted 6 lines
From: Jocelyn Mayer <[email protected]>
Reply-To: [email protected], [email protected]
To: [email protected]
Subject: Re: [Fwd: [Qemu-devel] RFC: linux user problems]
Date: Wed, 19 Sep 2007 11:23:03 +0200
Quoted 44 lines
Quoted 43 lines · Thiemo Seufer
Quoted 37 lines · J. Mayer
Following my previous message, I did a patch that makes syscalls take target_long/target_ulong argument and return
target_longvalue instead of long/unsigned long.
I also included the #ifdef protection fordo_socketcallanddo_ipcto avoid compilation warnings.
And I also converted the fd given todo_ioctlto be an int.In addition to my previous remarks, I noticed some other things while reading the code:
- thedo_msgctlfunction seems very strange to me. It looks like half of the code is missing in the switch...
-do_ipcdirectly uses pointers from the emulated environment without usinglock_userrelated functions like it seems to be done everywhere else.
- there are at least two problems inIPCOP_shmat:
* the returned address could not fit in the target address space when
emulating a 32 bits
target on a 64 bits host
* the returned address is always casted into a 32 bits value. I changed this to betarget_ulong.
- I also noticed some suspicious warnings (cast between pointer and integer of different size) that may hide other problems:
* target_to_host_cmsg:567
* host_to_target_cmsg:612
* do_ipc:1608
*do_ipc: 1620
*do_ipc: 1644
*do_ipc: 1654
*do_ipc: 1676 (multiple times)
*do_ipc: 1688
*do_ipc: 1710
* write_ldt:2009
* do_syscall:2684
*do_syscall: 3901
*do_syscall: 3902
*do_syscall: 4669Quoted 2 lines
May someone take a look at my patch and say if it seems reasonable to include this in the repository ?
Looks reasonable, but introduces new compiler warnings (on a ppc32/Linux host):
The reported warnings have been fixed.
There are still a lot of warnings related to 32/64 bits invalid casts on 64 bits hosts (see above) which will need to be fixed once.
I also changed some parameters of do_ipc from long to int (instead of target_long), following the do_ipc man page specification, and reported this change in child functions. There may be more to do...
Please comment...
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Index: linux-user/qemu.h
===================================================================
RCS file: /sources/qemu/qemu/linux-user/qemu.h,v
retrieving revision 1.33
qemu.h +4 -3
@@ -126,10 +127,11 @@ int load_flt_binary(struct linux_binprmvoid memcpy_to_target (target_ulong dest,const void *src,unsigned long len);void target_set_brk (target_ulong new_brk); -long do_brk (target_ulong new_brk); +target_long do_brk (target_ulong new_brk);void syscall_init (void ); -long do_syscall (void *cpu_env,int num,long arg1,long arg2,long arg3, -long arg4,long arg5,long arg6); +target_long do_syscall (void *cpu_env,int num,target_long arg1, +target_long arg2,target_long arg3,target_long arg4, +target_long arg5,target_long arg6);void gemu_log (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));extern CPUState *global_env;void cpu_loop (CPUState *env);
Index: linux-user/syscall.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.121
syscall.c +104 -80
507 lines not on this page · raw message
J. Mayer wrote:
[snip]
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
May someone take a look at my patch and say if it seems reasonable to include this in the repository ?
Looks reasonable, but introduces new compiler warnings (on a ppc32/Linux host):
The reported warnings have been fixed.
There are still a lot of warnings related to 32/64 bits invalid casts on 64 bits hosts (see above) which will need to be fixed once.
Quoted 5 lines
I also changed some parameters of
do_ipcfrom long to int (instead oftarget_long), following thedo_ipcman page specification, and reported this change in child functions. There may be more to do...Please comment...
Fine with me, FWIW.
Thiemo
Quoted 12 lines · Thiemo Seufer
J. Mayer wrote:
[snip]Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
May someone take a look at my patch and say if it seems reasonable to include this in the repository ?
Looks reasonable, but introduces new compiler warnings (on a ppc32/Linux host):
The reported warnings have been fixed.
There are still a lot of warnings related to 32/64 bits invalid casts on 64 bits hosts (see above) which will need to be fixed once.
Quoted 7 lines
Quoted 5 lines
I also changed some parameters of
do_ipcfrom long to int (instead oftarget_long), following thedo_ipcman page specification, and reported this change in child functions. There may be more to do...Please comment...
Fine with me, FWIW.
Great. I may do another pass, to check all helpers against long/int confusion to avoid using target_ulong when not necessary. I would appreciate anyone who would test the patch on other platforms than x86 / PowerPC, as I would like not to break everything...
I've often wondered why there isn't a tswap_target_ulong(). Seems like using tswap32() is asking for trouble.
Quoted 2 lines · Thayne Harbaugh
I've often wondered why there isn't a
tswap_target_ulong(). Seems like usingtswap32()is asking for trouble.
Isn't it tswapl ?
Signature · 2 lines
J. Mayer <[email protected]> Never organized