QEMU 0.2 is out
Most of the QEMU architecture is now finished. There are still complicated issues regarding thread locking. My main issue is that I would like to avoid locking the cpu emulator while doing 'tb_find()'.
DOSEMU is now working better (I was able to launch DOS Navigator and a small VGA demonstration). The speed seems reasonnable althought QEMU has to emulate both the DOS code _and_ the dosemu code itself !
About the Sparc code: is it possible to move the prolog and epilog generation from dyngen_code() to the cpu main loop ? It would ease a lot the precise exception handling and the direct block chaining.
For Alpha and Sparc, if someone has an account that I can use, I could make some debug to fix the last issues.
Fabrice.
Quoted 3 lines
For Alpha and Sparc, if someone has an account that I can use, I could make some debug to fix the last issues.
You can get an account on Alpha Linux from HP at
http://www.testdrive.compaq.com/, or I can give you one on my machine if you send me a ssh key.
I've attached a patch with all my changes, it doesn't seem to work at all though, I get sig11 on all tests. It used to work "mostly" about two weeks ago. I don't have time right now to look into it...
I think the fault address reporting was only introduced in 2.4.20 on Alpha, so it might not work on older kernels.
Signature · 1 line
Falk
Index: dyngen.c
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen.c,v
retrieving revision 1.16
dyngen.c +1 -1
@@ -691,7 +691,7 @@ void gen_code(const char *name, host_ulocase R_ALPHA_BRSGP :/* PC-relative jump. Tweak offset to skip the two instructions that try to set up the gp from the pv. */ -fprintf (outfile," fix_bsr(gen_code_ptr + %ld, (uint8_t *) &%s - (gen_code_ptr + %ld) + 4);\n" , +fprintf (outfile," fix_bsr(gen_code_ptr + %ld, (uint8_t *) &%s - (gen_code_ptr + %ld + 4) + 8);\n" , rel->r_offset - start_offset, sym_name, rel->r_offset - start_offset);break ;default :
Index: exec-i386.c
===================================================================
RCS file: /cvsroot/qemu/qemu/exec-i386.c,v
retrieving revision 1.26
exec-i386.c +28 -0
@@ -447,6 +447,34 @@ int cpu_x86_signal_handler(int host_sign is_write, &uc->uc_sigmask); } +#elif defined(__alpha__) + +int cpu_x86_signal_handler (int host_signum,struct siginfo *info, +void *puc) +{ +struct ucontext *uc = puc; +uint32_t *pc = uc->uc_mcontext.sc_pc; +uint32_t insn = *pc; +int is_write =0 ; + +switch (insn >>26 ) { +case 0x0d :// stw +case 0x0e :// stb +case 0x0f :// stq_u +case 0x24 :// stf +case 0x25 :// stg +case 0x26 :// sts +case 0x27 :// stt +case 0x2c :// stl +case 0x2d :// stq +case 0x2e :// stl_c +case 0x2f :// stq_c + is_write =1 ; + } + +return handle_cpu_signal (pc, (unsigned long )info->si_addr, + is_write, &uc->uc_sigmask); +}#else #error CPU specific signal handler needed
Index: exec-i386.h
===================================================================
RCS file: /cvsroot/qemu/qemu/exec-i386.h,v
retrieving revision 1.17
exec-i386.h +2 -0
@@ -124,6 +124,8 @@ register unsigned int A0 asm("$11"); registerunsigned int EAX asm("$12" ); registerunsigned int ESP asm("$13" ); registerunsigned int EBP asm("$14" ); +/* Note $15 is the frame pointer, so anything in op-i386.c that would +require a frame pointer, like alloca, would probably loose. */ registerstruct CPUX86State *env asm("$15" );#define reg_EAX#define reg_ESP
Index: exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/exec.h,v
retrieving revision 1.3
exec.h +1 -1
@@ -214,7 +214,7 @@ static inline int testandset (int *p)#endif #ifdef __alpha__ -int testandset (int *p) +static inline int testandset (int *p) {int ret;unsigned long one;
Index: op-i386.c
===================================================================
RCS file: /cvsroot/qemu/qemu/op-i386.c,v
retrieving revision 1.31
op-i386.c +5 -5
@@ -1762,16 +1762,16 @@ typedef union {double d;#ifndef WORDS_BIGENDIAN struct { -unsigned long lower; -long upper; +uint32_t lower; +int32_t upper; } l;#else struct { -long upper; -unsigned long lower; +int32_t upper; +uint32_t lower; } l;#endif -long long ll; +int64_t ll; } CPU86_LDoubleU;/* the following deal with IEEE double-precision numbers */
Quoted 8 lines · Falk Hueffner
Quoted 2 lines
For Alpha and Sparc, if someone has an account that I can use, I could make some debug to fix the last issues.
You can get an account on Alpha Linux from HP at
http://www.testdrive.compaq.com/, or I can give you one on my machine if you send me a ssh key.
Quoted 6 lines
I've attached a patch with all my changes, it doesn't seem to work at all though, I get sig11 on all tests. It used to work "mostly" about two weeks ago. I don't have time right now to look into it...
I think the fault address reporting was only introduced in 2.4.20 on Alpha, so it might not work on older kernels.
I have now access to an Alpha and a Sparc computer.
For Alpha: I am using gcc 3.2.3 and '-msmall-text' is not supported. Is it really necessary ?
Fabrice.
Quoted 2 lines · Fabrice Bellard
For Alpha: I am using gcc 3.2.3 and '-msmall-text' is not supported. Is it really necessary ?
Not really, I was just hoping to avoid a few gp readjustments with it, however it doesn't really seem to have that effect, since for non-static functions, that cannot be done, and for static functions, gcc already knows to avoid gp restoring.
Signature · 1 line
Falk
Quoted 11 lines · Falk Hueffner
Quoted 2 lines · Fabrice Bellard
For Alpha: I am using gcc 3.2.3 and '-msmall-text' is not supported. Is it really necessary ?
Not really, I was just hoping to avoid a few gp readjustments with it, however it doesn't really seem to have that effect, since for non-static functions, that cannot be done, and for static functions, gcc already knows to avoid gp restoring.
Which version of gcc are you using ? Do you use a patched gcc ? Can you give me your spec file and the gcc -v log when you compile op-i386.c ?
I am totally unable to get correct code. In particular, I cannot make gcc 3.2.3 generate R_ALPHA_BRADDR relocations. Currently, to get correct code, I must do the following:
--
int __op_param1;
#define PARAM1 ({ int _r; asm("ldah %0,__op_param1($29) !gprelhigh\n" \
"lda %0,__op_param1(%0) !gprellow" : "=r"(_r) ); _r; })
#define CALL(x) asm volatile ("bsr $26, %0" : : "i" (x)) --
and use the macro CALL to call a function!
Fabrice.
Quoted 3 lines · Fabrice Bellard
Which version of gcc are you using ? Do you use a patched gcc ? Can you give me your spec file and the gcc -v log when you compile
op-i386.c?
I use gcc 3.3 or 3.4 snapshots usually.
Quoted 9 lines
I am totally unable to get correct code. In particular, I cannot make gcc 3.2.3 generate
R_ALPHA_BRADDRrelocations. Currently, to get correct code, I must do the following:--
int__op_param1;#define PARAM1 ({ int _r; asm("ldah %0,__op_param1($29) !gprelhigh\n" \ "lda %0,__op_param1(%0) !gprellow" : "=r"(_r) ); _r; })
Ah yes, this is because gcc 3.2.3 doesn't support visibility("hidden") yet. If a symbol has global visibility, gcc cannot know it is accessed with the same gp, since it might be provided by libc for example. I don't think there's any better way do this with 3.2.3.
Quoted 3 lines
#define CALL(x) asm volatile ("bsr $26, %0" : : "i" (x)) --
and use the macro CALL to call a function!
This seems to works for me even with 3.2.3. What happens if you don't use the macro? Maybe your binutils is too old? I have 2.14.90.0.4-0.1.
Also, concerning the signal handler, siginfo is only filled in with 2.4.20 and newer kernels...
Signature · 1 line
Falk
With gcc 3.3 and binutils 2.14.90.0.4 it is better. I fixed some bugs related to the new jump optimisation I introduced. But there is a big problem: no relocations are generated for calls to global functions if they are in the same file as the function call. I am trying various patches for this.
Fabrice.
Quoted 39 lines · Falk Hueffner
Quoted 3 lines · Fabrice Bellard
Which version of gcc are you using ? Do you use a patched gcc ? Can you give me your spec file and the gcc -v log when you compile
op-i386.c?I use gcc 3.3 or 3.4 snapshots usually.
Quoted 9 lines
I am totally unable to get correct code. In particular, I cannot make gcc 3.2.3 generate
R_ALPHA_BRADDRrelocations. Currently, to get correct code, I must do the following:--
int__op_param1;#define PARAM1 ({ int _r; asm("ldah %0,__op_param1($29) !gprelhigh\n" \ "lda %0,__op_param1(%0) !gprellow" : "=r"(_r) ); _r; })Ah yes, this is because gcc 3.2.3 doesn't support
visibility("hidden")yet. If a symbol has global visibility, gcc cannot know it is accessed with the same gp, since it might be provided by libc for example. I don't think there's any better way do this with 3.2.3.Quoted 3 lines
#define CALL(x) asm volatile ("bsr $26, %0" : : "i" (x)) --
and use the macro CALL to call a function!This seems to works for me even with 3.2.3. What happens if you don't use the macro? Maybe your binutils is too old? I have 2.14.90.0.4-0.1.
Also, concerning the signal handler, siginfo is only filled in with 2.4.20 and newer kernels...
Signature · 1 line
Fabrice.
[Qemu-devel] QEMU on Alpha
In reply to Falk HueffnerHi,
The CVS version of QEMU should now launch test-i386 successfully on Alpha. If you want to try it, read the README file to know what are the tested tools (gcc 3.3 is _required_). I tested it only with a 2.2 Linux kernel, so I was not able to test the precise exception support which requires a 2.4.20 kernel.
The remaining issues (in particular with ls) should only be related to bad syscall emulation, which is easier to fix.
Fabrice.