target/ppc: Fix test on mmu_model in hreg_compute_hflags_value()
PATCH 1/1 target/ppc: Fix test on mmu_model in hreg_compute_hflags_value()
POWERPC_MMU_BOOKE is not a mask and should not be tested with a bitwise AND operator.
It went unnoticed because it only impacts the 601 CPU implementation for which we don't have a known firmware image.
--- target/ppc/helper_regs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/ppc/helper_regs.c +4 -2
@@ -156,7 +156,8 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)*/ unsigned immu_idx, dmmu_idx; dmmu_idx = msr & (1 <<MSR_PR ) ?0 :1 ; -if (env->mmu_model &POWERPC_MMU_BOOKE ) { +if (env->mmu_model ==POWERPC_MMU_BOOKE || + env->mmu_model ==POWERPC_MMU_BOOKE206 ) { dmmu_idx |= msr & (1 <<MSR_GS ) ?4 :0 ; immu_idx = dmmu_idx; immu_idx |= msr & (1 <<MSR_IS ) ?2 :0 ;
@@ -237,7 +238,8 @@ int hreg_store_msr(CPUPPCState *env, target_ulong value, int alter_hv) ((value >> MSR_DR) & 1) != msr_dr) {cpu_interrupt_exittb (cs); } -if ((env->mmu_model &POWERPC_MMU_BOOKE ) && +if ((env->mmu_model ==POWERPC_MMU_BOOKE || + env->mmu_model ==POWERPC_MMU_BOOKE206 ) && ((value >>MSR_GS ) &1 ) != msr_gs) {cpu_interrupt_exittb (cs); }
Signature · 1 line
2.31.1
Quoted 5 lines · Cédric Le Goater
POWERPC_MMU_BOOKEis not a mask and should not be tested with a bitwise AND operator.It went unnoticed because it only impacts the 601 CPU implementation for which we don't have a known firmware image.
I forgot to change that. There is one here :
https://github.com/artyom-tarasenko/openfirmware
image :
https://github.com/artyom-tarasenko/openfirmware/releases/download/40p-20190413/q40pofw-serial.rom
Thanks,
C.
Quoted 30 lines
Signed-off-by Cédric Le Goater <[email protected]>--- target/ppc/helper_regs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/ppc/helper_regs.c +4
-2@@ -156,7 +156,8 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)*/ unsigned immu_idx, dmmu_idx; dmmu_idx = msr & (1 <<MSR_PR ) ?0 :1 ; -if (env->mmu_model &POWERPC_MMU_BOOKE ) { +if (env->mmu_model ==POWERPC_MMU_BOOKE || + env->mmu_model ==POWERPC_MMU_BOOKE206 ) { dmmu_idx |= msr & (1 <<MSR_GS ) ?4 :0 ; immu_idx = dmmu_idx; immu_idx |= msr & (1 <<MSR_IS ) ?2 :0 ;@@ -237,7 +238,8 @@ int hreg_store_msr(CPUPPCState *env, target_ulong value, int alter_hv) ((value >> MSR_DR) & 1) != msr_dr) {cpu_interrupt_exittb (cs); } -if ((env->mmu_model &POWERPC_MMU_BOOKE ) && +if ((env->mmu_model ==POWERPC_MMU_BOOKE || + env->mmu_model ==POWERPC_MMU_BOOKE206 ) && ((value >>MSR_GS ) &1 ) != msr_gs) {cpu_interrupt_exittb (cs); }
Quoted 7 lines · Cédric le Goater
POWERPC_MMU_BOOKEis not a mask and should not be tested with a bitwise AND operator.It went unnoticed because it only impacts the 601 CPU implementation for which we don't have a known firmware image.
Signed-off-by Cédric Le Goater <[email protected]>
The longer term fix, of course, is to entirely get rid of the unholy mix of enum and bitmask that is mmu_model.
Quoted 28 lines
--- target/ppc/helper_regs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/ppc/helper_regs.c +4
-2@@ -156,7 +156,8 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)*/ unsigned immu_idx, dmmu_idx; dmmu_idx = msr & (1 <<MSR_PR ) ?0 :1 ; -if (env->mmu_model &POWERPC_MMU_BOOKE ) { +if (env->mmu_model ==POWERPC_MMU_BOOKE || + env->mmu_model ==POWERPC_MMU_BOOKE206 ) { dmmu_idx |= msr & (1 <<MSR_GS ) ?4 :0 ; immu_idx = dmmu_idx; immu_idx |= msr & (1 <<MSR_IS ) ?2 :0 ;@@ -237,7 +238,8 @@ int hreg_store_msr(CPUPPCState *env, target_ulong value, int alter_hv) ((value >> MSR_DR) & 1) != msr_dr) {cpu_interrupt_exittb (cs); } -if ((env->mmu_model &POWERPC_MMU_BOOKE ) && +if ((env->mmu_model ==POWERPC_MMU_BOOKE || + env->mmu_model ==POWERPC_MMU_BOOKE206 ) && ((value >>MSR_GS ) &1 ) != msr_gs) {cpu_interrupt_exittb (cs); }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson