RFC: fix run of 32 bits Linux executables on 64 bits targets
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
First of all, the personality was never set to PER_LINUX32 The second problem was that pointers used to set the values on the stack were still of target_ulong size, which lead 32 bits executable crash dereferencing NULL pointers as soon as they wanted to parse their arguments.
The attached patch makes 32 bits PowerPC executables run in ppc64_linux_user target. More fixes may be needed in the start_thread function and elf_check_arch to make other targets run as well.
Please comment.
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Index: configure
===================================================================
RCS file: /sources/qemu/qemu/configure,v
retrieving revision 1.161
configure +1 -0
@@ -1029,11 +1030,12 @@ elif test "$target_cpu" = "ppc" ; then echo "TARGET_ARCH=ppc" >> $config_mak echo "#define TARGET_ARCH \"ppc\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h elif test "$target_cpu" = "ppc64" ; then echo "TARGET_ARCH=ppc64" >> $config_mak echo "#define TARGET_ARCH \"ppc64\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h + elfload32="yes" elif test "$target_cpu" = "ppcemb" ; then echo "TARGET_ARCH=ppcemb" >> $config_mak echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
Index: linux-user/elfload.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/elfload.c,v retrieving revision 1.51
elfload.c +48 -71
180 lines not on this page · raw message
Index: linux-user/flatload.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/flatload.c,v retrieving revision 1.7
flatload.c +2 -1
@@ -766,7 +766,8 @@ int load_flt_binary(struct linux_binprm stack_len *=sizeof (target_ulong);if ((sp + stack_len) &15 ) sp -=16 - ((sp + stack_len) &15 ); - sp =loader_build_argptr (bprm->envc, bprm->argc, sp, p,1 ); + sp =loader_build_argptr (bprm->envc, bprm->argc, sp, p,1 , +sizeof (target_ulong));/* Fake some return addresses to ensure the call chain will * initialise library in order for us. We are required to call
Index: linux-user/linuxload.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/linuxload.c,v retrieving revision 1.6
linuxload.c +20 -9
@@ -109,10 +109,21 @@ static int prepare_binprm(struct linux_b }/* Construct the envp and argv tables on the target stack. */ +static inline void putl (target_ulong addr,target_ulong data,int n) +{ +if (n ==sizeof (target_ulong)) { +tputl (addr, data); + }else { +/* Force 32 bits store for 32 program executed on a 64 bits target */ +stl (addr, data); + } +} +target_ulong loader_build_argptr (int envc,int argc,target_ulong sp, -target_ulong stringp,int push_ptr) +target_ulong stringp,int push_ptr, +int plen) { -int n =sizeof (target_ulong); +int n = plen;target_ulong envp;target_ulong argv;
@@ -121,21 +132,21 @@ target_ulong loader_build_argptr(int env sp -= (argc +1 ) * n; argv = sp;if (push_ptr) { - sp -= n;tputl (sp, envp); - sp -= n;tputl (sp, argv); + sp -= n;putl (sp, envp, n); + sp -= n;putl (sp, argv, n); } - sp -= n;tputl (sp, argc); + sp -= n;putl (sp, argc, n);while (argc-- >0 ) { -tputl (argv, stringp); argv += n; +putl (argv, stringp, n); argv += n; stringp +=target_strlen (stringp) +1 ; } -tputl (argv,0 ); +putl (argv,0 , n);while (envc-- >0 ) { -tputl (envp, stringp); envp += n; +putl (envp, stringp, n); envp += n; stringp +=target_strlen (stringp) +1 ; } -tputl (envp,0 ); +putl (envp,0 , n);return sp; }
Index: linux-user/main.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/main.c,v
retrieving revision 1.131
main.c +9 -3
@@ -2159,8 +2159,17 @@ int main(int argc, char **argv)int i;/* Choose and initialise CPU */ +#if defined(TARGET_PPC64 ) +if (cpu_model ==NULL ) { +if (get_personality (info) ==PER_LINUX32 ) + cpu_model ="750" ; +else + cpu_model ="970" ; + } +#else if (cpu_model ==NULL ) cpu_model ="750" ; +#endif ppc_find_by_name (cpu_model, &def);if (def ==NULL ) { cpu_abort(env,
@@ -2172,9 +2181,6 @@ int main(int argc, char **argv)if (i !=12 && i !=6 && i !=13 ) env->msr[i] = (regs->msr >> i) &1 ; } -#if defined(TARGET_PPC64 ) - msr_sf =1 ; -#endif env->nip = regs->nip;for (i =0 ; i <32 ; i++) { env->gpr[i] = regs->gpr[i];
Index: linux-user/qemu.h
===================================================================
RCS file: /sources/qemu/qemu/linux-user/qemu.h,v
retrieving revision 1.40
qemu.h +61 -1
74 lines not on this page · raw message
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
Fabrice.
Quoted 11 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
True. But I hope some day we have Solaris binary execution support, and we need this 32+64 mode for that. I think Linux can emulate Solaris system calls.
Quoted 11 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Thiemo
Quoted 10 lines · Thiemo Seufer
Quoted 6 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename target_ulong so that it can have a different size of the CPU word default size.
Regards,
Fabrice.
Quoted 16 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 8 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
I think this would be sufficient for the Sparc and this way there would be no need to convert the structures. Brilliant!
Should we revert the elfload32 patch? What about PPC?
Quoted 25 lines · Blue Swirl
Quoted 16 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 8 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
Quoted 4 lines
I think this would be sufficient for the Sparc and this way there would be no need to convert the structures. Brilliant!
Should we revert the elfload32 patch? What about PPC?
We can keep the elfload32 for now, it does not hurt.
This approach is OK for PPC too. And as I got some 32 bits programs running in the 64 bits linux-user emulator, the same programs behavior can be compared to find eventual issues...
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Quoted 15 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 7 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
Doesn't work for MIPS64, since it doesn't quite have a compatibility mode in the traditional sense. It needs to retain 64bit register width when running N32 ABI binaries. (Thus the somewhat odd overrides I added for the preliminary N32 support.)
Thiemo
Quoted 24 lines · Thiemo Seufer
Quoted 15 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 7 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
Quoted 4 lines
Doesn't work for MIPS64, since it doesn't quite have a compatibility mode in the traditional sense. It needs to retain 64bit register width when running N32 ABI binaries. (Thus the somewhat odd overrides I added for the preliminary N32 support.)
CPU registers (and storage for full width registers) would still be 64 bits. The ABI uses of target_ulong need to be changed to, for example abi_ulong so that the size can be changed.
Sparc64 does not have a compatibility mode either (except for address masking), it can run Sparc32 binaries because of the cleverly designed instruction set. Ops use full 64 bits of a register, but there are two sets of CPU flags, 32 and 64 bits.
Blue Swirl wrote:
[snip]
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
Quoted 8 lines
Quoted 4 lines
Doesn't work for MIPS64, since it doesn't quite have a compatibility mode in the traditional sense. It needs to retain 64bit register width when running N32 ABI binaries. (Thus the somewhat odd overrides I added for the preliminary N32 support.)
CPU registers (and storage for full width registers) would still be 64 bits. The ABI uses of
target_ulongneed to be changed to, for exampleabi_ulongso that the size can be changed.
I see.
Quoted 4 lines
Sparc64 does not have a compatibility mode either (except for address masking), it can run Sparc32 binaries because of the cleverly designed instruction set. Ops use full 64 bits of a register, but there are two sets of CPU flags, 32 and 64 bits.
For MIPS it's not even that much, sign-extension magic handles everything.
Thiemo
Quoted 16 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 8 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
I made a patch to rename target_ulong/long to abi_ulong/long and also add a new emulator target that uses the 32 bit ABI with 64 bit CPU.
Some Sparc32 binaries run, others don't, possibly indicating bugs in the Sparc64 emulation!
The patch is quite large because of the renaming, but this shouldn't have effect to any other target. Any comments?
linux-user/alpha/syscall.h +31 -31
@@ -2,40 +2,40 @@#define __USER_DS (1)struct target_pt_regs { -target_ulong r0; -target_ulong r1; -target_ulong r2; -target_ulong r3; -target_ulong r4; -target_ulong r5; -target_ulong r6; -target_ulong r7; -target_ulong r8; -target_ulong r19; -target_ulong r20; -target_ulong r21; -target_ulong r22; -target_ulong r23; -target_ulong r24; -target_ulong r25; -target_ulong r26; -target_ulong r27; -target_ulong r28; -target_ulong hae; +abi_ulong r0; +abi_ulong r1; +abi_ulong r2; +abi_ulong r3; +abi_ulong r4; +abi_ulong r5; +abi_ulong r6; +abi_ulong r7; +abi_ulong r8; +abi_ulong r19; +abi_ulong r20; +abi_ulong r21; +abi_ulong r22; +abi_ulong r23; +abi_ulong r24; +abi_ulong r25; +abi_ulong r26; +abi_ulong r27; +abi_ulong r28; +abi_ulong hae;/* JRP - These are the values provided to a0-a2 by PALcode */ -target_ulong trap_a0; -target_ulong trap_a1; -target_ulong trap_a2; +abi_ulong trap_a0; +abi_ulong trap_a1; +abi_ulong trap_a2;/* These are saved by PAL-code: */ -target_ulong ps; -target_ulong pc; -target_ulong gp; -target_ulong r16; -target_ulong r17; -target_ulong r18; +abi_ulong ps; +abi_ulong pc; +abi_ulong gp; +abi_ulong r16; +abi_ulong r17; +abi_ulong r18;/* Those is needed by qemu to temporary store the user stack pointer */ -target_ulong usp; -target_ulong unique; +abi_ulong usp; +abi_ulong unique; };#define UNAME_MACHINE "alpha"
linux-user/alpha/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 4096#define TARGET_SIGSTKSZ 16384 -static inline target_ulong get_sp_from_cpustate (CPUAlphaState *state) +static inline abi_ulong get_sp_from_cpustate (CPUAlphaState *state) {return state->ir[IR_SP ]; }
linux-user/arm/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUARMState *state) +static inline abi_ulong get_sp_from_cpustate (CPUARMState *state) {return state->regs[13 ]; }
linux-user/cris/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_ulong ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUCRISState *state) +static inline abi_ulong get_sp_from_cpustate (CPUCRISState *state) {return state->regs[14 ]; }
linux-user/elfload.c +68 -58
317 lines not on this page · raw message
linux-user/flat.h +11 -11
@@ -22,25 +22,25 @@struct flat_hdr {char magic[4 ]; -target_ulong rev;/* version (as above) */ -target_ulong entry;/* Offset of first executable instruction +abi_ulong rev;/* version (as above) */ +abi_ulong entry;/* Offset of first executable instruction with text segment from beginning of file */ -target_ulong data_start;/* Offset of data segment from beginning of +abi_ulong data_start;/* Offset of data segment from beginning of file */ -target_ulong data_end;/* Offset of end of data segment +abi_ulong data_end;/* Offset of end of data segment from beginning of file */ -target_ulong bss_end;/* Offset of end of bss segment from beginning +abi_ulong bss_end;/* Offset of end of bss segment from beginning of file */ /* (It is assumed that data_end through bss_end forms the bss segment.) */ -target_ulong stack_size;/* Size of stack, in bytes */ -target_ulong reloc_start;/* Offset of relocation records from +abi_ulong stack_size;/* Size of stack, in bytes */ +abi_ulong reloc_start;/* Offset of relocation records from beginning of file */ -target_ulong reloc_count;/* Number of relocation records */ -target_ulong flags; -target_ulong build_date;/* When the program/library was built */ -target_ulong filler[5 ];/* Reservered, set to zero */ +abi_ulong reloc_count;/* Number of relocation records */ +abi_ulong flags; +abi_ulong build_date;/* When the program/library was built */ +abi_ulong filler[5 ];/* Reservered, set to zero */ };#define FLAT_FLAG_RAM 0x0001/* load program entirely into RAM */
linux-user/flatload.c +46 -46
204 lines not on this page · raw message
linux-user/i386/syscall.h +24 -24
83 lines not on this page · raw message
linux-user/i386/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUX86State *state) +static inline abi_ulong get_sp_from_cpustate (CPUX86State *state) {return state->regs[R_ESP ]; }
linux-user/linuxload.c +6 -6
@@ -13,7 +13,7 @@#define NGROUPS 32/* ??? This should really be somewhere else. */ -void memcpy_to_target (target_ulong dest,const void *src, +void memcpy_to_target (abi_ulong dest,const void *src,unsigned long len) {void *host_ptr;
@@ -109,12 +109,12 @@ }/* Construct the envp and argv tables on the target stack. */ -target_ulong loader_build_argptr (int envc,int argc,target_ulong sp, -target_ulong stringp,int push_ptr) +abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp, +abi_ulong stringp,int push_ptr) { -int n =sizeof (target_ulong); -target_ulong envp; -target_ulong argv; +int n =sizeof (abi_ulong); +abi_ulong envp; +abi_ulong argv; sp -= (envc +1 ) * n; envp = sp;
linux-user/m68k/syscall.h +6 -6
@@ -3,14 +3,14 @@stack during a system call. */ struct target_pt_regs { -target_long d1, d2, d3, d4, d5, d6, d7; -target_long a0, a1, a2, a3, a4, a5, a6; -target_ulong d0; -target_ulong usp; -target_ulong orig_d0; +abi_long d1, d2, d3, d4, d5, d6, d7; +abi_long a0, a1, a2, a3, a4, a5, a6; +abi_ulong d0; +abi_ulong usp; +abi_ulong orig_d0;int16_t stkadj;uint16_t sr; -target_ulong pc; +abi_ulong pc;uint16_t fntvex;uint16_t __fill; };
linux-user/m68k/target_signal.h +3 -3
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
linux-user/main.c +18 -15
@@ -168,7 +168,7 @@void cpu_loop (CPUX86State *env) {int trapnr; -target_ulong pc; +abi_ulong pc;target_siginfo_t info;for (;;) {
@@ -305,11 +305,11 @@#ifdef TARGET_ARM /* XXX: find a better solution */ -extern void tb_invalidate_page_range (target_ulong start,target_ulong end); +extern void tb_invalidate_page_range (abi_ulong start,abi_ulong end); -static void arm_cache_flush (target_ulong start,target_ulong last) +static void arm_cache_flush (abi_ulong start,abi_ulong last) { -target_ulong addr, last1; +abi_ulong addr, last1;if (last < start)return ;
@@ -474,7 +474,7 @@static inline void save_window_offset (CPUSPARCState *env,int cwp1) {unsigned int i; -target_ulong sp_ptr; +abi_ulong sp_ptr; sp_ptr = env->regbase[get_reg_index (env, cwp1,6 )];#if defined(DEBUG_WIN )
@@ -483,7 +483,7 @@#endif for (i =0 ; i <16 ; i++) {tputl (sp_ptr, env->regbase[get_reg_index (env, cwp1,8 + i)]); - sp_ptr +=sizeof (target_ulong); + sp_ptr +=sizeof (abi_ulong); } }
@@ -505,7 +505,7 @@static void restore_window (CPUSPARCState *env) {unsigned int new_wim, i, cwp1; -target_ulong sp_ptr; +abi_ulong sp_ptr; new_wim = ((env->wim <<1 ) | (env->wim >> (NWINDOWS -1 ))) & ((1LL <<NWINDOWS ) -1 );
@@ -519,7 +519,7 @@#endif for (i =0 ; i <16 ; i++) { env->regbase[get_reg_index (env, cwp1,8 + i)] =tgetl (sp_ptr); - sp_ptr +=sizeof (target_ulong); + sp_ptr +=sizeof (abi_ulong); } env->wim = new_wim;#ifdef TARGET_SPARC64
@@ -572,14 +572,14 @@ env->regwptr[2 ], env->regwptr[3 ], env->regwptr[4], env->regwptr[5]);if ((unsigned int )ret >= (unsigned int )(-515 )) { -#ifdef TARGET_SPARC64 +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) env->xcc |=PSR_CARRY ;#else env->psr |=PSR_CARRY ;#endif ret = -ret; }else { -#ifdef TARGET_SPARC64 +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) env->xcc &= ~PSR_CARRY ;#else env->psr &= ~PSR_CARRY ;
@@ -591,6 +591,9 @@ env->npc = env->npc +4 ;break ;case 0x83 :/* flush windows */ +#ifdef TARGET_ABI32 +case 0x103 : +#endif flush_windows (env);/* next instruction */ env->pc = env->npc;
@@ -708,12 +711,12 @@ }/* XXX: to be fixed */ -int ppc_dcr_read (ppc_dcr_t *dcr_env,int dcrn,target_ulong *valp) +int ppc_dcr_read (ppc_dcr_t *dcr_env,int dcrn,abi_ulong *valp) {return -1 ; } -int ppc_dcr_write (ppc_dcr_t *dcr_env,int dcrn,target_ulong val) +int ppc_dcr_write (ppc_dcr_t *dcr_env,int dcrn,abi_ulong val) {return -1 ; }
@@ -1489,8 +1492,8 @@ ret = -ENOSYS ; }else {int nb_args; -target_ulong sp_reg; -target_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; +abi_ulong sp_reg; +abi_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; nb_args = mips_syscall_args[syscall_num]; sp_reg = env->gpr[29 ][env->current_tc];
@@ -2244,7 +2247,7 @@int i;for (i =0 ; i <28 ; i++) { - env->ir[i] = ((target_ulong *)regs)[i]; + env->ir[i] = ((abi_ulong *)regs)[i]; } env->ipr[IPR_USP ] = regs->usp; env->ir[30 ] = regs->usp;
linux-user/mips/syscall.h +8 -8
@@ -4,18 +4,18 @@struct target_pt_regs {/* Pad bytes for argument save space on the stack. */ -target_ulong pad0[6 ]; +abi_ulong pad0[6 ];/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mips/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_long ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mips64/syscall.h +7 -7
@@ -4,15 +4,15 @@struct target_pt_regs {/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mips64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_long ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mipsn32/syscall.h +7 -7
@@ -4,15 +4,15 @@struct target_pt_regs {/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mipsn32/target_signal.h +1 -1
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mmap.c +19 -19
@@ -30,9 +30,9 @@//#define DEBUG_MMAP /* NOTE: all the constants are the HOST ones, but addresses are target. */ -int target_mprotect (target_ulong start,target_ulong len,int prot) +int target_mprotect (abi_ulong start,abi_ulong len,int prot) { -target_ulong end, host_start, host_end, addr; +abi_ulong end, host_start, host_end, addr;int prot1, ret;#ifdef DEBUG_MMAP
@@ -96,11 +96,11 @@ }/* map an incomplete host page */ -static int mmap_frag (target_ulong real_start, -target_ulong start,target_ulong end, -int prot,int flags,int fd,target_ulong offset) +static int mmap_frag (abi_ulong real_start, +abi_ulong start,abi_ulong end, +int prot,int flags,int fd,abi_ulong offset) { -target_ulong real_end, ret, addr; +abi_ulong real_end, ret, addr;void *host_start;int prot1, prot_new;
@@ -152,17 +152,17 @@ }/* NOTE: all the constants are the HOST ones */ -target_long target_mmap (target_ulong start,target_ulong len,int prot, -int flags,int fd,target_ulong offset) +abi_long target_mmap (abi_ulong start,abi_ulong len,int prot, +int flags,int fd,abi_ulong offset) { -target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; +abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len;unsigned long host_start;#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) -static target_ulong last_start =0x40000000 ; +static abi_ulong last_start =0x40000000 ;#elif defined(__CYGWIN__)/* Cygwin doesn't have a whole lot of address space. */ -static target_ulong last_start =0x18000000 ; +static abi_ulong last_start =0x18000000 ;#endif #ifdef DEBUG_MMAP
@@ -228,7 +228,7 @@* TARGET_PAGE_SIZE, see exec.c. qemu_real_host_page_size is the * hosts real page size. */ -target_ulong host_end; +abi_ulong host_end;unsigned long host_aligned_start; host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
@@ -354,9 +354,9 @@return start; } -int target_munmap (target_ulong start,target_ulong len) +int target_munmap (abi_ulong start,abi_ulong len) { -target_ulong end, real_start, real_end, addr; +abi_ulong end, real_start, real_end, addr;int prot, ret;#ifdef DEBUG_MMAP
@@ -408,9 +408,9 @@/* XXX: currently, we only handle MAP_ANONYMOUS and not MAP_FIXED blocks which have been allocated starting on a host page */ -target_long target_mremap (target_ulong old_addr,target_ulong old_size, -target_ulong new_size,unsigned long flags, -target_ulong new_addr) +abi_long target_mremap (abi_ulong old_addr,abi_ulong old_size, +abi_ulong new_size,unsigned long flags, +abi_ulong new_addr) {int prot;unsigned long host_addr;
@@ -426,9 +426,9 @@return new_addr; } -int target_msync (target_ulong start,target_ulong len,int flags) +int target_msync (abi_ulong start,abi_ulong len,int flags) { -target_ulong end; +abi_ulong end;if (start & ~TARGET_PAGE_MASK )return -EINVAL ;
linux-user/ppc/syscall.h +1 -1
@@ -44,7 +44,7 @@/* ioctls */ struct target_revectored_struct { -target_ulong __map[8 ];/* 256 bits */ +abi_ulong __map[8 ];/* 256 bits */ };/*
linux-user/ppc/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUPPCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUPPCState *state) {return state->gpr[1 ]; }
linux-user/ppc64/syscall.h +1 -1
@@ -44,7 +44,7 @@/* ioctls */ struct target_revectored_struct { -target_ulong __map[8 ];/* 256 bits */ +abi_ulong __map[8 ];/* 256 bits */ };/*
linux-user/ppc64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUPPCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUPPCState *state) {return state->gpr[1 ]; }
linux-user/qemu.h +53 -42
184 lines not on this page · raw message
linux-user/sh4/target_signal.h +3 -3
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
linux-user/signal.c +139 -139
582 lines not on this page · raw message
linux-user/sparc/syscall.h +5 -5
@@ -1,9 +1,9 @@struct target_pt_regs { -target_ulong psr; -target_ulong pc; -target_ulong npc; -target_ulong y; -target_ulong u_regs[16 ]; +abi_ulong psr; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong u_regs[16 ]; };#define UNAME_MACHINE "sun4"
linux-user/sparc/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -28,7 +28,7 @@#define UREG_FP UREG_I6#endif -static inline target_ulong get_sp_from_cpustate (CPUSPARCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUSPARCState *state) {return state->regwptr[UREG_FP ]; }
linux-user/sparc64/syscall.h +6 -6
@@ -1,10 +1,10 @@struct target_pt_regs { -target_ulong u_regs[16 ]; -target_ulong tstate; -target_ulong pc; -target_ulong npc; -target_ulong y; -target_ulong fprs; +abi_ulong u_regs[16 ]; +abi_ulong tstate; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong fprs; };#define UNAME_MACHINE "sun4u"
linux-user/sparc64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -28,7 +28,7 @@#define UREG_FP UREG_I6#endif -static inline target_ulong get_sp_from_cpustate (CPUSPARCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUSPARCState *state) {return state->regwptr[UREG_FP ]; }
linux-user/syscall.c +193 -193
929 lines not on this page · raw message
linux-user/syscall_defs.h +261 -261
522 lines not on this page · raw message
linux-user/x86_64/syscall.h +30 -30
60 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 25 lines · Blue Swirl
Quoted 16 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 8 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.
Quoted 8 lines
I made a patch to rename target_ulong/long to abi_ulong/long and also add a new emulator target that uses the 32 bit ABI with 64 bit CPU.
Some Sparc32 binaries run, others don't, possibly indicating bugs in the Sparc64 emulation!
The patch is quite large because of the renaming, but this shouldn't have effect to any other target. Any comments?
Great !
The patch seems safe, at first look, then I noticed a few things that are not correct or may be improved:
* In linux-user/main.c: PowerPC DCR access should keep using target_ulong. This is a hardware bus, not an ABI dependent stuff. If a 32 bits cast is needed, it would be done in the micro-ops that handle the DCR bus accesses.
* in linux-user/qemu.h: why is there still a OVERRIDE_ELF_CLASS variable, when checking TARGET_ABI32 should be sufficient ? It seems to me that having 2 defines which are, in fact, synonymous may be a source of confusion.
* in configure: you also added a sparc64-softmmu target, which seems not related with this particular patch.
* in configure: why add a specific TARGET_ABI32_DIR variable for that case ? It seems to me that a TARGET_ABI_DIR variable could be useful for all targets. Let me give an example: I want to add a ppcemb-linux-user target, emulating a PowerPC 32 with 64 bits registers and SIMD extensions but I don't want to duplicate the linux-user/ppc subdirectory. Having a TARGET_ABI_DIR available for all targets would solve my problem. In fact, even ppc and ppc64 could be merged... As you need this feature in your case, I think it would be a good idea to add it for all targets. And then, the kludge in Makefile.target could be replaced by:
-CPPFLAGS+=-I$(SRC_PATH)/linux-user -I $(SRC_PATH)/linux-user/$(TARGET_ARCH) +CPPFLAGS+=-I$(SRC_PATH)/linux-user -I $(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
which is simpler and easier to understand, imho.
Signature · 2 lines
J. Mayer <[email protected]> Never organized
Quoted 55 lines · J. Mayer
Quoted 25 lines · Blue Swirl
Quoted 16 lines · Fabrice Bellard
Quoted 6 lines · Thiemo Seufer
Quoted 5 lines · Fabrice Bellard
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
[...]Quoted 8 lines
Quoted 5 lines
Are you sure it is a good idea to try to add 32 bit executable support to a 64 bit target ? In the end you will need to write a 64 bit to 32 bit linux syscall converter which would mean duplicating all the linux-user code of the corresponding 32 bit target (think of ioctls with strutures, signals frames, etc...).
I would think this feature will be limited to platforms which can handle 32bit and 64bit binaries with a single personality.
Quoted 7 lines
I am not sure it is a common case !
However, I suggest to emulate a 32 bit user linux system with a 64 bit guest CPU running in 32 bit compatibily mode. It would be useful to test 64 bit CPUs in 32 bit compatibility mode. The only required modification in linux user is to rename
target_ulongso that it can have a different size of the CPU word default size.Quoted 8 lines
I made a patch to rename target_ulong/long to abi_ulong/long and also add a new emulator target that uses the 32 bit ABI with 64 bit CPU.
Some Sparc32 binaries run, others don't, possibly indicating bugs in the Sparc64 emulation!
The patch is quite large because of the renaming, but this shouldn't have effect to any other target. Any comments?
Great !
The patch seems safe, at first look, then I noticed a few things that are not correct or may be improved:
* Inlinux-user/main.c: PowerPC DCR access should keep usingtarget_ulong. This is a hardware bus, not an ABI dependent stuff. If a 32 bits cast is needed, it would be done in the micro-ops that handle the DCR bus accesses.
* inlinux-user/qemu.h: why is there still aOVERRIDE_ELF_CLASSvariable, when checkingTARGET_ABI32should be sufficient ? It seems to me that having 2 defines which are, in fact, synonymous may be a source of confusion.
* in configure: you also added a sparc64-softmmu target, which seems not related with this particular patch.
* in configure: why add a specificTARGET_ABI32_DIRvariable for that case ? It seems to me that aTARGET_ABI_DIRvariable could be useful for all targets. Let me give an example: I want to add a ppcemb-linux-user target, emulating a PowerPC 32 with 64 bits registers and SIMD extensions but I don't want to duplicate the linux-user/ppc subdirectory. Having aTARGET_ABI_DIRavailable for all targets would solve my problem. In fact, even ppc and ppc64 could be merged... As you
Quoted 8 lines
need this feature in your case, I think it would be a good idea to add it for all targets. And then, the kludge in Makefile.target could be replaced by:
-CPPFLAGS+=-I$(SRC_PATH)/linux-user -I $(SRC_PATH)/linux-user/$(TARGET_ARCH) +CPPFLAGS+=-I$(SRC_PATH)/linux-user -I $(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
which is simpler and easier to understand, imho.
Thanks, I updated the patch to reflect your comments. Is the ppcemb part correct or should just use existing values?
linux-user/alpha/syscall.h +31 -31
@@ -2,40 +2,40 @@#define __USER_DS (1)struct target_pt_regs { -target_ulong r0; -target_ulong r1; -target_ulong r2; -target_ulong r3; -target_ulong r4; -target_ulong r5; -target_ulong r6; -target_ulong r7; -target_ulong r8; -target_ulong r19; -target_ulong r20; -target_ulong r21; -target_ulong r22; -target_ulong r23; -target_ulong r24; -target_ulong r25; -target_ulong r26; -target_ulong r27; -target_ulong r28; -target_ulong hae; +abi_ulong r0; +abi_ulong r1; +abi_ulong r2; +abi_ulong r3; +abi_ulong r4; +abi_ulong r5; +abi_ulong r6; +abi_ulong r7; +abi_ulong r8; +abi_ulong r19; +abi_ulong r20; +abi_ulong r21; +abi_ulong r22; +abi_ulong r23; +abi_ulong r24; +abi_ulong r25; +abi_ulong r26; +abi_ulong r27; +abi_ulong r28; +abi_ulong hae;/* JRP - These are the values provided to a0-a2 by PALcode */ -target_ulong trap_a0; -target_ulong trap_a1; -target_ulong trap_a2; +abi_ulong trap_a0; +abi_ulong trap_a1; +abi_ulong trap_a2;/* These are saved by PAL-code: */ -target_ulong ps; -target_ulong pc; -target_ulong gp; -target_ulong r16; -target_ulong r17; -target_ulong r18; +abi_ulong ps; +abi_ulong pc; +abi_ulong gp; +abi_ulong r16; +abi_ulong r17; +abi_ulong r18;/* Those is needed by qemu to temporary store the user stack pointer */ -target_ulong usp; -target_ulong unique; +abi_ulong usp; +abi_ulong unique; };#define UNAME_MACHINE "alpha"
linux-user/alpha/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 4096#define TARGET_SIGSTKSZ 16384 -static inline target_ulong get_sp_from_cpustate (CPUAlphaState *state) +static inline abi_ulong get_sp_from_cpustate (CPUAlphaState *state) {return state->ir[IR_SP ]; }
linux-user/arm/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUARMState *state) +static inline abi_ulong get_sp_from_cpustate (CPUARMState *state) {return state->regs[13 ]; }
linux-user/cris/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_ulong ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUCRISState *state) +static inline abi_ulong get_sp_from_cpustate (CPUCRISState *state) {return state->regs[14 ]; }
linux-user/elfload.c +74 -64
332 lines not on this page · raw message
linux-user/flat.h +16 -16
@@ -22,25 +22,25 @@struct flat_hdr {char magic[4 ]; -target_ulong rev;/* version (as above) */ -target_ulong entry;/* Offset of first executable instruction -with text segment from beginning of file */ -target_ulong data_start;/* Offset of data segment from beginning of -file */ -target_ulong data_end;/* Offset of end of data segment -from beginning of file */ -target_ulong bss_end;/* Offset of end of bss segment from beginning -of file */ +abi_ulong rev;/* version (as above) */ +abi_ulong entry;/* Offset of first executable instruction +with text segment from beginning of file */ +abi_ulong data_start;/* Offset of data segment from beginning of +file */ +abi_ulong data_end;/* Offset of end of data segment +from beginning of file */ +abi_ulong bss_end;/* Offset of end of bss segment from beginning +of file */ /* (It is assumed that data_end through bss_end forms the bss segment.) */ -target_ulong stack_size;/* Size of stack, in bytes */ -target_ulong reloc_start;/* Offset of relocation records from -beginning of file */ -target_ulong reloc_count;/* Number of relocation records */ -target_ulong flags; -target_ulong build_date;/* When the program/library was built */ -target_ulong filler[5 ];/* Reservered, set to zero */ +abi_ulong stack_size;/* Size of stack, in bytes */ +abi_ulong reloc_start;/* Offset of relocation records from +beginning of file */ +abi_ulong reloc_count;/* Number of relocation records */ +abi_ulong flags; +abi_ulong build_date;/* When the program/library was built */ +abi_ulong filler[5 ];/* Reservered, set to zero */ };#define FLAT_FLAG_RAM 0x0001/* load program entirely into RAM */
linux-user/flatload.c +46 -46
204 lines not on this page · raw message
linux-user/i386/syscall.h +24 -24
83 lines not on this page · raw message
linux-user/i386/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUX86State *state) +static inline abi_ulong get_sp_from_cpustate (CPUX86State *state) {return state->regs[R_ESP ]; }
linux-user/linuxload.c +6 -6
@@ -13,7 +13,7 @@#define NGROUPS 32/* ??? This should really be somewhere else. */ -void memcpy_to_target (target_ulong dest,const void *src, +void memcpy_to_target (abi_ulong dest,const void *src,unsigned long len) {void *host_ptr;
@@ -109,12 +109,12 @@ }/* Construct the envp and argv tables on the target stack. */ -target_ulong loader_build_argptr (int envc,int argc,target_ulong sp, -target_ulong stringp,int push_ptr) +abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp, +abi_ulong stringp,int push_ptr) { -int n =sizeof (target_ulong); -target_ulong envp; -target_ulong argv; +int n =sizeof (abi_ulong); +abi_ulong envp; +abi_ulong argv; sp -= (envc +1 ) * n; envp = sp;
linux-user/m68k/syscall.h +6 -6
@@ -3,14 +3,14 @@stack during a system call. */ struct target_pt_regs { -target_long d1, d2, d3, d4, d5, d6, d7; -target_long a0, a1, a2, a3, a4, a5, a6; -target_ulong d0; -target_ulong usp; -target_ulong orig_d0; +abi_long d1, d2, d3, d4, d5, d6, d7; +abi_long a0, a1, a2, a3, a4, a5, a6; +abi_ulong d0; +abi_ulong usp; +abi_ulong orig_d0;int16_t stkadj;uint16_t sr; -target_ulong pc; +abi_ulong pc;uint16_t fntvex;uint16_t __fill; };
linux-user/m68k/target_signal.h +3 -3
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
linux-user/main.c +16 -13
@@ -168,7 +168,7 @@void cpu_loop (CPUX86State *env) {int trapnr; -target_ulong pc; +abi_ulong pc;target_siginfo_t info;for (;;) {
@@ -305,11 +305,11 @@#ifdef TARGET_ARM /* XXX: find a better solution */ -extern void tb_invalidate_page_range (target_ulong start,target_ulong end); +extern void tb_invalidate_page_range (abi_ulong start,abi_ulong end); -static void arm_cache_flush (target_ulong start,target_ulong last) +static void arm_cache_flush (abi_ulong start,abi_ulong last) { -target_ulong addr, last1; +abi_ulong addr, last1;if (last < start)return ;
@@ -474,7 +474,7 @@static inline void save_window_offset (CPUSPARCState *env,int cwp1) {unsigned int i; -target_ulong sp_ptr; +abi_ulong sp_ptr; sp_ptr = env->regbase[get_reg_index (env, cwp1,6 )];#if defined(DEBUG_WIN )
@@ -483,7 +483,7 @@#endif for (i =0 ; i <16 ; i++) {tputl (sp_ptr, env->regbase[get_reg_index (env, cwp1,8 + i)]); - sp_ptr +=sizeof (target_ulong); + sp_ptr +=sizeof (abi_ulong); } }
@@ -505,7 +505,7 @@static void restore_window (CPUSPARCState *env) {unsigned int new_wim, i, cwp1; -target_ulong sp_ptr; +abi_ulong sp_ptr; new_wim = ((env->wim <<1 ) | (env->wim >> (NWINDOWS -1 ))) & ((1LL <<NWINDOWS ) -1 );
@@ -519,7 +519,7 @@#endif for (i =0 ; i <16 ; i++) { env->regbase[get_reg_index (env, cwp1,8 + i)] =tgetl (sp_ptr); - sp_ptr +=sizeof (target_ulong); + sp_ptr +=sizeof (abi_ulong); } env->wim = new_wim;#ifdef TARGET_SPARC64
@@ -572,14 +572,14 @@ env->regwptr[2 ], env->regwptr[3 ], env->regwptr[4], env->regwptr[5]);if ((unsigned int )ret >= (unsigned int )(-515 )) { -#ifdef TARGET_SPARC64 +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) env->xcc |=PSR_CARRY ;#else env->psr |=PSR_CARRY ;#endif ret = -ret; }else { -#ifdef TARGET_SPARC64 +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) env->xcc &= ~PSR_CARRY ;#else env->psr &= ~PSR_CARRY ;
@@ -591,6 +591,9 @@ env->npc = env->npc +4 ;break ;case 0x83 :/* flush windows */ +#ifdef TARGET_ABI32 +case 0x103 : +#endif flush_windows (env);/* next instruction */ env->pc = env->npc;
@@ -1489,8 +1492,8 @@ ret = -ENOSYS ; }else {int nb_args; -target_ulong sp_reg; -target_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; +abi_ulong sp_reg; +abi_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; nb_args = mips_syscall_args[syscall_num]; sp_reg = env->gpr[29 ][env->current_tc];
@@ -2244,7 +2247,7 @@int i;for (i =0 ; i <28 ; i++) { - env->ir[i] = ((target_ulong *)regs)[i]; + env->ir[i] = ((abi_ulong *)regs)[i]; } env->ipr[IPR_USP ] = regs->usp; env->ir[30 ] = regs->usp;
linux-user/mips/syscall.h +8 -8
@@ -4,18 +4,18 @@struct target_pt_regs {/* Pad bytes for argument save space on the stack. */ -target_ulong pad0[6 ]; +abi_ulong pad0[6 ];/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mips/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_long ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mips64/syscall.h +7 -7
@@ -4,15 +4,15 @@struct target_pt_regs {/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mips64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_long ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mipsn32/syscall.h +7 -7
@@ -4,15 +4,15 @@struct target_pt_regs {/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mipsn32/target_signal.h +1 -1
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mmap.c +19 -19
@@ -30,9 +30,9 @@//#define DEBUG_MMAP /* NOTE: all the constants are the HOST ones, but addresses are target. */ -int target_mprotect (target_ulong start,target_ulong len,int prot) +int target_mprotect (abi_ulong start,abi_ulong len,int prot) { -target_ulong end, host_start, host_end, addr; +abi_ulong end, host_start, host_end, addr;int prot1, ret;#ifdef DEBUG_MMAP
@@ -96,11 +96,11 @@ }/* map an incomplete host page */ -static int mmap_frag (target_ulong real_start, -target_ulong start,target_ulong end, -int prot,int flags,int fd,target_ulong offset) +static int mmap_frag (abi_ulong real_start, +abi_ulong start,abi_ulong end, +int prot,int flags,int fd,abi_ulong offset) { -target_ulong real_end, ret, addr; +abi_ulong real_end, ret, addr;void *host_start;int prot1, prot_new;
@@ -152,17 +152,17 @@ }/* NOTE: all the constants are the HOST ones */ -target_long target_mmap (target_ulong start,target_ulong len,int prot, -int flags,int fd,target_ulong offset) +abi_long target_mmap (abi_ulong start,abi_ulong len,int prot, +int flags,int fd,abi_ulong offset) { -target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; +abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len;unsigned long host_start;#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) -static target_ulong last_start =0x40000000 ; +static abi_ulong last_start =0x40000000 ;#elif defined(__CYGWIN__)/* Cygwin doesn't have a whole lot of address space. */ -static target_ulong last_start =0x18000000 ; +static abi_ulong last_start =0x18000000 ;#endif #ifdef DEBUG_MMAP
@@ -228,7 +228,7 @@* TARGET_PAGE_SIZE, see exec.c. qemu_real_host_page_size is the * hosts real page size. */ -target_ulong host_end; +abi_ulong host_end;unsigned long host_aligned_start; host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
@@ -354,9 +354,9 @@return start; } -int target_munmap (target_ulong start,target_ulong len) +int target_munmap (abi_ulong start,abi_ulong len) { -target_ulong end, real_start, real_end, addr; +abi_ulong end, real_start, real_end, addr;int prot, ret;#ifdef DEBUG_MMAP
@@ -408,9 +408,9 @@/* XXX: currently, we only handle MAP_ANONYMOUS and not MAP_FIXED blocks which have been allocated starting on a host page */ -target_long target_mremap (target_ulong old_addr,target_ulong old_size, -target_ulong new_size,unsigned long flags, -target_ulong new_addr) +abi_long target_mremap (abi_ulong old_addr,abi_ulong old_size, +abi_ulong new_size,unsigned long flags, +abi_ulong new_addr) {int prot;unsigned long host_addr;
@@ -426,9 +426,9 @@return new_addr; } -int target_msync (target_ulong start,target_ulong len,int flags) +int target_msync (abi_ulong start,abi_ulong len,int flags) { -target_ulong end; +abi_ulong end;if (start & ~TARGET_PAGE_MASK )return -EINVAL ;
linux-user/ppc/syscall.h +1 -1
@@ -44,7 +44,7 @@/* ioctls */ struct target_revectored_struct { -target_ulong __map[8 ];/* 256 bits */ +abi_ulong __map[8 ];/* 256 bits */ };/*
linux-user/ppc/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUPPCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUPPCState *state) {return state->gpr[1 ]; }
linux-user/ppc64/syscall.h +1 -1
@@ -44,7 +44,7 @@/* ioctls */ struct target_revectored_struct { -target_ulong __map[8 ];/* 256 bits */ +abi_ulong __map[8 ];/* 256 bits */ };/*
linux-user/ppc64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUPPCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUPPCState *state) {return state->gpr[1 ]; }
linux-user/qemu.h +53 -43
185 lines not on this page · raw message
linux-user/sh4/target_signal.h +3 -3
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
linux-user/signal.c +139 -139
582 lines not on this page · raw message
linux-user/sparc/syscall.h +5 -5
@@ -1,9 +1,9 @@struct target_pt_regs { -target_ulong psr; -target_ulong pc; -target_ulong npc; -target_ulong y; -target_ulong u_regs[16 ]; +abi_ulong psr; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong u_regs[16 ]; };#define UNAME_MACHINE "sun4"
linux-user/sparc/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -28,7 +28,7 @@#define UREG_FP UREG_I6#endif -static inline target_ulong get_sp_from_cpustate (CPUSPARCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUSPARCState *state) {return state->regwptr[UREG_FP ]; }
linux-user/sparc64/syscall.h +6 -6
@@ -1,10 +1,10 @@struct target_pt_regs { -target_ulong u_regs[16 ]; -target_ulong tstate; -target_ulong pc; -target_ulong npc; -target_ulong y; -target_ulong fprs; +abi_ulong u_regs[16 ]; +abi_ulong tstate; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong fprs; };#define UNAME_MACHINE "sun4u"
linux-user/sparc64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -28,7 +28,7 @@#define UREG_FP UREG_I6#endif -static inline target_ulong get_sp_from_cpustate (CPUSPARCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUSPARCState *state) {return state->regwptr[UREG_FP ]; }
linux-user/syscall.c +200 -200
922 lines not on this page · raw message
linux-user/syscall_defs.h +262 -262
524 lines not on this page · raw message
linux-user/x86_64/syscall.h +30 -30
60 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Blue Swirl wrote:
[snip]
Quoted 15 lines
Index:
qemu/linux-user/mipsn32/syscall.h
===================================================================linux-user/mipsn32/syscall.h +1
-4@@ -4,15 +4,15 @@struct target_pt_regs {/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi;
linux-user/mipsn32/syscall.h line 16
Quoted 10 lines
linux-user/mipsn32/syscall.h +6
-3-target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };
This is broken. n32 has 64bit wide registers (and uses them for long long).
Quoted 6 lines
linux-user/mipsn32/syscall.h +0
-0/* Target errno definitions taken from asm-mips/errno.h */ Index:
qemu/linux-user/mipsn32/target_signal.h
===================================================================
linux-user/mipsn32/target_signal.h line 27
Quoted 8 lines
linux-user/mipsn32/target_signal.h +1
-1@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
Same problem.
[snip]
Quoted 4 lines
Index:
qemu/linux-user/signal.c
===================================================================linux-user/signal.c +0
-0
[snip]
Quoted 7 lines
linux-user/signal.c +0
-3@@ -2013,12 +2013,12 @@uint32_t sc_dsp;/* dsp status, was sc_ssflags */ uint64_t sc_mdhi;uint64_t sc_mdlo; -target_ulong sc_hi1;/* Was sc_cause */ -target_ulong sc_lo1;/* Was sc_badvaddr */ -target_ulong sc_hi2;/* Was sc_sigset[4] */
linux-user/signal.c line 2022
Quoted 10 lines
linux-user/signal.c +6
-3-target_ulong sc_lo2; -target_ulong sc_hi3; -target_ulong sc_lo3; +abi_ulong sc_hi1;/* Was sc_cause */ +abi_ulong sc_lo1;/* Was sc_badvaddr */ +abi_ulong sc_hi2;/* Was sc_sigset[4] */ +abi_ulong sc_lo2; +abi_ulong sc_hi3; +abi_ulong sc_lo3; };
Likewise. When comparing with Linux kernel headers keep in mind that a 64bit MIPS kernel is always n64, so the data types used on the kernel side don't match the n32 userland ones.
I'm probably just too used to it to find it confusing, taking the glibc headers as a guideline might be easier for you. :-)
[snip]
Quoted 4 lines
Index:
qemu/linux-user/syscall_defs.h
===================================================================linux-user/syscall_defs.h +0
-0
[snip]
linux-user/syscall_defs.h line 1278
Quoted 9 lines
linux-user/syscall_defs.h +1
-1@@ -1272,7 +1272,7 @@unsigned int st_dev;unsigned int st_pad0[3 ];/* Reserved for st_dev expansion */ -target_ulong st_ino; +abi_ulong st_ino;unsigned int st_mode;unsigned int st_nlink;
Another one. I leave out a few more instances which also break n32.
[snip]
Quoted 22 lines
Index: qemu/configure
===================================================================configure +2
-1@@ -504,7 +504,7 @@ fi # the following are Linux specific if [ "$linux_user" = "yes" ] ; then - target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user ppc-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user ppc64-linux-user sh4-linux-user cris-linux-user $target_list" + target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user sparc64-linux-user sparc32plus-linux-user ppc-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user ppc64-linux-user sh4-linux-user cris-linux-user $target_list" fi # the following are Darwin specific if [ "$darwin_user" = "yes" ] ; then@@ -933,6 +933,7 @@ [ "$target_cpu" = "armeb" ] && target_bigendian=yes [ "$target_cpu" = "sparc" ] && target_bigendian=yes [ "$target_cpu" = "sparc64" ] && target_bigendian=yes +[ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes [ "$target_cpu" = "ppc" ] && target_bigendian=yes [ "$target_cpu" = "ppc64" ] && target_bigendian=yes [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
configure line 1012
Quoted 7 lines
configure +1
-0@@ -1005,6 +1006,7 @@ if test "$target_cpu" = "i386" ; then echo "TARGET_ARCH=i386" >> $config_mak + echo "TARGET_ABI_DIR=i386" >> $config_mak echo "#define TARGET_ARCH \"i386\"" >> $config_h echo "#define TARGET_I386 1" >> $config_h if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then
It would be less clutter to let TARGET_ABI_DIR default to TARGET_ARCH and override it when needed.
Thiemo
Quoted 13 lines · Thiemo Seufer
Blue Swirl wrote:
[snip]Quoted 11 lines
Index:
qemu/linux-user/mipsn32/syscall.h
===================================================================linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 renamed from linux-user/mipsn32/syscall.h 2007-10-11 19:17:14.000000000 +0000 +1
-1@@ -4,15 +4,15 @@ struct target_pt_regs { /* Saved main processor registers. */ - target_ulong regs[32]; + abi_ulong regs[32];
Quoted 16 lines
Quoted 4 lines
linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 renamed from linux-user/mipsn32/syscall.h 2007-10-11 19:17:14.000000000 +0000 +0
-3/* Saved special registers. */ - target_ulong cp0_status; - target_ulong lo; - target_ulong hi;linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 line 16
Quoted 10 lines
linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 renamed from linux-user/mipsn32/syscall.h 2007-10-11 19:17:14.000000000 +0000 +6
-3- target_ulong cp0_badvaddr; - target_ulong cp0_cause; - target_ulong cp0_epc; + abi_ulong cp0_status; + abi_ulong lo; + abi_ulong hi; + abi_ulong cp0_badvaddr; + abi_ulong cp0_cause; + abi_ulong cp0_epc; };This is broken. n32 has 64bit wide registers (and uses them for long long).
If target_ulong is 64 bits, then abi_ulong is 64 bits too and therefore correct. Unless you want to enable the ABI32 feature? It is only enabled for the new Sparc32plus and PPC targets for now.
But I put the original target_ulongs back.
Quoted 2 lines
It would be less clutter to let
TARGET_ABI_DIRdefault toTARGET_ARCHand override it when needed.
Maybe. I changed the patch to do that.
I found out why Sparc32plus can't execute Sparc32 binaries. Addresses need to be truncated to 32 bits, otherwise things like
ld [ %l7 + %o0 ], %o0
don't work when the other register is set to a 32 bit negative value in such a way that it is not negative in 64 bits. Now all my Sparc32 test cases run equally fine with both qemu-sparc and qemu-sparc32plus, so Sparc64 emulator should be OK for the part shared with Sparc32.
linux-user/alpha/syscall.h +31 -31
@@ -2,40 +2,40 @@#define __USER_DS (1)struct target_pt_regs { -target_ulong r0; -target_ulong r1; -target_ulong r2; -target_ulong r3; -target_ulong r4; -target_ulong r5; -target_ulong r6; -target_ulong r7; -target_ulong r8; -target_ulong r19; -target_ulong r20; -target_ulong r21; -target_ulong r22; -target_ulong r23; -target_ulong r24; -target_ulong r25; -target_ulong r26; -target_ulong r27; -target_ulong r28; -target_ulong hae; +abi_ulong r0; +abi_ulong r1; +abi_ulong r2; +abi_ulong r3; +abi_ulong r4; +abi_ulong r5; +abi_ulong r6; +abi_ulong r7; +abi_ulong r8; +abi_ulong r19; +abi_ulong r20; +abi_ulong r21; +abi_ulong r22; +abi_ulong r23; +abi_ulong r24; +abi_ulong r25; +abi_ulong r26; +abi_ulong r27; +abi_ulong r28; +abi_ulong hae;/* JRP - These are the values provided to a0-a2 by PALcode */ -target_ulong trap_a0; -target_ulong trap_a1; -target_ulong trap_a2; +abi_ulong trap_a0; +abi_ulong trap_a1; +abi_ulong trap_a2;/* These are saved by PAL-code: */ -target_ulong ps; -target_ulong pc; -target_ulong gp; -target_ulong r16; -target_ulong r17; -target_ulong r18; +abi_ulong ps; +abi_ulong pc; +abi_ulong gp; +abi_ulong r16; +abi_ulong r17; +abi_ulong r18;/* Those is needed by qemu to temporary store the user stack pointer */ -target_ulong usp; -target_ulong unique; +abi_ulong usp; +abi_ulong unique; };#define UNAME_MACHINE "alpha"
linux-user/alpha/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 4096#define TARGET_SIGSTKSZ 16384 -static inline target_ulong get_sp_from_cpustate (CPUAlphaState *state) +static inline abi_ulong get_sp_from_cpustate (CPUAlphaState *state) {return state->ir[IR_SP ]; }
linux-user/arm/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUARMState *state) +static inline abi_ulong get_sp_from_cpustate (CPUARMState *state) {return state->regs[13 ]; }
linux-user/cris/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_ulong ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUCRISState *state) +static inline abi_ulong get_sp_from_cpustate (CPUCRISState *state) {return state->regs[14 ]; }
linux-user/elfload.c +74 -64
332 lines not on this page · raw message
linux-user/flat.h +16 -16
@@ -22,25 +22,25 @@struct flat_hdr {char magic[4 ]; -target_ulong rev;/* version (as above) */ -target_ulong entry;/* Offset of first executable instruction -with text segment from beginning of file */ -target_ulong data_start;/* Offset of data segment from beginning of -file */ -target_ulong data_end;/* Offset of end of data segment -from beginning of file */ -target_ulong bss_end;/* Offset of end of bss segment from beginning -of file */ +abi_ulong rev;/* version (as above) */ +abi_ulong entry;/* Offset of first executable instruction +with text segment from beginning of file */ +abi_ulong data_start;/* Offset of data segment from beginning of +file */ +abi_ulong data_end;/* Offset of end of data segment +from beginning of file */ +abi_ulong bss_end;/* Offset of end of bss segment from beginning +of file */ /* (It is assumed that data_end through bss_end forms the bss segment.) */ -target_ulong stack_size;/* Size of stack, in bytes */ -target_ulong reloc_start;/* Offset of relocation records from -beginning of file */ -target_ulong reloc_count;/* Number of relocation records */ -target_ulong flags; -target_ulong build_date;/* When the program/library was built */ -target_ulong filler[5 ];/* Reservered, set to zero */ +abi_ulong stack_size;/* Size of stack, in bytes */ +abi_ulong reloc_start;/* Offset of relocation records from +beginning of file */ +abi_ulong reloc_count;/* Number of relocation records */ +abi_ulong flags; +abi_ulong build_date;/* When the program/library was built */ +abi_ulong filler[5 ];/* Reservered, set to zero */ };#define FLAT_FLAG_RAM 0x0001/* load program entirely into RAM */
linux-user/flatload.c +46 -46
204 lines not on this page · raw message
linux-user/i386/syscall.h +24 -24
83 lines not on this page · raw message
linux-user/i386/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUX86State *state) +static inline abi_ulong get_sp_from_cpustate (CPUX86State *state) {return state->regs[R_ESP ]; }
linux-user/linuxload.c +6 -6
@@ -13,7 +13,7 @@#define NGROUPS 32/* ??? This should really be somewhere else. */ -void memcpy_to_target (target_ulong dest,const void *src, +void memcpy_to_target (abi_ulong dest,const void *src,unsigned long len) {void *host_ptr;
@@ -109,12 +109,12 @@ }/* Construct the envp and argv tables on the target stack. */ -target_ulong loader_build_argptr (int envc,int argc,target_ulong sp, -target_ulong stringp,int push_ptr) +abi_ulong loader_build_argptr (int envc,int argc,abi_ulong sp, +abi_ulong stringp,int push_ptr) { -int n =sizeof (target_ulong); -target_ulong envp; -target_ulong argv; +int n =sizeof (abi_ulong); +abi_ulong envp; +abi_ulong argv; sp -= (envc +1 ) * n; envp = sp;
linux-user/m68k/syscall.h +6 -6
@@ -3,14 +3,14 @@stack during a system call. */ struct target_pt_regs { -target_long d1, d2, d3, d4, d5, d6, d7; -target_long a0, a1, a2, a3, a4, a5, a6; -target_ulong d0; -target_ulong usp; -target_ulong orig_d0; +abi_long d1, d2, d3, d4, d5, d6, d7; +abi_long a0, a1, a2, a3, a4, a5, a6; +abi_ulong d0; +abi_ulong usp; +abi_ulong orig_d0;int16_t stkadj;uint16_t sr; -target_ulong pc; +abi_ulong pc;uint16_t fntvex;uint16_t __fill; };
linux-user/m68k/target_signal.h +3 -3
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
linux-user/main.c +16 -13
@@ -168,7 +168,7 @@void cpu_loop (CPUX86State *env) {int trapnr; -target_ulong pc; +abi_ulong pc;target_siginfo_t info;for (;;) {
@@ -305,11 +305,11 @@#ifdef TARGET_ARM /* XXX: find a better solution */ -extern void tb_invalidate_page_range (target_ulong start,target_ulong end); +extern void tb_invalidate_page_range (abi_ulong start,abi_ulong end); -static void arm_cache_flush (target_ulong start,target_ulong last) +static void arm_cache_flush (abi_ulong start,abi_ulong last) { -target_ulong addr, last1; +abi_ulong addr, last1;if (last < start)return ;
@@ -474,7 +474,7 @@static inline void save_window_offset (CPUSPARCState *env,int cwp1) {unsigned int i; -target_ulong sp_ptr; +abi_ulong sp_ptr; sp_ptr = env->regbase[get_reg_index (env, cwp1,6 )];#if defined(DEBUG_WIN )
@@ -483,7 +483,7 @@#endif for (i =0 ; i <16 ; i++) {tputl (sp_ptr, env->regbase[get_reg_index (env, cwp1,8 + i)]); - sp_ptr +=sizeof (target_ulong); + sp_ptr +=sizeof (abi_ulong); } }
@@ -505,7 +505,7 @@static void restore_window (CPUSPARCState *env) {unsigned int new_wim, i, cwp1; -target_ulong sp_ptr; +abi_ulong sp_ptr; new_wim = ((env->wim <<1 ) | (env->wim >> (NWINDOWS -1 ))) & ((1LL <<NWINDOWS ) -1 );
@@ -519,7 +519,7 @@#endif for (i =0 ; i <16 ; i++) { env->regbase[get_reg_index (env, cwp1,8 + i)] =tgetl (sp_ptr); - sp_ptr +=sizeof (target_ulong); + sp_ptr +=sizeof (abi_ulong); } env->wim = new_wim;#ifdef TARGET_SPARC64
@@ -572,14 +572,14 @@ env->regwptr[2 ], env->regwptr[3 ], env->regwptr[4], env->regwptr[5]);if ((unsigned int )ret >= (unsigned int )(-515 )) { -#ifdef TARGET_SPARC64 +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) env->xcc |=PSR_CARRY ;#else env->psr |=PSR_CARRY ;#endif ret = -ret; }else { -#ifdef TARGET_SPARC64 +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) env->xcc &= ~PSR_CARRY ;#else env->psr &= ~PSR_CARRY ;
@@ -591,6 +591,9 @@ env->npc = env->npc +4 ;break ;case 0x83 :/* flush windows */ +#ifdef TARGET_ABI32 +case 0x103 : +#endif flush_windows (env);/* next instruction */ env->pc = env->npc;
@@ -1489,8 +1492,8 @@ ret = -ENOSYS ; }else {int nb_args; -target_ulong sp_reg; -target_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; +abi_ulong sp_reg; +abi_ulong arg5 =0 , arg6 =0 , arg7 =0 , arg8 =0 ; nb_args = mips_syscall_args[syscall_num]; sp_reg = env->gpr[29 ][env->current_tc];
@@ -2244,7 +2247,7 @@int i;for (i =0 ; i <28 ; i++) { - env->ir[i] = ((target_ulong *)regs)[i]; + env->ir[i] = ((abi_ulong *)regs)[i]; } env->ipr[IPR_USP ] = regs->usp; env->ir[30 ] = regs->usp;
linux-user/mips/syscall.h +8 -8
@@ -4,18 +4,18 @@struct target_pt_regs {/* Pad bytes for argument save space on the stack. */ -target_ulong pad0[6 ]; +abi_ulong pad0[6 ];/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mips/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_long ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mips64/syscall.h +7 -7
@@ -4,15 +4,15 @@struct target_pt_regs {/* Saved main processor registers. */ -target_ulong regs[32 ]; +abi_ulong regs[32 ];/* Saved special registers. */ -target_ulong cp0_status; -target_ulong lo; -target_ulong hi; -target_ulong cp0_badvaddr; -target_ulong cp0_cause; -target_ulong cp0_epc; +abi_ulong cp0_status; +abi_ulong lo; +abi_ulong hi; +abi_ulong cp0_badvaddr; +abi_ulong cp0_cause; +abi_ulong cp0_epc; };/* Target errno definitions taken from asm-mips/errno.h */
linux-user/mips64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_long ss_sp; -target_ulong ss_size; -target_long ss_flags; +abi_long ss_sp; +abi_ulong ss_size; +abi_long ss_flags; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUMIPSState *state) +static inline abi_ulong get_sp_from_cpustate (CPUMIPSState *state) {return state->gpr[29 ][state->current_tc]; }
linux-user/mmap.c +19 -19
@@ -30,9 +30,9 @@//#define DEBUG_MMAP /* NOTE: all the constants are the HOST ones, but addresses are target. */ -int target_mprotect (target_ulong start,target_ulong len,int prot) +int target_mprotect (abi_ulong start,abi_ulong len,int prot) { -target_ulong end, host_start, host_end, addr; +abi_ulong end, host_start, host_end, addr;int prot1, ret;#ifdef DEBUG_MMAP
@@ -96,11 +96,11 @@ }/* map an incomplete host page */ -static int mmap_frag (target_ulong real_start, -target_ulong start,target_ulong end, -int prot,int flags,int fd,target_ulong offset) +static int mmap_frag (abi_ulong real_start, +abi_ulong start,abi_ulong end, +int prot,int flags,int fd,abi_ulong offset) { -target_ulong real_end, ret, addr; +abi_ulong real_end, ret, addr;void *host_start;int prot1, prot_new;
@@ -152,17 +152,17 @@ }/* NOTE: all the constants are the HOST ones */ -target_long target_mmap (target_ulong start,target_ulong len,int prot, -int flags,int fd,target_ulong offset) +abi_long target_mmap (abi_ulong start,abi_ulong len,int prot, +int flags,int fd,abi_ulong offset) { -target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; +abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len;unsigned long host_start;#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) -static target_ulong last_start =0x40000000 ; +static abi_ulong last_start =0x40000000 ;#elif defined(__CYGWIN__)/* Cygwin doesn't have a whole lot of address space. */ -static target_ulong last_start =0x18000000 ; +static abi_ulong last_start =0x18000000 ;#endif #ifdef DEBUG_MMAP
@@ -228,7 +228,7 @@* TARGET_PAGE_SIZE, see exec.c. qemu_real_host_page_size is the * hosts real page size. */ -target_ulong host_end; +abi_ulong host_end;unsigned long host_aligned_start; host_len = HOST_PAGE_ALIGN(host_len + qemu_host_page_size
@@ -354,9 +354,9 @@return start; } -int target_munmap (target_ulong start,target_ulong len) +int target_munmap (abi_ulong start,abi_ulong len) { -target_ulong end, real_start, real_end, addr; +abi_ulong end, real_start, real_end, addr;int prot, ret;#ifdef DEBUG_MMAP
@@ -408,9 +408,9 @@/* XXX: currently, we only handle MAP_ANONYMOUS and not MAP_FIXED blocks which have been allocated starting on a host page */ -target_long target_mremap (target_ulong old_addr,target_ulong old_size, -target_ulong new_size,unsigned long flags, -target_ulong new_addr) +abi_long target_mremap (abi_ulong old_addr,abi_ulong old_size, +abi_ulong new_size,unsigned long flags, +abi_ulong new_addr) {int prot;unsigned long host_addr;
@@ -426,9 +426,9 @@return new_addr; } -int target_msync (target_ulong start,target_ulong len,int flags) +int target_msync (abi_ulong start,abi_ulong len,int flags) { -target_ulong end; +abi_ulong end;if (start & ~TARGET_PAGE_MASK )return -EINVAL ;
linux-user/ppc/syscall.h +1 -1
@@ -44,7 +44,7 @@/* ioctls */ struct target_revectored_struct { -target_ulong __map[8 ];/* 256 bits */ +abi_ulong __map[8 ];/* 256 bits */ };/*
linux-user/ppc/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUPPCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUPPCState *state) {return state->gpr[1 ]; }
linux-user/ppc64/syscall.h +1 -1
@@ -44,7 +44,7 @@/* ioctls */ struct target_revectored_struct { -target_ulong __map[8 ];/* 256 bits */ +abi_ulong __map[8 ];/* 256 bits */ };/*
linux-user/ppc64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -21,7 +21,7 @@#define TARGET_MINSIGSTKSZ 2048#define TARGET_SIGSTKSZ 8192 -static inline target_ulong get_sp_from_cpustate (CPUPPCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUPPCState *state) {return state->gpr[1 ]; }
linux-user/qemu.h +53 -43
185 lines not on this page · raw message
linux-user/sh4/target_signal.h +3 -3
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
linux-user/signal.c +133 -133
564 lines not on this page · raw message
linux-user/sparc/syscall.h +5 -5
@@ -1,9 +1,9 @@struct target_pt_regs { -target_ulong psr; -target_ulong pc; -target_ulong npc; -target_ulong y; -target_ulong u_regs[16 ]; +abi_ulong psr; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong u_regs[16 ]; };#define UNAME_MACHINE "sun4"
linux-user/sparc/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -28,7 +28,7 @@#define UREG_FP UREG_I6#endif -static inline target_ulong get_sp_from_cpustate (CPUSPARCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUSPARCState *state) {return state->regwptr[UREG_FP ]; }
linux-user/sparc64/syscall.h +6 -6
@@ -1,10 +1,10 @@struct target_pt_regs { -target_ulong u_regs[16 ]; -target_ulong tstate; -target_ulong pc; -target_ulong npc; -target_ulong y; -target_ulong fprs; +abi_ulong u_regs[16 ]; +abi_ulong tstate; +abi_ulong pc; +abi_ulong npc; +abi_ulong y; +abi_ulong fprs; };#define UNAME_MACHINE "sun4u"
linux-user/sparc64/target_signal.h +4 -4
@@ -6,9 +6,9 @@/* this struct defines a stack used during syscall handling */ typedef struct target_sigaltstack { -target_ulong ss_sp; -target_long ss_flags; -target_ulong ss_size; +abi_ulong ss_sp; +abi_long ss_flags; +abi_ulong ss_size; }target_stack_t ;
@@ -28,7 +28,7 @@#define UREG_FP UREG_I6#endif -static inline target_ulong get_sp_from_cpustate (CPUSPARCState *state) +static inline abi_ulong get_sp_from_cpustate (CPUSPARCState *state) {return state->regwptr[UREG_FP ]; }
linux-user/syscall.c +200 -200
950 lines not on this page · raw message
linux-user/syscall_defs.h +261 -261
522 lines not on this page · raw message
linux-user/x86_64/syscall.h +30 -30
60 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 31 lines · Blue Swirl
Quoted 13 lines · Thiemo Seufer
Blue Swirl wrote:
[snip]Quoted 11 lines
Index:
qemu/linux-user/mipsn32/syscall.h
===================================================================linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 renamed from linux-user/mipsn32/syscall.h 2007-10-11 19:17:14.000000000 +0000 +1
-1@@ -4,15 +4,15 @@ struct target_pt_regs { /* Saved main processor registers. */ - target_ulong regs[32]; + abi_ulong regs[32];Quoted 16 lines
Quoted 4 lines
linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 renamed from linux-user/mipsn32/syscall.h 2007-10-11 19:17:14.000000000 +0000 +0
-3/* Saved special registers. */ - target_ulong cp0_status; - target_ulong lo; - target_ulong hi;linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 line 16
Quoted 10 lines
linux-user/mipsn32/syscall.h 2007-10-11 19:17:46.000000000 +0000 renamed from linux-user/mipsn32/syscall.h 2007-10-11 19:17:14.000000000 +0000 +6
-3- target_ulong cp0_badvaddr; - target_ulong cp0_cause; - target_ulong cp0_epc; + abi_ulong cp0_status; + abi_ulong lo; + abi_ulong hi; + abi_ulong cp0_badvaddr; + abi_ulong cp0_cause; + abi_ulong cp0_epc; };This is broken. n32 has 64bit wide registers (and uses them for long long).
Quoted 5 lines
If
target_ulongis 64 bits, thenabi_ulongis 64 bits too and therefore correct. Unless you want to enable the ABI32 feature? It is only enabled for the new Sparc32plus and PPC targets for now.But I put the original
target_ulongsback.
I probably should have written "looks broken" than "is broken". In any case, having abi_ulong not matching the ABI's "unsigned long" is even more confusing than target_ulong not matching the ABI's "unsigned long".
Now that I think of it again I believe the ABI32 feature isn't usable for mips. The ABI-mandated structures are too different.
Thiemo
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
First of all, the personality was never set toPER_LINUX32
It's set in elfload32.c, but I think your approach is better. The check for elf_ex->e_ident[EI_CLASS] == ELFCLASS64
could be moved from elfload32.c.
Quoted 4 lines
The second problem was that pointers used to set the values on the stack were still of
target_ulongsize, which lead 32 bits executable crash dereferencing NULL pointers as soon as they wanted to parse their arguments.
Nice, I was wondering why my test program crashed.
Quoted 9 lines · Blue Swirl
Quoted 4 lines · J. Mayer
Following the patches done for elfload32, it appeared to me that there were still problems that would prevent 32 bits executables to run on 64 bits target in linux user mode emulation.
First of all, the personality was never set toPER_LINUX32It's set in
elfload32.c, but I think your approach is better. The check for elf_ex->e_ident[EI_CLASS] == ELFCLASS64
could be moved fromelfload32.c.
Well, it is overriden just before the create_elf_table call... And it's especially needed there and in the start_thread code, at least for PowerPC. As the kernel set it up at this point, it seems to be a good idea to do the same !
Quoted 6 lines
Quoted 4 lines
The second problem was that pointers used to set the values on the stack were still of
target_ulongsize, which lead 32 bits executable crash dereferencing NULL pointers as soon as they wanted to parse their arguments.Nice, I was wondering why my test program crashed.
I realized there are tons of unneeded checks/code in my patch, as this code is compiled twice. I will repost a cleaned one soon...
Signature · 2 lines
J. Mayer <[email protected]> Never organized