On Fri, 2 Feb 2007, Paul Robinson wrote: > But the T0, T1, and T2 registers are being saved for the benefit of the > host not the target.
FWIW, I use the following patch for Virtual Box on x86_64. The proper fix would be to not globally allocate registers for the whole program but only for the micro-ops. Then, make the necessary save/restore around the gen_func call. --- vbox-1.3.3/src/recompiler/new/cpu-exec.c.64bit-fixes 2007-01-23 10:30:18.000000000 +0100 +++ vbox-1.3.3/src/recompiler/new/cpu-exec.c 2007-02-02 18:16:19.000000000 +0100 @@ -228,7 +228,23 @@ static inline TranslationBlock *tb_find_ int cpu_exec(CPUState *env1) { - int saved_T0, saved_T1, saved_T2; + /* Preserve callee-saved registers */ +#ifdef AREG0 + register unsigned long reg_AREG0 asm(AREG0); + volatile unsigned long saved_AREG0; +#endif +#ifdef AREG1 + register unsigned long reg_AREG1 asm(AREG1); + volatile unsigned long saved_AREG1; +#endif +#ifdef AREG2 + register unsigned long reg_AREG2 asm(AREG2); + volatile unsigned long saved_AREG2; +#endif +#ifdef AREG3 + register unsigned long reg_AREG3 asm(AREG3); + volatile unsigned long saved_AREG3; +#endif CPUState *saved_env; #ifdef reg_EAX int saved_EAX; @@ -319,10 +335,17 @@ int cpu_exec(CPUState *env1) /* first we save global registers */ saved_env = env; env = env1; - saved_T0 = T0; - saved_T1 = T1; -#if defined(reg_T2) - saved_T2 = T2; +#ifdef AREG0 + saved_AREG0 = reg_AREG0; +#endif +#ifdef AREG1 + saved_AREG1 = reg_AREG1; +#endif +#ifdef AREG2 + saved_AREG2 = reg_AREG2; +#endif +#ifdef AREG3 + saved_AREG3 = reg_AREG3; #endif #if defined(__sparc__) && !defined(HOST_SOLARIS) /* we also save i7 because longjmp may not restore it */ @@ -656,9 +679,18 @@ int cpu_exec(CPUState *env1) #else #error unsupported target CPU #endif - T0 = saved_T0; - T1 = saved_T1; - T2 = saved_T2; +#ifdef AREG0 + reg_AREG0 = saved_AREG0; +#endif +#ifdef AREG1 + reg_AREG1 = saved_AREG1; +#endif +#ifdef AREG2 + reg_AREG2 = saved_AREG2; +#endif +#ifdef AREG3 + reg_AREG3 = saved_AREG3; +#endif env = saved_env; return ret; } _______________________________________________ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel