target/alpha: Fix bug 1701835
cover target/alpha: Fix bug 1701835
Serves me right for really only being interested in system testing. Anyway, in order to emulate user-only properly, we have to do all of the crazy things the kernel does, forced on us by the crazy DEC hardware engineers.
r~
Richard Henderson (2):
target/alpha: Clean up alpha_cpu_dump_state target/alpha: Fix user-only floating-point exceptions
linux-user/syscall_defs.h | 3 +- target/alpha/cpu.h | 42 +++++++++++++++ linux-user/syscall.c | 104 ++++++++++++++++++-------------------- target/alpha/fpu_helper.c | 21 ++++++-- target/alpha/helper.c | 39 ++++++++++---- 5 files changed, 140 insertions(+), 69 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 target/alpha: Clean up alpha_cpu_dump_state
Drop the "RI" and "FIR" prefixes; use only the normal linux names. Add the FPCR to the dump.
--- target/alpha/helper.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
target/alpha/helper.c +10 -9
@@ -429,32 +429,33 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request)void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags) { -static const char *linux_reg_names[] = { -"v0 " ,"t0 " ,"t1 " ,"t2 " ,"t3 " ,"t4 " ,"t5 " ,"t6 " , -"t7 " ,"s0 " ,"s1 " ,"s2 " ,"s3 " ,"s4 " ,"s5 " ,"fp " , -"a0 " ,"a1 " ,"a2 " ,"a3 " ,"a4 " ,"a5 " ,"t8 " ,"t9 " , -"t10" ,"t11" ,"ra " ,"t12" ,"at " ,"gp " ,"sp " ,"zero" , +static const char linux_reg_names[31 ][4 ] = { +"v0" ,"t0" ,"t1" ,"t2" ,"t3" ,"t4" ,"t5" ,"t6" , +"t7" ,"s0" ,"s1" ,"s2" ,"s3" ,"s4" ,"s5" ,"fp" , +"a0" ,"a1" ,"a2" ,"a3" ,"a4" ,"a5" ,"t8" ,"t9" , +"t10" ,"t11" ,"ra" ,"t12" ,"at" ,"gp" ,"sp" };AlphaCPU *cpu =ALPHA_CPU (cs);CPUAlphaState *env = &cpu->env;int i; -qemu_fprintf (f," PC " TARGET_FMT_lx" PS %02x\n" , +qemu_fprintf (f,"PC " TARGET_FMT_lx" PS %02x\n" , env->pc,extract32 (env->flags,ENV_FLAG_PS_SHIFT ,8 ));for (i =0 ; i <31 ; i++) { -qemu_fprintf (f,"IR%02d %s " TARGET_FMT_lx"%c" , i, +qemu_fprintf (f,"%-8s" TARGET_FMT_lx"%c" , linux_reg_names[i],cpu_alpha_load_gr (env, i), (i %3 ) ==2 ?'\n' :' ' ); } -qemu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , +qemu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , env->lock_addr, env->lock_value);if (flags &CPU_DUMP_FPU ) {for (i =0 ; i <31 ; i++) { -qemu_fprintf (f,"FIR%02d %016" PRIx64"%c" , i, env->fir[i], +qemu_fprintf (f,"f%-7d%016" PRIx64"%c" , i, env->fir[i], (i %3 ) ==2 ?'\n' :' ' ); } +qemu_fprintf (f,"fpcr %016" PRIx64"\n" ,cpu_alpha_load_fpcr (env)); }qemu_fprintf (f,"\n" ); }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 1/2] target/alpha: Clean up alpha_cpu_dump_state
Quoted 27 lines · Richard Henderson
Drop the "RI" and "FIR" prefixes; use only the normal linux names. Add the FPCR to the dump.
Signed-off-by Richard Henderson <[email protected]>--- target/alpha/helper.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)target/alpha/helper.c +5
-5@@ -429,32 +429,33 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request)void alpha_cpu_dump_state (CPUState *cs,FILE *f,int flags) { -static const char *linux_reg_names[] = { -"v0 " ,"t0 " ,"t1 " ,"t2 " ,"t3 " ,"t4 " ,"t5 " ,"t6 " , -"t7 " ,"s0 " ,"s1 " ,"s2 " ,"s3 " ,"s4 " ,"s5 " ,"fp " , -"a0 " ,"a1 " ,"a2 " ,"a3 " ,"a4 " ,"a5 " ,"t8 " ,"t9 " , -"t10" ,"t11" ,"ra " ,"t12" ,"at " ,"gp " ,"sp " ,"zero" , +static const char linux_reg_names[31 ][4 ] = { +"v0" ,"t0" ,"t1" ,"t2" ,"t3" ,"t4" ,"t5" ,"t6" , +"t7" ,"s0" ,"s1" ,"s2" ,"s3" ,"s4" ,"s5" ,"fp" , +"a0" ,"a1" ,"a2" ,"a3" ,"a4" ,"a5" ,"t8" ,"t9" , +"t10" ,"t11" ,"ra" ,"t12" ,"at" ,"gp" ,"sp" };
target/alpha/helper.c bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) · line 445
Quoted 10 lines
target/alpha/helper.c +2
-2AlphaCPU *cpu =ALPHA_CPU (cs);CPUAlphaState *env = &cpu->env;int i; -qemu_fprintf (f," PC " TARGET_FMT_lx" PS %02x\n" , +qemu_fprintf (f,"PC " TARGET_FMT_lx" PS %02x\n" , env->pc,extract32 (env->flags,ENV_FLAG_PS_SHIFT ,8 ));for (i =0 ; i <31 ; i++) { - qemu_fprintf(f, "IR%02d %s " TARGET_FMT_lx "%c", i, + qemu_fprintf(f, "%-8s" TARGET_FMT_lx "%c",
I often wondered was this useful for (I mean, one would focus on one or another, but having both displayed was not helpful IMO). Now the output looks clearer, thanks!
Quoted 19 lines
target/alpha/helper.c +3
-2linux_reg_names[i],cpu_alpha_load_gr (env, i), (i % 3) == 2 ? '\n' : ' '); } -qemu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , +qemu_fprintf (f,"lock_a " TARGET_FMT_lx" lock_v " TARGET_FMT_lx"\n" , env->lock_addr, env->lock_value);if (flags &CPU_DUMP_FPU ) {for (i =0 ; i <31 ; i++) { -qemu_fprintf (f,"FIR%02d %016" PRIx64"%c" , i, env->fir[i], +qemu_fprintf (f,"f%-7d%016" PRIx64"%c" , i, env->fir[i], (i %3 ) ==2 ?'\n' :' ' ); } +qemu_fprintf (f,"fpcr %016" PRIx64"\n" ,cpu_alpha_load_fpcr (env)); }qemu_fprintf (f,"\n" ); }
PATCH 2/2 target/alpha: Fix user-only floating-point exceptions
In reply to Richard HendersonRecord the software fp control register, as set by the osf_setsysinfo syscall. Add those masked exceptions to fpcr_exc_enable. Do not raise a signal for masked fp exceptions.
--- linux-user/syscall_defs.h | 3 +- target/alpha/cpu.h | 42 +++++++++++++++ linux-user/syscall.c | 104 ++++++++++++++++++-------------------- target/alpha/fpu_helper.c | 21 ++++++-- target/alpha/helper.c | 20 +++++++- 5 files changed, 130 insertions(+), 60 deletions(-)
linux-user/syscall_defs.h +2 -1
@@ -635,7 +635,8 @@ typedef struct target_siginfo {#define TARGET_FPE_FLTRES (6)/* floating point inexact result */ #define TARGET_FPE_FLTINV (7)/* floating point invalid operation */ #define TARGET_FPE_FLTSUB (8)/* subscript out of range */ -#define TARGET_NSIGFPE 8 +#define TARGET_FPE_FLTUNK (14)/* undiagnosed fp exception */ +#define TARGET_NSIGFPE 15/* * SIGSEGV si_codes
target/alpha/cpu.h +42 -0
58 lines not on this page · raw message
linux-user/syscall.c +50 -54
143 lines not on this page · raw message
target/alpha/fpu_helper.c +18 -3
@@ -91,10 +91,25 @@ void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t regno)if (exc) { env->fpcr |= exc; exc &= ~ignore; -if (exc) { - exc &= env->fpcr_exc_enable; -fp_exc_raise1 (env,GETPC (), exc, regno,EXC_M_SWC ); +#ifdef CONFIG_USER_ONLY +/* +* In user mode, the kernel's software handler only +* delivers a signal if the exception is enabled. +*/ +if (!(exc & env->fpcr_exc_enable)) { +return ; } +#else +/* +* In system mode, the software handler gets invoked +* for any non-ignored exception. +*/ +if (!exc) { +return ; + } +#endif + exc &= env->fpcr_exc_enable; +fp_exc_raise1 (env,GETPC (), exc, regno,EXC_M_SWC ); } }
target/alpha/helper.c +18 -2
@@ -29,12 +29,12 @@#define CONVERT_BIT (X ,SRC ,DST ) \ (SRC > DST ? (X) / (SRC / DST) & (DST) : ((X) & SRC) * (DST / SRC)) -uint64_t cpu_alpha_load_fpcr (CPUAlphaState *env) +uint64_t cpu_alpha_load_fpcr (CPUAlphaState *env) {return (uint64_t )env->fpcr <<32 ; } -void cpu_alpha_store_fpcr (CPUAlphaState *env,uint64_t val) +void cpu_alpha_store_fpcr (CPUAlphaState *env,uint64_t val) {uint32_t fpcr = val >>32 ;uint32_t t =0 ;
@@ -67,6 +67,22 @@ void cpu_alpha_store_fpcr (CPUAlphaState *env, uint64_t val) env->fpcr_flush_to_zero = (fpcr &FPCR_UNFD ) && (fpcr &FPCR_UNDZ ); env->fp_status.flush_inputs_to_zero = (fpcr &FPCR_DNZ ) !=0 ; + +#ifdef CONFIG_USER_ONLY +/* +* Override some of these bits with the contents of ENV->SWCR. +* In system mode, some of these would trap to the kernel, at +* which point the kernel's handler would emulate and apply +* the software exception mask. +*/ +if (env->swcr &SWCR_MAP_DMZ ) { + env->fp_status.flush_inputs_to_zero =1 ; + } +if (env->swcr &SWCR_MAP_UMZ ) { + env->fp_status.flush_to_zero =1 ; + } + env->fpcr_exc_enable &= ~(alpha_ieee_swcr_to_fpcr (env->swcr) >>32 ); +#endif }uint64_t helper_load_fpcr (CPUAlphaState *env)
Signature · 1 line
2.17.1