target/ppc: powerpc_excp improvements (2/n)
v3 cover target/ppc: powerpc_excp improvements (2/n)
Version 3:
- patches 1,3,4,5,6,7: unchanged, reviewed;
- patch 2: started using qemu_loglevel_mask(CPU_LOG_MMU) instead of
qemu_log_enabled; I decided to not rename the function at this point because it is used for both 60x and 7x5 and these two will be split in the near future, so allow me to postpone that;
- patch 8: new patch using env->has_hv_mode to fix the endianness of powernv dumps as suggested by David.
v2:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-01/msg00139.html
v1:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-01/msg00054.html
RFC v1:
https://lists.nongnu.org/archive/html/qemu-ppc/2021-06/msg00026.html
RFC v2:
https://lists.nongnu.org/archive/html/qemu-ppc/2021-12/msg00542.html
Cleanups 1/n [already merged]:
https://mail.gnu.org/archive/html/qemu-ppc/2021-12/msg00696.html
Fabiano Rosas (8):
target/ppc: powerpc_excp: Extract software TLB logging into a function target/ppc: powerpc_excp: Keep 60x/7x5 soft MMU logs active target/ppc: powerpc_excp: Group unimplemented exceptions target/ppc: Add HV support to ppc_interrupts_little_endian target/ppc: Add MSR_ILE support to ppc_interrupts_little_endian target/ppc: Use ppc_interrupts_little_endian in powerpc_excp target/ppc: Introduce a wrapper for powerpc_excp target/ppc: Set the correct endianness for powernv memory dumps
target/ppc/arch_dump.c | 2 +- target/ppc/cpu.h | 25 ++++-- target/ppc/excp_helper.c | 183 ++++++++++++--------------------------- 3 files changed, 73 insertions(+), 137 deletions(-)
Signature · 1 line
2.33.1
PATCH v3 1/8 target/ppc: powerpc_excp: Extract software TLB logging into a function
--- target/ppc/excp_helper.c | 63 +++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 27 deletions(-)
target/ppc/excp_helper.c +36 -27
@@ -135,6 +135,41 @@ static void dump_hcall(CPUPPCState *env) env->nip); } +static void ppc_excp_debug_sw_tlb (CPUPPCState *env,int excp) +{ +#if defined(DEBUG_SOFTWARE_TLB ) +const char *es; +target_ulong *miss, *cmp; +int en; + +if (!qemu_log_enabled ()) { +return ; + } + +if (excp ==POWERPC_EXCP_IFTLB ) { + es ="I" ; + en ='I' ; + miss = &env->spr[SPR_IMISS ]; + cmp = &env->spr[SPR_ICMP ]; + }else { +if (excp ==POWERPC_EXCP_DLTLB ) { + es ="DL" ; + }else { + es ="DS" ; + } + en ='D' ; + miss = &env->spr[SPR_DMISS ]; + cmp = &env->spr[SPR_DCMP ]; + } +qemu_log ("6xx %sTLB miss: %cM " TARGET_FMT_lx" %cC " + TARGET_FMT_lx" H1 " TARGET_FMT_lx" H2 " + TARGET_FMT_lx" %08x\n" , es, en, *miss, en, *cmp, + env->spr[SPR_HASH1 ], env->spr[SPR_HASH2 ], + env->error_code); +#endif +} + +static int powerpc_reset_wakeup (CPUState *cs,CPUPPCState *env,int excp,target_ulong *msr) {
@@ -777,34 +812,8 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp) }/* fall through */ case POWERPC_EXCP_7x5: -#if defined(DEBUG_SOFTWARE_TLB ) -if (qemu_log_enabled ()) { -const char *es; -target_ulong *miss, *cmp; -int en; +ppc_excp_debug_sw_tlb (env, excp); -if (excp ==POWERPC_EXCP_IFTLB ) { - es ="I" ; - en ='I' ; - miss = &env->spr[SPR_IMISS ]; - cmp = &env->spr[SPR_ICMP ]; - }else { -if (excp ==POWERPC_EXCP_DLTLB ) { - es ="DL" ; - }else { - es ="DS" ; - } - en ='D' ; - miss = &env->spr[SPR_DMISS ]; - cmp = &env->spr[SPR_DCMP ]; - } -qemu_log ("6xx %sTLB miss: %cM " TARGET_FMT_lx" %cC " - TARGET_FMT_lx" H1 " TARGET_FMT_lx" H2 " - TARGET_FMT_lx" %08x\n" , es, en, *miss, en, *cmp, - env->spr[SPR_HASH1 ], env->spr[SPR_HASH2 ], - env->error_code); - } -#endif msr |= env->crf[0 ] <<28 ; msr |= env->error_code;/* key, D/I, S/L bits */ /* Set way using a LRU mechanism */
Signature · 1 line
2.33.1
PATCH v3 2/8 target/ppc: powerpc_excp: Keep 60x/7x5 soft MMU logs active
In reply to Fabiano RosasRemove the compile time definition and make the logging be controlled by the -d mmu option in the cmdline.
--- target/ppc/excp_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
target/ppc/excp_helper.c +1 -5
@@ -30,8 +30,6 @@#include "exec/cpu_ldst.h" #endif -/* #define DEBUG_SOFTWARE_TLB */ -/*****************************************************************************/ /* Exception processing */ #if !defined(CONFIG_USER_ONLY )
@@ -137,12 +135,11 @@ static void dump_hcall(CPUPPCState *env)static void ppc_excp_debug_sw_tlb (CPUPPCState *env,int excp) { -#if defined(DEBUG_SOFTWARE_TLB )const char *es;target_ulong *miss, *cmp;int en; -if (!qemu_log_enabled ()) { +if (!qemu_loglevel_mask (CPU_LOG_MMU )) {return ; }
@@ -166,7 +163,6 @@ static void ppc_excp_debug_sw_tlb(CPUPPCState *env, int excp) TARGET_FMT_lx" %08x\n" , es, en, *miss, en, *cmp, env->spr[SPR_HASH1 ], env->spr[SPR_HASH2 ], env->error_code); -#endif }
Signature · 1 line
2.33.1
PATCH v3 3/8 target/ppc: powerpc_excp: Group unimplemented exceptions
In reply to Fabiano Rosas--- target/ppc/excp_helper.c | 77 +++++----------------------------------- 1 file changed, 8 insertions(+), 69 deletions(-)
target/ppc/excp_helper.c +8 -69
@@ -700,23 +700,6 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavailable/VPU */ env->spr[SPR_BOOKE_ESR ] =ESR_SPV ;break ; -case POWERPC_EXCP_EFPDI :/* Embedded floating-point data interrupt */ -/* XXX: TODO */ -cpu_abort (cs,"Embedded floating point data exception " -"is not implemented yet !\n" ); - env->spr[SPR_BOOKE_ESR ] =ESR_SPV ; -break ; -case POWERPC_EXCP_EFPRI :/* Embedded floating-point round interrupt */ -/* XXX: TODO */ -cpu_abort (cs,"Embedded floating point round exception " -"is not implemented yet !\n" ); - env->spr[SPR_BOOKE_ESR ] =ESR_SPV ; -break ; -case POWERPC_EXCP_EPERFM :/* Embedded performance monitor interrupt */ -/* XXX: TODO */ -cpu_abort (cs, -"Performance counter exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_DOORI :/* Embedded doorbell interrupt */ break ;case POWERPC_EXCP_DOORCI :/* Embedded doorbell critical interrupt */
@@ -781,19 +764,6 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ trace_ppc_excp_print ("PIT" );break ; -case POWERPC_EXCP_IO :/* IO error exception */ -/* XXX: TODO */ -cpu_abort (cs,"601 IO error exception is not implemented yet !\n" ); -break ; -case POWERPC_EXCP_RUNM :/* Run mode exception */ -/* XXX: TODO */ -cpu_abort (cs,"601 run mode exception is not implemented yet !\n" ); -break ; -case POWERPC_EXCP_EMUL :/* Emulation trap exception */ -/* XXX: TODO */ -cpu_abort (cs,"602 emulation trap exception " -"is not implemented yet !\n" ); -break ;case POWERPC_EXCP_IFTLB :/* Instruction fetch TLB error */ case POWERPC_EXCP_DLTLB :/* Data load TLB miss */ case POWERPC_EXCP_DSTLB :/* Data store TLB miss */
@@ -820,56 +790,25 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)break ; }break ; +case POWERPC_EXCP_EFPDI :/* Embedded floating-point data interrupt */ +case POWERPC_EXCP_EFPRI :/* Embedded floating-point round interrupt */ +case POWERPC_EXCP_EPERFM :/* Embedded performance monitor interrupt */ +case POWERPC_EXCP_IO :/* IO error exception */ +case POWERPC_EXCP_RUNM :/* Run mode exception */ +case POWERPC_EXCP_EMUL :/* Emulation trap exception */ case POWERPC_EXCP_FPA :/* Floating-point assist exception */ -/* XXX: TODO */ -cpu_abort (cs,"Floating point assist exception " -"is not implemented yet !\n" ); -break ;case POWERPC_EXCP_DABR :/* Data address breakpoint */ -/* XXX: TODO */ -cpu_abort (cs,"DABR exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_IABR :/* Instruction address breakpoint */ -/* XXX: TODO */ -cpu_abort (cs,"IABR exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_SMI :/* System management interrupt */ -/* XXX: TODO */ -cpu_abort (cs,"SMI exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_THERM :/* Thermal interrupt */ -/* XXX: TODO */ -cpu_abort (cs,"Thermal management exception " -"is not implemented yet !\n" ); -break ;case POWERPC_EXCP_PERFM :/* Embedded performance monitor interrupt */ -/* XXX: TODO */ -cpu_abort (cs, -"Performance counter exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_VPUA :/* Vector assist exception */ -/* XXX: TODO */ -cpu_abort (cs,"VPU assist exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_SOFTP :/* Soft patch exception */ -/* XXX: TODO */ -cpu_abort (cs, -"970 soft-patch exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_MAINT :/* Maintenance exception */ -/* XXX: TODO */ -cpu_abort (cs, -"970 maintenance exception is not implemented yet !\n" ); -break ;case POWERPC_EXCP_MEXTBR :/* Maskable external breakpoint */ -/* XXX: TODO */ -cpu_abort (cs,"Maskable external exception " -"is not implemented yet !\n" ); -break ;case POWERPC_EXCP_NMEXTBR :/* Non maskable external breakpoint */ -/* XXX: TODO */ -cpu_abort (cs,"Non maskable external exception " -"is not implemented yet !\n" ); +cpu_abort (cs,"%s exception not implemented\n" , +powerpc_excp_name (excp));break ;default : excp_invalid:
Signature · 1 line
2.33.1
PATCH v3 4/8 target/ppc: Add HV support to ppc_interrupts_little_endian
In reply to Fabiano RosasThe ppc_interrupts_little_endian function could be used for interrupts delivered in Hypervisor mode, so add support for powernv8 and powernv9 to it.
Also drop the comment because it is inaccurate, all CPUs that can run little endian can have interrupts in little endian. The point is whether they can take interrupts in an endianness different from MSR_LE.
This change has no functional impact.
--- target/ppc/arch_dump.c | 2 +- target/ppc/cpu.h | 23 +++++++++++++++-------- target/ppc/excp_helper.c | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-)
target/ppc/arch_dump.c +1 -1
@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu)) { +if (ppc_interrupts_little_endian (cpu, false)) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
target/ppc/cpu.h +15 -8
@@ -2728,20 +2728,27 @@ static inline bool ppc_has_spr(PowerPCCPU *cpu, int spr)return cpu->env.spr_cb[spr].name !=NULL ; } -static inline bool ppc_interrupts_little_endian (PowerPCCPU *cpu) +#if !defined(CONFIG_USER_ONLY ) +static inline bool ppc_interrupts_little_endian (PowerPCCPU *cpu,bool hv) {PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu); +CPUPPCState *env = &cpu->env; +bool ile = false; -/* -* Only models that have an LPCR and know about LPCR_ILE can do little -* endian. -*/ -if (pcc->lpcr_mask &LPCR_ILE ) { -return !!(cpu->env.spr[SPR_LPCR ] &LPCR_ILE ); +if (hv && env->has_hv_mode) { +if (is_isa300 (pcc)) { + ile = !!(env->spr[SPR_HID0 ] &HID0_POWER9_HILE ); + }else { + ile = !!(env->spr[SPR_HID0 ] &HID0_HILE ); + } + + }else if (pcc->lpcr_mask &LPCR_ILE ) { + ile = !!(env->spr[SPR_LPCR ] &LPCR_ILE ); } -return false; +return ile; } +#endif void dump_mmu (CPUPPCState *env);
target/ppc/excp_helper.c +1 -1
@@ -1070,7 +1070,7 @@ void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector)*/ msr = (1ULL <<MSR_ME ); msr |= env->msr & (1ULL <<MSR_SF ); -if (ppc_interrupts_little_endian (cpu)) { +if (ppc_interrupts_little_endian (cpu, false)) { msr |= (1ULL <<MSR_LE ); }
Signature · 1 line
2.33.1
PATCH v3 5/8 target/ppc: Add MSR_ILE support to ppc_interrupts_little_endian
In reply to Fabiano RosasSome CPUs set ILE via an MSR bit. We can make ppc_interrupts_little_endian handle that case as well. Now we have a centralized way of determining the endianness of interrupts.
This change has no functional impact.
--- target/ppc/cpu.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/ppc/cpu.h +3 -1
@@ -2733,7 +2733,7 @@ static inline bool ppc_interrupts_little_endian(PowerPCCPU *cpu, bool hv) {PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu);CPUPPCState *env = &cpu->env; -bool ile = false; +bool ile;if (hv && env->has_hv_mode) {if (is_isa300 (pcc)) {
@@ -2744,6 +2744,8 @@ static inline bool ppc_interrupts_little_endian(PowerPCCPU *cpu, bool hv) }else if (pcc->lpcr_mask &LPCR_ILE ) { ile = !!(env->spr[SPR_LPCR ] &LPCR_ILE ); + }else { + ile = !!(msr_ile); }return ile;
Signature · 1 line
2.33.1
PATCH v3 6/8 target/ppc: Use ppc_interrupts_little_endian in powerpc_excp
In reply to Fabiano RosasThe ppc_interrupts_little_endian function is now suitable for determining the endianness of interrupts for all CPUs.
--- target/ppc/excp_helper.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-)
target/ppc/excp_helper.c +1 -28
@@ -832,36 +832,9 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)* Sort out endianness of interrupt, this differs depending on the * CPU, the HV mode, etc... */ -#ifdef TARGET_PPC64 -if (excp_model ==POWERPC_EXCP_POWER7 ) { -if (!(new_msr &MSR_HVB ) && (env->spr[SPR_LPCR ] &LPCR_ILE )) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } - }else if (excp_model ==POWERPC_EXCP_POWER8 ) { -if (new_msr &MSR_HVB ) { -if (env->spr[SPR_HID0 ] &HID0_HILE ) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } - }else if (env->spr[SPR_LPCR ] &LPCR_ILE ) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } - }else if (excp_model ==POWERPC_EXCP_POWER9 || - excp_model ==POWERPC_EXCP_POWER10 ) { -if (new_msr &MSR_HVB ) { -if (env->spr[SPR_HID0 ] &HID0_POWER9_HILE ) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } - }else if (env->spr[SPR_LPCR ] &LPCR_ILE ) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } - }else if (msr_ile) { +if (ppc_interrupts_little_endian (cpu, !!(new_msr &MSR_HVB ))) { new_msr |= (target_ulong )1 <<MSR_LE ; } -#else -if (msr_ile) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } -#endif #if defined(TARGET_PPC64 )if (excp_model ==POWERPC_EXCP_BOOKE ) {
Signature · 1 line
2.33.1
PATCH v3 7/8 target/ppc: Introduce a wrapper for powerpc_excp
In reply to Fabiano RosasNext patches will split powerpc_excp in multiple family specific handlers. This patch adds a wrapper to make the transition clearer.
--- target/ppc/excp_helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
target/ppc/excp_helper.c +11 -1
@@ -396,7 +396,7 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu,* Note that this function should be greatly optimized when called * with a constant excp, from ppc_hw_interrupt */ -static void powerpc_excp (PowerPCCPU *cpu,int excp) +static inline void powerpc_excp_legacy (PowerPCCPU *cpu,int excp) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;
@@ -867,6 +867,16 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)powerpc_set_excp_state (cpu, vector, new_msr); } +static void powerpc_excp (PowerPCCPU *cpu,int excp) +{ +CPUPPCState *env = &cpu->env; + +switch (env->excp_model) { +default : +powerpc_excp_legacy (cpu, excp); + } +} +void ppc_cpu_do_interrupt (CPUState *cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);
Signature · 1 line
2.33.1
PATCH v3 8/8 target/ppc: Set the correct endianness for powernv memory dumps
In reply to Fabiano RosasWe use the endianness of interrupts to determine which endianness to use for the guest kernel memory dump. For machines that support HILE (powernv8 and up) we have been always generating big endian dump files.
This patch uses the HILE support recently added to ppc_interrupts_little_endian to fix the endianness of the dumps for powernv machines.
Here are two dumps created at different moments:
$ file skiboot.dump skiboot.dump: ELF 64-bit MSB core file, 64-bit PowerPC ...
$ file kernel.dump kernel.dump: ELF 64-bit LSB core file, 64-bit PowerPC ...
--- target/ppc/arch_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/arch_dump.c +1 -1
@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu, false)) { +if (ppc_interrupts_little_endian (cpu, cpu->env.has_hv_mode)) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
Signature · 1 line
2.33.1
Re: [PATCH v3 8/8] target/ppc: Set the correct endianness for powernv memory dumps
Quoted 11 lines · Fabiano Rosas
We use the endianness of interrupts to determine which endianness to use for the guest kernel memory dump. For machines that support HILE (powernv8 and up) we have been always generating big endian dump files.
This patch uses the HILE support recently added to
ppc_interrupts_little_endianto fix the endianness of the dumps for powernv machines.Here are two dumps created at different moments:
Quoted 8 lines
$ file skiboot.dump skiboot.dump: ELF 64-bit MSB core file, 64-bit PowerPC ...$ file kernel.dump kernel.dump: ELF 64-bit LSB core file, 64-bit PowerPC ...Suggested-by David Gibson <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
Quoted 17 lines
--- target/ppc/arch_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/arch_dump.c +1
-1@@ -237,7 +237,7 @@ int cpu_get_dump_info(ArchDumpInfo *info, info->d_machine =PPC_ELF_MACHINE ; info->d_class =ELFCLASS ; -if (ppc_interrupts_little_endian (cpu, false)) { +if (ppc_interrupts_little_endian (cpu, cpu->env.has_hv_mode)) { info->d_endian =ELFDATA2LSB ; }else { info->d_endian =ELFDATA2MSB ;
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
Hello Fabiano,
Quoted 5 lines · Fabiano Rosas
Version 3:
- patches 1,3,4,5,6,7: unchanged, reviewed;
- patch 2: started using
qemu_loglevel_mask(CPU_LOG_MMU)instead of
Quoted 8 lines
qemu_log_enabled; I decided to not rename the function at this point because it is used for both 60x and 7x5 and these two will be split in the near future, so allow me to postpone that;- patch 8: new patch using
env->has_hv_modeto fix the endianness of powernv dumps as suggested by David.
I have queued this version for ppc-7.0. You can send followups on top of it.
Thanks,
C.