Skip to contentSkip to conversation

Updated RFC: linux user problems]]

Qemu-devel J. Mayer 3 participants 5 messages Sep 21, 2007 – Sep 25, 2007

lore
Share & tools
lore

J. Mayer

author
#0 lore raw

-------- 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_long value instead of long/unsigned long.
I also included the #ifdef protection for do_socketcall and do_ipc to avoid compilation warnings.
And I also converted the fd given to do_ioctl to be an int.

In addition to my previous remarks, I noticed some other things while reading the code:
- the do_msgctl function seems very strange to me. It looks like half of the code is missing in the switch...
- do_ipc directly uses pointers from the emulated environment without using lock_user related functions like it seems to be done everywhere else.
- there are at least two problems in IPCOP_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 be target_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: 4669

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.

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
diff -u -d -d -p -r1.33 qemu.h
@@ -126,10 +127,11 @@ int load_flt_binary(struct linux_binprm 
 void 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

#1 lore raw

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_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...

Fine with me, FWIW.

Thiemo

#2 lore raw
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_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...

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...

#3 lore raw

I've often wondered why there isn't a tswap_target_ulong(). Seems like using tswap32() is asking for trouble.

author
#4 lore raw
Quoted 2 lines · Thayne Harbaugh

I've often wondered why there isn't a tswap_target_ulong(). Seems like using tswap32() is asking for trouble.

Isn't it tswapl ?

Signature · 2 lines
J. Mayer <[email protected]>
Never organized