target/ppc: powerpc_excp improvements [40x] (3/n)
PATCH v2 3/14 target/ppc: Introduce powerpc_excp_40x
In reply to Fabiano RosasIntroduce a new powerpc_excp function specific for 40x CPUs. This commit copies powerpc_excp_legacy verbatim so the next one has a clean diff.
--- target/ppc/excp_helper.c | 474 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+)
target/ppc/excp_helper.c +474 -0
@@ -392,6 +392,477 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu,check_tlb_flush (env, false); } +static void powerpc_excp_40x (PowerPCCPU *cpu,int excp) +{ +CPUState *cs =CPU (cpu); +CPUPPCState *env = &cpu->env; +int excp_model = env->excp_model; +target_ulong msr, new_msr, vector; +int srr0, srr1, lev =-1 ; + +if (excp <=POWERPC_EXCP_NONE || excp >=POWERPC_EXCP_NB ) { +cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp); + } + +qemu_log_mask (CPU_LOG_INT ,"Raise exception at " TARGET_FMT_lx +" => %s (%d) error=%02x\n" , env->nip,powerpc_excp_name (excp), + excp, env->error_code); + +/* new srr1 value excluding must-be-zero bits */ +if (excp_model ==POWERPC_EXCP_BOOKE ) { + msr = env->msr; + }else { + msr = env->msr & ~0x783f0000ULL ; + } + +/* +* new interrupt handler msr preserves existing HV and ME unless +* explicitly overriden +*/ + new_msr = env->msr & (((target_ulong )1 <<MSR_ME ) |MSR_HVB ); + +/* target registers */ + srr0 =SPR_SRR0 ; + srr1 =SPR_SRR1 ; + +/* +* check for special resume at 0x100 from doze/nap/sleep/winkle on +* P7/P8/P9 +*/ +if (env->resume_as_sreset) { + excp =powerpc_reset_wakeup (cs, env, excp, &msr); + } + +/* +* Hypervisor emulation assistance interrupt only exists on server +* arch 2.05 server or later. We also don't want to generate it if +* we don't have HVB in msr_mask (PAPR mode). +*/ + if (excp == POWERPC_EXCP_HV_EMU +#if defined(TARGET_PPC64 ) + && !(mmu_is_64bit(env->mmu_model) && (env->msr_mask & MSR_HVB)) +#endif /* defined(TARGET_PPC64) */ + + ) { + excp =POWERPC_EXCP_PROGRAM ; + } + +#ifdef TARGET_PPC64 +/* +* SPEU and VPU share the same IVOR but they exist in different +* processors. SPEU is e500v1/2 only and VPU is e6500 only. +*/ +if (excp_model ==POWERPC_EXCP_BOOKE && excp ==POWERPC_EXCP_VPU ) { + excp =POWERPC_EXCP_SPEU ; + } +#endif + + vector = env->excp_vectors[excp]; +if (vector == (target_ulong)-1ULL ) { +cpu_abort (cs,"Raised an exception without defined vector %d\n" , + excp); + } + + vector |= env->excp_prefix; + +switch (excp) { +case POWERPC_EXCP_CRITICAL :/* Critical input */ +switch (excp_model) { +case POWERPC_EXCP_40x: + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3; +break ; +case POWERPC_EXCP_BOOKE : + srr0 =SPR_BOOKE_CSRR0 ; + srr1 =SPR_BOOKE_CSRR1 ; +break ; +case POWERPC_EXCP_G2 : +break ; +default : + goto excp_invalid; + } +break ; +case POWERPC_EXCP_MCHECK :/* Machine check exception */ +if (msr_me ==0 ) { +/* +* Machine check exception is not enabled. Enter +* checkstop state. +*/ +fprintf (stderr,"Machine check while not allowed. " +"Entering checkstop state\n" ); +if (qemu_log_separate ()) { +qemu_log ("Machine check while not allowed. " +"Entering checkstop state\n" ); + } + cs->halted =1 ; +cpu_interrupt_exittb (cs); + } +if (env->msr_mask &MSR_HVB ) { +/* +* ISA specifies HV, but can be delivered to guest with HV +* clear (e.g., see FWNMI in PAPR). +*/ + new_msr |= (target_ulong )MSR_HVB ; + } + +/* machine check exceptions don't have ME set */ + new_msr &= ~((target_ulong )1 <<MSR_ME ); + +/* XXX: should also have something loaded in DAR / DSISR */ +switch (excp_model) { +case POWERPC_EXCP_40x: + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3; +break ; +case POWERPC_EXCP_BOOKE : +/* FIXME: choose one or the other based on CPU type */ + srr0 =SPR_BOOKE_MCSRR0 ; + srr1 =SPR_BOOKE_MCSRR1 ; + + env->spr[SPR_BOOKE_CSRR0 ] = env->nip; + env->spr[SPR_BOOKE_CSRR1 ] = msr; +break ; +default : +break ; + } +break ; +case POWERPC_EXCP_DSI :/* Data storage exception */ +trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]); +break ; +case POWERPC_EXCP_ISI :/* Instruction storage exception */ +trace_ppc_excp_isi (msr, env->nip); + msr |= env->error_code; +break ; +case POWERPC_EXCP_EXTERNAL :/* External input */ + { +bool lpes0; + + cs =CPU (cpu); + +/* +* Exception targeting modifiers +* +* LPES0 is supported on POWER7/8/9 +* LPES1 is not supported (old iSeries mode) +* +* On anything else, we behave as if LPES0 is 1 +* (externals don't alter MSR:HV) +*/ +#if defined(TARGET_PPC64 ) +if (excp_model ==POWERPC_EXCP_POWER7 || + excp_model ==POWERPC_EXCP_POWER8 || + excp_model ==POWERPC_EXCP_POWER9 || + excp_model ==POWERPC_EXCP_POWER10 ) { + lpes0 = !!(env->spr[SPR_LPCR ] &LPCR_LPES0 ); + } else +#endif /* defined(TARGET_PPC64) */ + { + lpes0 = true; + } + +if (!lpes0) { + new_msr |= (target_ulong )MSR_HVB ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); + srr0 =SPR_HSRR0 ; + srr1 =SPR_HSRR1 ; + } +if (env->mpic_proxy) { +/* IACK the IRQ on delivery */ + env->spr[SPR_BOOKE_EPR ] =ldl_phys (cs->as, env->mpic_iack); + } +break ; + } +case POWERPC_EXCP_ALIGN :/* Alignment exception */ +/* Get rS/rD and rA from faulting opcode */ +/* +* Note: the opcode fields will not be set properly for a +* direct store load/store, but nobody cares as nobody +* actually uses direct store segments. +*/ + env->spr[SPR_DSISR ] |= (env->error_code &0x03FF0000 ) >>16 ; +break ; +case POWERPC_EXCP_PROGRAM :/* Program exception */ +switch (env->error_code & ~0xF ) { +case POWERPC_EXCP_FP : +if ((msr_fe0 ==0 && msr_fe1 ==0 ) || msr_fp ==0 ) { +trace_ppc_excp_fp_ignore (); + cs->exception_index =POWERPC_EXCP_NONE ; + env->error_code =0 ; +return ; + } + +/* +* FP exceptions always have NIP pointing to the faulting +* instruction, so always use store_next and claim we are +* precise in the MSR. +*/ + msr |=0x00100000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_FP ; +break ; +case POWERPC_EXCP_INVAL : +trace_ppc_excp_inval (env->nip); + msr |=0x00080000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_PIL ; +break ; +case POWERPC_EXCP_PRIV : + msr |=0x00040000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_PPR ; +break ; +case POWERPC_EXCP_TRAP : + msr |=0x00020000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_PTR ; +break ; +default : +/* Should never occur */ +cpu_abort (cs,"Invalid program exception %d. Aborting\n" , + env->error_code); +break ; + } +break ; +case POWERPC_EXCP_SYSCALL :/* System call exception */ + lev = env->error_code; + +if ((lev ==1 ) && cpu->vhyp) { +dump_hcall (env); + }else { +dump_syscall (env); + } + +/* +* We need to correct the NIP which in this case is supposed +* to point to the next instruction +*/ + env->nip +=4 ; + +/* "PAPR mode" built-in hypercall emulation */ +if ((lev ==1 ) && cpu->vhyp) { +PPCVirtualHypervisorClass *vhc = +PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); + vhc->hypercall (cpu->vhyp, cpu); +return ; + } +if (lev ==1 ) { + new_msr |= (target_ulong )MSR_HVB ; + } +break ; +case POWERPC_EXCP_SYSCALL_VECTORED :/* scv exception */ + lev = env->error_code; +dump_syscall (env); + env->nip +=4 ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_EE ); + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); + + vector += lev *0x20 ; + + env->lr = env->nip; + env->ctr = msr; +break ; +case POWERPC_EXCP_FPU :/* Floating-point unavailable exception */ +case POWERPC_EXCP_APU :/* Auxiliary processor unavailable */ +case POWERPC_EXCP_DECR :/* Decrementer exception */ +break ; +case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ +/* FIT on 4xx */ +trace_ppc_excp_print ("FIT" ); +break ; +case POWERPC_EXCP_WDT :/* Watchdog timer interrupt */ +trace_ppc_excp_print ("WDT" ); +switch (excp_model) { +case POWERPC_EXCP_BOOKE : + srr0 =SPR_BOOKE_CSRR0 ; + srr1 =SPR_BOOKE_CSRR1 ; +break ; +default : +break ; + } +break ; +case POWERPC_EXCP_DTLB :/* Data TLB error */ +case POWERPC_EXCP_ITLB :/* Instruction TLB error */ +break ; +case POWERPC_EXCP_DEBUG :/* Debug interrupt */ +if (env->flags &POWERPC_FLAG_DE ) { +/* FIXME: choose one or the other based on CPU type */ + srr0 =SPR_BOOKE_DSRR0 ; + srr1 =SPR_BOOKE_DSRR1 ; + + env->spr[SPR_BOOKE_CSRR0 ] = env->nip; + env->spr[SPR_BOOKE_CSRR1 ] = msr; + +/* DBSR already modified by caller */ + }else { +cpu_abort (cs,"Debug exception triggered on unsupported model\n" ); + } +break ; +case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavailable/VPU */ + env->spr[SPR_BOOKE_ESR ] =ESR_SPV ; +break ; +case POWERPC_EXCP_DOORI :/* Embedded doorbell interrupt */ +break ; +case POWERPC_EXCP_DOORCI :/* Embedded doorbell critical interrupt */ + srr0 =SPR_BOOKE_CSRR0 ; + srr1 =SPR_BOOKE_CSRR1 ; +break ; +case POWERPC_EXCP_RESET :/* System reset exception */ +/* A power-saving exception sets ME, otherwise it is unchanged */ +if (msr_pow) { +/* indicate that we resumed from power save mode */ + msr |=0x10000 ; + new_msr |= ((target_ulong )1 <<MSR_ME ); + } +if (env->msr_mask &MSR_HVB ) { +/* +* ISA specifies HV, but can be delivered to guest with HV +* clear (e.g., see FWNMI in PAPR, NMI injection in QEMU). +*/ + new_msr |= (target_ulong )MSR_HVB ; + }else { +if (msr_pow) { +cpu_abort (cs,"Trying to deliver power-saving system reset " +"exception %d with no HV support\n" , excp); + } + } +break ; +case POWERPC_EXCP_DSEG :/* Data segment exception */ +case POWERPC_EXCP_ISEG :/* Instruction segment exception */ +case POWERPC_EXCP_TRACE :/* Trace exception */ +break ; +case POWERPC_EXCP_HISI :/* Hypervisor instruction storage exception */ + msr |= env->error_code; +/* fall through */ +case POWERPC_EXCP_HDECR :/* Hypervisor decrementer exception */ +case POWERPC_EXCP_HDSI :/* Hypervisor data storage exception */ +case POWERPC_EXCP_HDSEG :/* Hypervisor data segment exception */ +case POWERPC_EXCP_HISEG :/* Hypervisor instruction segment exception */ +case POWERPC_EXCP_SDOOR_HV :/* Hypervisor Doorbell interrupt */ +case POWERPC_EXCP_HV_EMU : +case POWERPC_EXCP_HVIRT :/* Hypervisor virtualization */ + srr0 =SPR_HSRR0 ; + srr1 =SPR_HSRR1 ; + new_msr |= (target_ulong )MSR_HVB ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); +break ; +case POWERPC_EXCP_VPU :/* Vector unavailable exception */ +case POWERPC_EXCP_VSXU :/* VSX unavailable exception */ +case POWERPC_EXCP_FU :/* Facility unavailable exception */ +#ifdef TARGET_PPC64 + env->spr[SPR_FSCR ] |= ((target_ulong )env->error_code <<56 ); +#endif +break ; +case POWERPC_EXCP_HV_FU :/* Hypervisor Facility Unavailable Exception */ +#ifdef TARGET_PPC64 + env->spr[SPR_HFSCR ] |= ((target_ulong )env->error_code <<FSCR_IC_POS ); + srr0 =SPR_HSRR0 ; + srr1 =SPR_HSRR1 ; + new_msr |= (target_ulong )MSR_HVB ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); +#endif +break ; +case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ +trace_ppc_excp_print ("PIT" ); +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 */ +switch (excp_model) { +case POWERPC_EXCP_602 : +case POWERPC_EXCP_603 : +case POWERPC_EXCP_G2 : +/* Swap temporary saved registers with GPRs */ +if (!(new_msr & ((target_ulong )1 <<MSR_TGPR ))) { + new_msr |= (target_ulong )1 <<MSR_TGPR ; +hreg_swap_gpr_tgpr (env); + } +/* fall through */ +case POWERPC_EXCP_7x5: +ppc_excp_debug_sw_tlb (env, excp); + + msr |= env->crf[0 ] <<28 ; + msr |= env->error_code;/* key, D/I, S/L bits */ +/* Set way using a LRU mechanism */ + msr |= ((env->last_way +1 ) & (env->nb_ways -1 )) <<17 ; +break ; +default : +cpu_abort (cs,"Invalid TLB miss exception\n" ); +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 */ +case POWERPC_EXCP_DABR :/* Data address breakpoint */ +case POWERPC_EXCP_IABR :/* Instruction address breakpoint */ +case POWERPC_EXCP_SMI :/* System management interrupt */ +case POWERPC_EXCP_THERM :/* Thermal interrupt */ +case POWERPC_EXCP_PERFM :/* Embedded performance monitor interrupt */ +case POWERPC_EXCP_VPUA :/* Vector assist exception */ +case POWERPC_EXCP_SOFTP :/* Soft patch exception */ +case POWERPC_EXCP_MAINT :/* Maintenance exception */ +case POWERPC_EXCP_MEXTBR :/* Maskable external breakpoint */ +case POWERPC_EXCP_NMEXTBR :/* Non maskable external breakpoint */ +cpu_abort (cs,"%s exception not implemented\n" , +powerpc_excp_name (excp)); +break ; +default : + excp_invalid: +cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp); +break ; + } + +/* Sanity check */ +if (!(env->msr_mask &MSR_HVB )) { +if (new_msr &MSR_HVB ) { +cpu_abort (cs,"Trying to deliver HV exception (MSR) %d with " +"no HV support\n" , excp); + } +if (srr0 ==SPR_HSRR0 ) { +cpu_abort (cs,"Trying to deliver HV exception (HSRR) %d with " +"no HV support\n" , excp); + } + } + +/* +* Sort out endianness of interrupt, this differs depending on the +* CPU, the HV mode, etc... +*/ +if (ppc_interrupts_little_endian (cpu, !!(new_msr &MSR_HVB ))) { + new_msr |= (target_ulong )1 <<MSR_LE ; + } + +#if defined(TARGET_PPC64 ) +if (excp_model ==POWERPC_EXCP_BOOKE ) { +if (env->spr[SPR_BOOKE_EPCR ] &EPCR_ICM ) { +/* Cat.64-bit: EPCR.ICM is copied to MSR.CM */ + new_msr |= (target_ulong )1 <<MSR_CM ; + }else { + vector = (uint32_t )vector; + } + }else { +if (!msr_isf && !mmu_is_64bit (env->mmu_model)) { + vector = (uint32_t )vector; + }else { + new_msr |= (target_ulong )1 <<MSR_SF ; + } + } +#endif + +if (excp !=POWERPC_EXCP_SYSCALL_VECTORED ) { +/* Save PC */ + env->spr[srr0] = env->nip; + +/* Save MSR */ + env->spr[srr1] = msr; + } + +/* This can update new_msr and vector if AIL applies */ +ppc_excp_apply_ail (cpu, excp_model, excp, msr, &new_msr, &vector); + + powerpc_set_excp_state(cpu, vector, new_msr); +} +/* * Note that this function should be greatly optimized when called * with a constant excp, from ppc_hw_interrupt
@@ -872,6 +1343,9 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)CPUPPCState *env = &cpu->env;switch (env->excp_model) { +case POWERPC_EXCP_40x: +powerpc_excp_40x (cpu, excp); +break ;default :powerpc_excp_legacy (cpu, excp); }
Signature · 1 line
2.33.1
PATCH v2 4/14 target/ppc: Simplify powerpc_excp_40x
In reply to Fabiano RosasDifferences from the generic powerpc_excp code:
- Not BookE, so some MSR bits are cleared at interrupt dispatch;
- No MSR_HV or MSR_LE;
- No power saving states;
- No Hypervisor Emulation Assistance;
- Not 64 bits;
- No System call vectored;
- No Interrupts Little Endian;
- No Alternate Interrupt Location.
Exceptions used:
POWERPC_EXCP_ALIGNPOWERPC_EXCP_CRITICALPOWERPC_EXCP_DEBUGPOWERPC_EXCP_DSIPOWERPC_EXCP_DTLBPOWERPC_EXCP_EXTERNALPOWERPC_EXCP_FITPOWERPC_EXCP_ISIPOWERPC_EXCP_ITLBPOWERPC_EXCP_MCHECKPOWERPC_EXCP_PITPOWERPC_EXCP_PROGRAMPOWERPC_EXCP_SYSCALLPOWERPC_EXCP_WDT
--- target/ppc/excp_helper.c | 205 ++------------------------------------- 1 file changed, 10 insertions(+), 195 deletions(-)
target/ppc/excp_helper.c +10 -195
@@ -409,54 +409,26 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) excp, env->error_code);/* new srr1 value excluding must-be-zero bits */ -if (excp_model ==POWERPC_EXCP_BOOKE ) { - msr = env->msr; - }else { - msr = env->msr & ~0x783f0000ULL ; - } + msr = env->msr & ~0x783f0000ULL ;/* -* new interrupt handler msr preserves existing HV and ME unless -* explicitly overriden +* new interrupt handler msr preserves existing ME unless +* explicitly overriden. */ - new_msr = env->msr & (((target_ulong )1 <<MSR_ME ) |MSR_HVB ); + new_msr = env->msr & (((target_ulong )1 <<MSR_ME ));/* target registers */ srr0 =SPR_SRR0 ; srr1 =SPR_SRR1 ; -/* -* check for special resume at 0x100 from doze/nap/sleep/winkle on -* P7/P8/P9 -*/ -if (env->resume_as_sreset) { - excp =powerpc_reset_wakeup (cs, env, excp, &msr); - } -/* * Hypervisor emulation assistance interrupt only exists on server -* arch 2.05 server or later. We also don't want to generate it if -* we don't have HVB in msr_mask (PAPR mode). +* arch 2.05 server or later. */ - if (excp == POWERPC_EXCP_HV_EMU -#if defined(TARGET_PPC64 ) - && !(mmu_is_64bit(env->mmu_model) && (env->msr_mask & MSR_HVB)) -#endif /* defined(TARGET_PPC64) */ - - ) { +if (excp ==POWERPC_EXCP_HV_EMU ) { excp =POWERPC_EXCP_PROGRAM ; } -#ifdef TARGET_PPC64 -/* -* SPEU and VPU share the same IVOR but they exist in different -* processors. SPEU is e500v1/2 only and VPU is e6500 only. -*/ -if (excp_model ==POWERPC_EXCP_BOOKE && excp ==POWERPC_EXCP_VPU ) { - excp =POWERPC_EXCP_SPEU ; - } -#endif - vector = env->excp_vectors[excp];if (vector == (target_ulong)-1ULL ) { cpu_abort(cs, "Raised an exception without defined vector %d\n",
@@ -645,24 +617,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) new_msr |= (target_ulong )MSR_HVB ; }break ; -case POWERPC_EXCP_SYSCALL_VECTORED :/* scv exception */ - lev = env->error_code; -dump_syscall (env); - env->nip +=4 ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_EE ); - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); - - vector += lev *0x20 ; - - env->lr = env->nip; - env->ctr = msr; -break ; -case POWERPC_EXCP_FPU :/* Floating-point unavailable exception */ -case POWERPC_EXCP_APU :/* Auxiliary processor unavailable */ -case POWERPC_EXCP_DECR :/* Decrementer exception */ -break ;case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ -/* FIT on 4xx */ trace_ppc_excp_print ("FIT" );break ;case POWERPC_EXCP_WDT :/* Watchdog timer interrupt */
@@ -693,119 +648,9 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)cpu_abort (cs,"Debug exception triggered on unsupported model\n" ); }break ; -case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavailable/VPU */ - env->spr[SPR_BOOKE_ESR ] =ESR_SPV ; -break ; -case POWERPC_EXCP_DOORI :/* Embedded doorbell interrupt */ -break ; -case POWERPC_EXCP_DOORCI :/* Embedded doorbell critical interrupt */ - srr0 =SPR_BOOKE_CSRR0 ; - srr1 =SPR_BOOKE_CSRR1 ; -break ; -case POWERPC_EXCP_RESET :/* System reset exception */ -/* A power-saving exception sets ME, otherwise it is unchanged */ -if (msr_pow) { -/* indicate that we resumed from power save mode */ - msr |=0x10000 ; - new_msr |= ((target_ulong )1 <<MSR_ME ); - } -if (env->msr_mask &MSR_HVB ) { -/* -* ISA specifies HV, but can be delivered to guest with HV -* clear (e.g., see FWNMI in PAPR, NMI injection in QEMU). -*/ - new_msr |= (target_ulong )MSR_HVB ; - }else { -if (msr_pow) { -cpu_abort (cs,"Trying to deliver power-saving system reset " -"exception %d with no HV support\n" , excp); - } - } -break ; -case POWERPC_EXCP_DSEG :/* Data segment exception */ -case POWERPC_EXCP_ISEG :/* Instruction segment exception */ -case POWERPC_EXCP_TRACE :/* Trace exception */ -break ; -case POWERPC_EXCP_HISI :/* Hypervisor instruction storage exception */ - msr |= env->error_code; -/* fall through */ -case POWERPC_EXCP_HDECR :/* Hypervisor decrementer exception */ -case POWERPC_EXCP_HDSI :/* Hypervisor data storage exception */ -case POWERPC_EXCP_HDSEG :/* Hypervisor data segment exception */ -case POWERPC_EXCP_HISEG :/* Hypervisor instruction segment exception */ -case POWERPC_EXCP_SDOOR_HV :/* Hypervisor Doorbell interrupt */ -case POWERPC_EXCP_HV_EMU : -case POWERPC_EXCP_HVIRT :/* Hypervisor virtualization */ - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - new_msr |= (target_ulong )MSR_HVB ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); -break ; -case POWERPC_EXCP_VPU :/* Vector unavailable exception */ -case POWERPC_EXCP_VSXU :/* VSX unavailable exception */ -case POWERPC_EXCP_FU :/* Facility unavailable exception */ -#ifdef TARGET_PPC64 - env->spr[SPR_FSCR ] |= ((target_ulong )env->error_code <<56 ); -#endif -break ; -case POWERPC_EXCP_HV_FU :/* Hypervisor Facility Unavailable Exception */ -#ifdef TARGET_PPC64 - env->spr[SPR_HFSCR ] |= ((target_ulong )env->error_code <<FSCR_IC_POS ); - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - new_msr |= (target_ulong )MSR_HVB ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); -#endif -break ;case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ trace_ppc_excp_print ("PIT" );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 */ -switch (excp_model) { -case POWERPC_EXCP_602 : -case POWERPC_EXCP_603 : -case POWERPC_EXCP_G2 : -/* Swap temporary saved registers with GPRs */ -if (!(new_msr & ((target_ulong )1 <<MSR_TGPR ))) { - new_msr |= (target_ulong )1 <<MSR_TGPR ; -hreg_swap_gpr_tgpr (env); - } -/* fall through */ -case POWERPC_EXCP_7x5: -ppc_excp_debug_sw_tlb (env, excp); - - msr |= env->crf[0 ] <<28 ; - msr |= env->error_code;/* key, D/I, S/L bits */ -/* Set way using a LRU mechanism */ - msr |= ((env->last_way +1 ) & (env->nb_ways -1 )) <<17 ; -break ; -default : -cpu_abort (cs,"Invalid TLB miss exception\n" ); -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 */ -case POWERPC_EXCP_DABR :/* Data address breakpoint */ -case POWERPC_EXCP_IABR :/* Instruction address breakpoint */ -case POWERPC_EXCP_SMI :/* System management interrupt */ -case POWERPC_EXCP_THERM :/* Thermal interrupt */ -case POWERPC_EXCP_PERFM :/* Embedded performance monitor interrupt */ -case POWERPC_EXCP_VPUA :/* Vector assist exception */ -case POWERPC_EXCP_SOFTP :/* Soft patch exception */ -case POWERPC_EXCP_MAINT :/* Maintenance exception */ -case POWERPC_EXCP_MEXTBR :/* Maskable external breakpoint */ -case POWERPC_EXCP_NMEXTBR :/* Non maskable external breakpoint */ -cpu_abort (cs,"%s exception not implemented\n" , -powerpc_excp_name (excp)); -break ;default : excp_invalid:cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);
@@ -824,41 +669,11 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) } } -/* -* Sort out endianness of interrupt, this differs depending on the -* CPU, the HV mode, etc... -*/ -if (ppc_interrupts_little_endian (cpu, !!(new_msr &MSR_HVB ))) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } +/* Save PC */ + env->spr[srr0] = env->nip; -#if defined(TARGET_PPC64 ) -if (excp_model ==POWERPC_EXCP_BOOKE ) { -if (env->spr[SPR_BOOKE_EPCR ] &EPCR_ICM ) { -/* Cat.64-bit: EPCR.ICM is copied to MSR.CM */ - new_msr |= (target_ulong )1 <<MSR_CM ; - }else { - vector = (uint32_t )vector; - } - }else { -if (!msr_isf && !mmu_is_64bit (env->mmu_model)) { - vector = (uint32_t )vector; - }else { - new_msr |= (target_ulong )1 <<MSR_SF ; - } - } -#endif - -if (excp !=POWERPC_EXCP_SYSCALL_VECTORED ) { -/* Save PC */ - env->spr[srr0] = env->nip; - -/* Save MSR */ - env->spr[srr1] = msr; - } - -/* This can update new_msr and vector if AIL applies */ -ppc_excp_apply_ail (cpu, excp_model, excp, msr, &new_msr, &vector); +/* Save MSR */ + env->spr[srr1] = msr;powerpc_set_excp_state (cpu, vector, new_msr); }
Signature · 1 line
2.33.1
PATCH v2 2/14 target/ppc: 405: Add missing MSR_ME bit
In reply to Fabiano RosasThe 405 MSR has the Machine Check Enable bit. We're making use of it when dispatching Machine Check, so add the bit to the msr_mask.
--- target/ppc/cpu_init.c | 1 + 1 file changed, 1 insertion(+)
target/ppc/cpu_init.c +1 -0
@@ -2540,6 +2540,7 @@ POWERPC_FAMILY(405)(ObjectClass *oc, void *data) (1ull <<MSR_EE ) | (1ull <<MSR_PR ) | (1ull <<MSR_FP ) | + (1ull <<MSR_ME ) | (1ull <<MSR_DWE ) | (1ull <<MSR_DE ) | (1ull << MSR_IR) |
Signature · 1 line
2.33.1
PATCH v2 10/14 target/ppc: 405: Debug exception cleanup
In reply to Fabiano RosasThe current Debug exception dispatch is the BookE one, so it is different from the 405. We effectively don't support the 405 Debug exception.
This patch removes the BookE code and moves the DEBUG into the "not implemented" block.
Note that there is in theory a functional change here since we now abort when a Debug exception happens. However, given how it was never implemented, I don't believe this to have ever been dispatched for the 405.
--- target/ppc/excp_helper.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
target/ppc/excp_helper.c +4 -14
@@ -539,23 +539,13 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)case POWERPC_EXCP_DTLB :/* Data TLB error */ case POWERPC_EXCP_ITLB :/* Instruction TLB error */ break ; -case POWERPC_EXCP_DEBUG :/* Debug interrupt */ -if (env->flags &POWERPC_FLAG_DE ) { -/* FIXME: choose one or the other based on CPU type */ - srr0 =SPR_BOOKE_DSRR0 ; - srr1 =SPR_BOOKE_DSRR1 ; - - env->spr[SPR_BOOKE_CSRR0 ] = env->nip; - env->spr[SPR_BOOKE_CSRR1 ] = msr; - -/* DBSR already modified by caller */ - }else { -cpu_abort (cs,"Debug exception triggered on unsupported model\n" ); - } -break ;case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ trace_ppc_excp_print ("PIT" );break ; +case POWERPC_EXCP_DEBUG :/* Debug interrupt */ +cpu_abort (cs,"%s exception not implemented\n" , +powerpc_excp_name (excp)); +break ;default :cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);break ;
Signature · 1 line
2.33.1
PATCH v2 1/14 target/ppc: 405: Rename MSR_POW to MSR_WE
In reply to Fabiano RosasBit 13 is the Wait State Enable bit. Give it its proper name.
As far as I can see we don't do anything with MSR_POW for the 405, so this change has no effect.
--- target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
target/ppc/cpu.h +1 -0
@@ -327,6 +327,7 @@ typedef enum {#define MSR_S 22/* Secure state */ #define MSR_KEY 19/* key bit on 603e */ #define MSR_POW 18/* Power management */ +#define MSR_WE 18/* Wait State Enable on 405 */ #define MSR_TGPR 17/* TGPR usage on 602/603 x */ #define MSR_CE 17/* Critical interrupt enable on embedded PowerPC x */ #define MSR_ILE 16/* Interrupt little-endian mode */
target/ppc/cpu_init.c +1 -1
@@ -2535,7 +2535,7 @@ POWERPC_FAMILY(405)(ObjectClass *oc, void *data)PPC_MEM_SYNC |PPC_MEM_EIEIO | PPC_40x_TLB |PPC_MEM_TLBIA |PPC_MEM_TLBSYNC | PPC_4xx_COMMON |PPC_405_MAC | PPC_40x_EXCP; - pcc->msr_mask = (1ull <<MSR_POW ) | + pcc->msr_mask = (1ull <<MSR_WE ) | (1ull <<MSR_CE ) | (1ull <<MSR_EE ) | (1ull << MSR_PR) |
Signature · 1 line
2.33.1
PATCH v2 9/14 target/ppc: 405: Alignment exception cleanup
In reply to Fabiano RosasThere is no DSISR in the 405. It uses DEAR which we already set earlier at ppc_cpu_do_unaligned_access.
--- target/ppc/excp_helper.c | 7 ------- 1 file changed, 7 deletions(-)
target/ppc/excp_helper.c +0 -7
@@ -474,13 +474,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)case POWERPC_EXCP_EXTERNAL :/* External input */ break ;case POWERPC_EXCP_ALIGN :/* Alignment exception */ -/* Get rS/rD and rA from faulting opcode */ -/* -* Note: the opcode fields will not be set properly for a -* direct store load/store, but nobody cares as nobody -* actually uses direct store segments. -*/ - env->spr[SPR_DSISR ] |= (env->error_code &0x03FF0000 ) >>16 ;break ;case POWERPC_EXCP_PROGRAM :/* Program exception */ switch (env->error_code & ~0xF ) {
Signature · 1 line
2.33.1
PATCH v2 6/14 target/ppc: 405: Machine check exception cleanup
In reply to Fabiano Rosaspowerpc_excp_40x applies only to the 405, so remove HV code and references to BookE.
--- target/ppc/excp_helper.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)
target/ppc/excp_helper.c +2 -24
@@ -457,34 +457,12 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) cs->halted =1 ;cpu_interrupt_exittb (cs); } -if (env->msr_mask &MSR_HVB ) { -/* -* ISA specifies HV, but can be delivered to guest with HV -* clear (e.g., see FWNMI in PAPR). -*/ - new_msr |= (target_ulong )MSR_HVB ; - }/* machine check exceptions don't have ME set */ new_msr &= ~((target_ulong )1 <<MSR_ME ); -/* XXX: should also have something loaded in DAR / DSISR */ -switch (excp_model) { -case POWERPC_EXCP_40x: - srr0 = SPR_40x_SRR2; - srr1 = SPR_40x_SRR3; -break ; -case POWERPC_EXCP_BOOKE : -/* FIXME: choose one or the other based on CPU type */ - srr0 =SPR_BOOKE_MCSRR0 ; - srr1 =SPR_BOOKE_MCSRR1 ; - - env->spr[SPR_BOOKE_CSRR0 ] = env->nip; - env->spr[SPR_BOOKE_CSRR1 ] = msr; -break ; -default : -break ; - } + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]);
Signature · 1 line
2.33.1
PATCH v2 5/14 target/ppc: 405: Critical exceptions cleanup
In reply to Fabiano RosasIn powerpc_excp_40x the Critical exception is now for 405 only, so we can remove the BookE and G2 blocks.
--- target/ppc/excp_helper.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
target/ppc/excp_helper.c +2 -15
@@ -439,20 +439,8 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)switch (excp) {case POWERPC_EXCP_CRITICAL :/* Critical input */ -switch (excp_model) { -case POWERPC_EXCP_40x: - srr0 = SPR_40x_SRR2; - srr1 = SPR_40x_SRR3; -break ; -case POWERPC_EXCP_BOOKE : - srr0 =SPR_BOOKE_CSRR0 ; - srr1 =SPR_BOOKE_CSRR1 ; -break ; -case POWERPC_EXCP_G2 : -break ; -default : - goto excp_invalid; - } + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_MCHECK :/* Machine check exception */ if (msr_me ==0 ) {
@@ -652,7 +640,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)trace_ppc_excp_print ("PIT" );break ;default : - excp_invalid:cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);break ; }
Signature · 1 line
2.33.1
v2 cover target/ppc: powerpc_excp improvements [40x] (3/n)
changes from v1:
- New patch that renames MSR_POW to MSR_WE for the 405.
- New patch that adds just MSR_ME to the msr_mask.
- New patches to cleanup exceptions I missed the first time around.
- Dropped the patch that added all the missing MSR bits. We have an issue when two different MSR bits share the same number in different CPUs. Described in v1 here:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-01/msg00503.html
- Dropped the patch that adds missing exception vectors because Linux clearly cannot handle them. And I don't have access to real hardware to confirm some of the questions raised, so let's keep things as they are.
- Kept the split in two patches. One that copies powerpc_excp_legacy and other that does the changes.
Based on legoater/ppc-7.0
With only the fixes from the above branch, the ref405ep machine boots until the shell. This series doesn't change that.
v1:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-01/msg00300.html
Fabiano Rosas (14):
target/ppc: 405: Rename MSR_POW to MSR_WE target/ppc: 405: Add missing MSR_ME bit target/ppc: Introduce powerpc_excp_40x target/ppc: Simplify powerpc_excp_40x target/ppc: 405: Critical exceptions cleanup target/ppc: 405: Machine check exception cleanup target/ppc: 405: External exception cleanup target/ppc: 405: System call exception cleanup target/ppc: 405: Alignment exception cleanup target/ppc: 405: Debug exception cleanup target/ppc: 405: Data Storage exception cleanup target/ppc: 405: Instruction storage interrupt cleanup target/ppc: 405: Program exception cleanup target/ppc: 405: Watchdog timer exception cleanup
target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 3 +- target/ppc/excp_helper.c | 159 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 161 insertions(+), 2 deletions(-)
Signature · 1 line
2.33.1
PATCH v2 7/14 target/ppc: 405: External exception cleanup
405 has no MSR_HV and EPR is BookE only so we can remove it all.
--- target/ppc/excp_helper.c | 37 ------------------------------------- 1 file changed, 37 deletions(-)
target/ppc/excp_helper.c +0 -37
@@ -472,44 +472,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) msr |= env->error_code;break ;case POWERPC_EXCP_EXTERNAL :/* External input */ - { -bool lpes0; - - cs =CPU (cpu); - -/* -* Exception targeting modifiers -* -* LPES0 is supported on POWER7/8/9 -* LPES1 is not supported (old iSeries mode) -* -* On anything else, we behave as if LPES0 is 1 -* (externals don't alter MSR:HV) -*/ -#if defined(TARGET_PPC64 ) -if (excp_model ==POWERPC_EXCP_POWER7 || - excp_model ==POWERPC_EXCP_POWER8 || - excp_model ==POWERPC_EXCP_POWER9 || - excp_model ==POWERPC_EXCP_POWER10 ) { - lpes0 = !!(env->spr[SPR_LPCR ] &LPCR_LPES0 ); - } else -#endif /* defined(TARGET_PPC64) */ - { - lpes0 = true; - } - -if (!lpes0) { - new_msr |= (target_ulong )MSR_HVB ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - } -if (env->mpic_proxy) { -/* IACK the IRQ on delivery */ - env->spr[SPR_BOOKE_EPR ] =ldl_phys (cs->as, env->mpic_iack); - }break ; - }case POWERPC_EXCP_ALIGN :/* Alignment exception */ /* Get rS/rD and rA from faulting opcode */ /*
Signature · 1 line
2.33.1
PATCH v2 8/14 target/ppc: 405: System call exception cleanup
In reply to Fabiano RosasThere's no sc 1.
--- target/ppc/excp_helper.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
target/ppc/excp_helper.c +2 -19
@@ -398,7 +398,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)CPUPPCState *env = &cpu->env;int excp_model = env->excp_model;target_ulong msr, new_msr, vector; -int srr0, srr1, lev =-1 ; +int srr0, srr1;if (excp <=POWERPC_EXCP_NONE || excp >=POWERPC_EXCP_NB ) {cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);
@@ -521,30 +521,13 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) }break ;case POWERPC_EXCP_SYSCALL :/* System call exception */ - lev = env->error_code; - -if ((lev ==1 ) && cpu->vhyp) { -dump_hcall (env); - }else { -dump_syscall (env); - } +dump_syscall (env);/* * We need to correct the NIP which in this case is supposed * to point to the next instruction */ env->nip +=4 ; - -/* "PAPR mode" built-in hypercall emulation */ -if ((lev ==1 ) && cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hypercall (cpu->vhyp, cpu); -return ; - } -if (lev ==1 ) { - new_msr |= (target_ulong )MSR_HVB ; - }break ;case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ trace_ppc_excp_print ("FIT" );
Signature · 1 line
2.33.1
PATCH v2 11/14 target/ppc: 405: Data Storage exception cleanup
In reply to Fabiano RosasThe 405 has no DSISR or DAR, so convert the trace entry to trace_ppc_excp_print.
--- target/ppc/excp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/excp_helper.c +1 -1
@@ -465,7 +465,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ -trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]); +trace_ppc_excp_print ("DSI" );break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip);
Signature · 1 line
2.33.1
PATCH v2 12/14 target/ppc: 405: Instruction storage interrupt cleanup
In reply to Fabiano RosasThe 405 ISI does not set SRR1 with any exception syndrome bits, only a clean copy of the MSR.
--- target/ppc/excp_helper.c | 1 - 1 file changed, 1 deletion(-)
target/ppc/excp_helper.c +0 -1
@@ -715,7 +715,6 @@ static inline void powerpc_excp_legacy(PowerPCCPU *cpu, int excp)break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip); - msr |= env->error_code;break ;case POWERPC_EXCP_EXTERNAL :/* External input */ {
Signature · 1 line
2.33.1
PATCH v2 14/14 target/ppc: 405: Watchdog timer exception cleanup
In reply to Fabiano RosasRemove references to BookE.
--- target/ppc/excp_helper.c | 9 --------- 1 file changed, 9 deletions(-)
target/ppc/excp_helper.c +0 -9
@@ -396,7 +396,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env; -int excp_model = env->excp_model;target_ulong msr, new_msr, vector;int srr0, srr1;
@@ -511,14 +510,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)break ;case POWERPC_EXCP_WDT :/* Watchdog timer interrupt */ trace_ppc_excp_print ("WDT" ); -switch (excp_model) { -case POWERPC_EXCP_BOOKE : - srr0 =SPR_BOOKE_CSRR0 ; - srr1 =SPR_BOOKE_CSRR1 ; -break ; -default : -break ; - }break ;case POWERPC_EXCP_DTLB :/* Data TLB error */ case POWERPC_EXCP_ITLB :/* Instruction TLB error */
Signature · 1 line
2.33.1
PATCH v2 13/14 target/ppc: 405: Program exception cleanup
In reply to Fabiano RosasThe 405 Program Interrupt does not set SRR1 with any diagnostic bits, just a clean copy of the MSR.
We're using the BookE Exception Syndrome Register which is different from the 405.
--- target/ppc/excp_helper.c | 16 ---------------- 1 file changed, 16 deletions(-)
target/ppc/excp_helper.c +0 -16
@@ -484,30 +484,14 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) env->error_code =0 ;return ; } - -/* -* FP exceptions always have NIP pointing to the faulting -* instruction, so always use store_next and claim we are -* precise in the MSR. -*/ - msr |=0x00100000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_FP ;break ;case POWERPC_EXCP_INVAL :trace_ppc_excp_inval (env->nip); - msr |=0x00080000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PIL ;break ;case POWERPC_EXCP_PRIV : - msr |=0x00040000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PPR ; -break ;case POWERPC_EXCP_TRAP : - msr |=0x00020000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PTR ;break ;default : -/* Should never occur */ cpu_abort (cs,"Invalid program exception %d. Aborting\n" , env->error_code);break ;
Signature · 1 line
2.33.1
Re: [PATCH v2 09/14] target/ppc: 405: Alignment exception cleanup
In reply to Fabiano RosasQuoted 2 lines · Fabiano Rosas
There is no DSISR in the 405. It uses DEAR which we already set earlier at
ppc_cpu_do_unaligned_access.
Enabled specifically, I note, by env->mmu_model rather than env->excp_model, which doesn't make a lot of sense. Another cleanup for later.
Quoted 1 line
Signed-off-by Fabiano Rosas <[email protected]>
Quoted 22 lines
--- target/ppc/excp_helper.c | 7 ------- 1 file changed, 7 deletions(-)target/ppc/excp_helper.c +0
-7@@ -474,13 +474,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)case POWERPC_EXCP_EXTERNAL :/* External input */ break ;case POWERPC_EXCP_ALIGN :/* Alignment exception */ -/* Get rS/rD and rA from faulting opcode */ -/* -* Note: the opcode fields will not be set properly for a -* direct store load/store, but nobody cares as nobody -* actually uses direct store segments. -*/ - env->spr[SPR_DSISR ] |= (env->error_code &0x03FF0000 ) >>16 ;break ;case POWERPC_EXCP_PROGRAM :/* Program exception */ switch (env->error_code & ~0xF ) {
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
Re: [PATCH v2 06/14] target/ppc: 405: Machine check exception cleanup
In reply to Fabiano RosasQuoted 19 lines · Fabiano Rosas
powerpc_excp_40xapplies only to the 405, so remove HV code and references to BookE.Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by David Gibson <[email protected]>--- target/ppc/excp_helper.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)target/ppc/excp_helper.c +0
-2@@ -457,34 +457,12 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) cs->halted =1 ;cpu_interrupt_exittb (cs); } -if (env->msr_mask &MSR_HVB ) { -/*
target/ppc/excp_helper.c static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) · line 471
Quoted 10 lines
target/ppc/excp_helper.c +0
-6-* ISA specifies HV, but can be delivered to guest with HV -* clear (e.g., see FWNMI in PAPR). -*/ - new_msr |= (target_ulong )MSR_HVB ; - }/* machine check exceptions don't have ME set */ new_msr &= ~((target_ulong )1 <<MSR_ME ); -/* XXX: should also have something loaded in DAR / DSISR */
DAR and DSISR don't apply for 40x, but I wonder if we should be loading something into DEAR or ESR for machine checks.
Quoted 21 lines
target/ppc/excp_helper.c +2
-16-switch (excp_model) { -case POWERPC_EXCP_40x: - srr0 = SPR_40x_SRR2; - srr1 = SPR_40x_SRR3; -break ; -case POWERPC_EXCP_BOOKE : -/* FIXME: choose one or the other based on CPU type */ - srr0 =SPR_BOOKE_MCSRR0 ; - srr1 =SPR_BOOKE_MCSRR1 ; - - env->spr[SPR_BOOKE_CSRR0 ] = env->nip; - env->spr[SPR_BOOKE_CSRR1 ] = msr; -break ; -default : -break ; - } + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]);
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
Re: [PATCH v2 10/14] target/ppc: 405: Debug exception cleanup
In reply to Fabiano RosasQuoted 7 lines · Fabiano Rosas
The current Debug exception dispatch is the BookE one, so it is different from the 405. We effectively don't support the 405 Debug exception.
This patch removes the BookE code and moves the DEBUG into the "not implemented" block.
Quoted 6 lines
Note that there is in theory a functional change here since we now abort when a Debug exception happens. However, given how it was never implemented, I don't believe this to have ever been dispatched for the 405.
Signed-off-by Fabiano Rosas <[email protected]>
Quoted 36 lines
--- target/ppc/excp_helper.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)target/ppc/excp_helper.c +4
-14@@ -539,23 +539,13 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)case POWERPC_EXCP_DTLB :/* Data TLB error */ case POWERPC_EXCP_ITLB :/* Instruction TLB error */ break ; -case POWERPC_EXCP_DEBUG :/* Debug interrupt */ -if (env->flags &POWERPC_FLAG_DE ) { -/* FIXME: choose one or the other based on CPU type */ - srr0 =SPR_BOOKE_DSRR0 ; - srr1 =SPR_BOOKE_DSRR1 ; - - env->spr[SPR_BOOKE_CSRR0 ] = env->nip; - env->spr[SPR_BOOKE_CSRR1 ] = msr; - -/* DBSR already modified by caller */ - }else { -cpu_abort (cs,"Debug exception triggered on unsupported model\n" ); - } -break ;case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ trace_ppc_excp_print ("PIT" );break ; +case POWERPC_EXCP_DEBUG :/* Debug interrupt */ +cpu_abort (cs,"%s exception not implemented\n" , +powerpc_excp_name (excp)); +break ;default :cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);break ;
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
Re: [PATCH v2 04/14] target/ppc: Simplify powerpc_excp_40x
In reply to Fabiano RosasQuoted 28 lines · Fabiano Rosas
Differences from the generic
powerpc_excpcode:- Not BookE, so some MSR bits are cleared at interrupt dispatch;
- NoMSR_HVorMSR_LE;
- No power saving states;
- No Hypervisor Emulation Assistance;
- Not 64 bits;
- No System call vectored;
- No Interrupts Little Endian;
- No Alternate Interrupt Location.Exceptions used:
POWERPC_EXCP_ALIGNPOWERPC_EXCP_CRITICALPOWERPC_EXCP_DEBUGPOWERPC_EXCP_DSIPOWERPC_EXCP_DTLBPOWERPC_EXCP_EXTERNALPOWERPC_EXCP_FITPOWERPC_EXCP_ISIPOWERPC_EXCP_ITLBPOWERPC_EXCP_MCHECKPOWERPC_EXCP_PITPOWERPC_EXCP_PROGRAMPOWERPC_EXCP_SYSCALLPOWERPC_EXCP_WDT
Quoted 1 line
Signed-off-by Fabiano Rosas <[email protected]>
Quoted 260 lines
--- target/ppc/excp_helper.c | 205 ++------------------------------------- 1 file changed, 10 insertions(+), 195 deletions(-)target/ppc/excp_helper.c +10
-195@@ -409,54 +409,26 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) excp, env->error_code);/* new srr1 value excluding must-be-zero bits */ -if (excp_model ==POWERPC_EXCP_BOOKE ) { - msr = env->msr; - }else { - msr = env->msr & ~0x783f0000ULL ; - } + msr = env->msr & ~0x783f0000ULL ;/* -* new interrupt handler msr preserves existing HV and ME unless -* explicitly overriden +* new interrupt handler msr preserves existing ME unless +* explicitly overriden. */ - new_msr = env->msr & (((target_ulong )1 <<MSR_ME ) |MSR_HVB ); + new_msr = env->msr & (((target_ulong )1 <<MSR_ME ));/* target registers */ srr0 =SPR_SRR0 ; srr1 =SPR_SRR1 ; -/* -* check for special resume at 0x100 from doze/nap/sleep/winkle on -* P7/P8/P9 -*/ -if (env->resume_as_sreset) { - excp =powerpc_reset_wakeup (cs, env, excp, &msr); - } -/* * Hypervisor emulation assistance interrupt only exists on server -* arch 2.05 server or later. We also don't want to generate it if -* we don't have HVB in msr_mask (PAPR mode). +* arch 2.05 server or later. */ - if (excp == POWERPC_EXCP_HV_EMU -#if defined(TARGET_PPC64 ) - && !(mmu_is_64bit(env->mmu_model) && (env->msr_mask & MSR_HVB)) -#endif /* defined(TARGET_PPC64) */ - - ) { +if (excp ==POWERPC_EXCP_HV_EMU ) { excp =POWERPC_EXCP_PROGRAM ; } -#ifdef TARGET_PPC64 -/* -* SPEU and VPU share the same IVOR but they exist in different -* processors. SPEU is e500v1/2 only and VPU is e6500 only. -*/ -if (excp_model ==POWERPC_EXCP_BOOKE && excp ==POWERPC_EXCP_VPU ) { - excp =POWERPC_EXCP_SPEU ; - } -#endif - vector = env->excp_vectors[excp];if (vector == (target_ulong)-1ULL ) { cpu_abort(cs, "Raised an exception without defined vector %d\n",@@ -645,24 +617,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) new_msr |= (target_ulong )MSR_HVB ; }break ; -case POWERPC_EXCP_SYSCALL_VECTORED :/* scv exception */ - lev = env->error_code; -dump_syscall (env); - env->nip +=4 ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_EE ); - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); - - vector += lev *0x20 ; - - env->lr = env->nip; - env->ctr = msr; -break ; -case POWERPC_EXCP_FPU :/* Floating-point unavailable exception */ -case POWERPC_EXCP_APU :/* Auxiliary processor unavailable */ -case POWERPC_EXCP_DECR :/* Decrementer exception */ -break ;case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ -/* FIT on 4xx */ trace_ppc_excp_print ("FIT" );break ;case POWERPC_EXCP_WDT :/* Watchdog timer interrupt */ @@ -693,119 +648,9 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)cpu_abort (cs,"Debug exception triggered on unsupported model\n" ); }break ; -case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavailable/VPU */ - env->spr[SPR_BOOKE_ESR ] =ESR_SPV ; -break ; -case POWERPC_EXCP_DOORI :/* Embedded doorbell interrupt */ -break ; -case POWERPC_EXCP_DOORCI :/* Embedded doorbell critical interrupt */ - srr0 =SPR_BOOKE_CSRR0 ; - srr1 =SPR_BOOKE_CSRR1 ; -break ; -case POWERPC_EXCP_RESET :/* System reset exception */ -/* A power-saving exception sets ME, otherwise it is unchanged */ -if (msr_pow) { -/* indicate that we resumed from power save mode */ - msr |=0x10000 ; - new_msr |= ((target_ulong )1 <<MSR_ME ); - } -if (env->msr_mask &MSR_HVB ) { -/* -* ISA specifies HV, but can be delivered to guest with HV -* clear (e.g., see FWNMI in PAPR, NMI injection in QEMU). -*/ - new_msr |= (target_ulong )MSR_HVB ; - }else { -if (msr_pow) { -cpu_abort (cs,"Trying to deliver power-saving system reset " -"exception %d with no HV support\n" , excp); - } - } -break ; -case POWERPC_EXCP_DSEG :/* Data segment exception */ -case POWERPC_EXCP_ISEG :/* Instruction segment exception */ -case POWERPC_EXCP_TRACE :/* Trace exception */ -break ; -case POWERPC_EXCP_HISI :/* Hypervisor instruction storage exception */ - msr |= env->error_code; -/* fall through */ -case POWERPC_EXCP_HDECR :/* Hypervisor decrementer exception */ -case POWERPC_EXCP_HDSI :/* Hypervisor data storage exception */ -case POWERPC_EXCP_HDSEG :/* Hypervisor data segment exception */ -case POWERPC_EXCP_HISEG :/* Hypervisor instruction segment exception */ -case POWERPC_EXCP_SDOOR_HV :/* Hypervisor Doorbell interrupt */ -case POWERPC_EXCP_HV_EMU : -case POWERPC_EXCP_HVIRT :/* Hypervisor virtualization */ - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - new_msr |= (target_ulong )MSR_HVB ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); -break ; -case POWERPC_EXCP_VPU :/* Vector unavailable exception */ -case POWERPC_EXCP_VSXU :/* VSX unavailable exception */ -case POWERPC_EXCP_FU :/* Facility unavailable exception */ -#ifdef TARGET_PPC64 - env->spr[SPR_FSCR ] |= ((target_ulong )env->error_code <<56 ); -#endif -break ; -case POWERPC_EXCP_HV_FU :/* Hypervisor Facility Unavailable Exception */ -#ifdef TARGET_PPC64 - env->spr[SPR_HFSCR ] |= ((target_ulong )env->error_code <<FSCR_IC_POS ); - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - new_msr |= (target_ulong )MSR_HVB ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); -#endif -break ;case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ trace_ppc_excp_print ("PIT" );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 */ -switch (excp_model) { -case POWERPC_EXCP_602 : -case POWERPC_EXCP_603 : -case POWERPC_EXCP_G2 : -/* Swap temporary saved registers with GPRs */ -if (!(new_msr & ((target_ulong )1 <<MSR_TGPR ))) { - new_msr |= (target_ulong )1 <<MSR_TGPR ; -hreg_swap_gpr_tgpr (env); - } -/* fall through */ -case POWERPC_EXCP_7x5: -ppc_excp_debug_sw_tlb (env, excp); - - msr |= env->crf[0 ] <<28 ; - msr |= env->error_code;/* key, D/I, S/L bits */ -/* Set way using a LRU mechanism */ - msr |= ((env->last_way +1 ) & (env->nb_ways -1 )) <<17 ; -break ; -default : -cpu_abort (cs,"Invalid TLB miss exception\n" ); -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 */ -case POWERPC_EXCP_DABR :/* Data address breakpoint */ -case POWERPC_EXCP_IABR :/* Instruction address breakpoint */ -case POWERPC_EXCP_SMI :/* System management interrupt */ -case POWERPC_EXCP_THERM :/* Thermal interrupt */ -case POWERPC_EXCP_PERFM :/* Embedded performance monitor interrupt */ -case POWERPC_EXCP_VPUA :/* Vector assist exception */ -case POWERPC_EXCP_SOFTP :/* Soft patch exception */ -case POWERPC_EXCP_MAINT :/* Maintenance exception */ -case POWERPC_EXCP_MEXTBR :/* Maskable external breakpoint */ -case POWERPC_EXCP_NMEXTBR :/* Non maskable external breakpoint */ -cpu_abort (cs,"%s exception not implemented\n" , -powerpc_excp_name (excp)); -break ;default : excp_invalid:cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);@@ -824,41 +669,11 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) } } -/* -* Sort out endianness of interrupt, this differs depending on the -* CPU, the HV mode, etc... -*/ -if (ppc_interrupts_little_endian (cpu, !!(new_msr &MSR_HVB ))) { - new_msr |= (target_ulong )1 <<MSR_LE ; - } +/* Save PC */ + env->spr[srr0] = env->nip; -#if defined(TARGET_PPC64 ) -if (excp_model ==POWERPC_EXCP_BOOKE ) { -if (env->spr[SPR_BOOKE_EPCR ] &EPCR_ICM ) { -/* Cat.64-bit: EPCR.ICM is copied to MSR.CM */ - new_msr |= (target_ulong )1 <<MSR_CM ; - }else { - vector = (uint32_t )vector; - } - }else { -if (!msr_isf && !mmu_is_64bit (env->mmu_model)) { - vector = (uint32_t )vector; - }else { - new_msr |= (target_ulong )1 <<MSR_SF ; - } - } -#endif - -if (excp !=POWERPC_EXCP_SYSCALL_VECTORED ) { -/* Save PC */ - env->spr[srr0] = env->nip; - -/* Save MSR */ - env->spr[srr1] = msr; - } - -/* This can update new_msr and vector if AIL applies */ -ppc_excp_apply_ail (cpu, excp_model, excp, msr, &new_msr, &vector); +/* Save MSR */ + env->spr[srr1] = msr;powerpc_set_excp_state (cpu, vector, new_msr); }
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
Re: [PATCH v2 11/14] target/ppc: 405: Data Storage exception cleanup
In reply to Fabiano RosasQuoted 2 lines · Fabiano Rosas
The 405 has no DSISR or DAR, so convert the trace entry to
trace_ppc_excp_print.
I think it would be preferable to show ESR and DEAR here, which are very loosely equivalent to DSISR and DAR on 40x. Might want to create a new trace point explicitly for this so the terminology is clear as well.
Quoted 19 lines
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/excp_helper.c +1
-1@@ -465,7 +465,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ -trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]); +trace_ppc_excp_print ("DSI" );break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip);
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
Re: [PATCH v2 08/14] target/ppc: 405: System call exception cleanup
In reply to Fabiano RosasQuoted 1 line · Fabiano Rosas
There's no sc 1.
No... but what exactly should and will happen if you attempt to execute an "sc 1" on 40x. Will it be treated as an "sc 0", or will it cause a 0x700? If it's a 0x700, better double check that that is generated at translation time, if you're removing the check on level here.
Quoted 51 lines
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)target/ppc/excp_helper.c +2
-19@@ -398,7 +398,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)CPUPPCState *env = &cpu->env;int excp_model = env->excp_model;target_ulong msr, new_msr, vector; -int srr0, srr1, lev =-1 ; +int srr0, srr1;if (excp <=POWERPC_EXCP_NONE || excp >=POWERPC_EXCP_NB ) {cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);@@ -521,30 +521,13 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) }break ;case POWERPC_EXCP_SYSCALL :/* System call exception */ - lev = env->error_code; - -if ((lev ==1 ) && cpu->vhyp) { -dump_hcall (env); - }else { -dump_syscall (env); - } +dump_syscall (env);/* * We need to correct the NIP which in this case is supposed * to point to the next instruction */ env->nip +=4 ; - -/* "PAPR mode" built-in hypercall emulation */ -if ((lev ==1 ) && cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hypercall (cpu->vhyp, cpu); -return ; - } -if (lev ==1 ) { - new_msr |= (target_ulong )MSR_HVB ; - }break ;case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ trace_ppc_excp_print ("FIT" );
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
Re: [PATCH v2 13/14] target/ppc: 405: Program exception cleanup
In reply to Fabiano RosasQuoted 5 lines · Fabiano Rosas
The 405 Program Interrupt does not set SRR1 with any diagnostic bits, just a clean copy of the MSR.
We're using the BookE Exception Syndrome Register which is different from the 405.
Hrm. We really do want to set the 40x ESR bits here, though.
Quoted 41 lines
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 16 ---------------- 1 file changed, 16 deletions(-)target/ppc/excp_helper.c +0
-16@@ -484,30 +484,14 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) env->error_code =0 ;return ; } - -/* -* FP exceptions always have NIP pointing to the faulting -* instruction, so always use store_next and claim we are -* precise in the MSR. -*/ - msr |=0x00100000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_FP ;break ;case POWERPC_EXCP_INVAL :trace_ppc_excp_inval (env->nip); - msr |=0x00080000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PIL ;break ;case POWERPC_EXCP_PRIV : - msr |=0x00040000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PPR ; -break ;case POWERPC_EXCP_TRAP : - msr |=0x00020000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PTR ;break ;default : -/* Should never occur */ cpu_abort (cs,"Invalid program exception %d. Aborting\n" , env->error_code);break ;
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
Re: [PATCH v2 06/14] target/ppc: 405: Machine check exception cleanup
In reply to David GibsonQuoted 26 lines · David Gibson
Quoted 25 lines · Fabiano Rosas
powerpc_excp_40xapplies only to the 405, so remove HV code and references to BookE.Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by David Gibson <[email protected]>--- target/ppc/excp_helper.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)target/ppc/excp_helper.c +0
-7@@ -457,34 +457,12 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) cs->halted =1 ;cpu_interrupt_exittb (cs); } -if (env->msr_mask &MSR_HVB ) { -/* -* ISA specifies HV, but can be delivered to guest with HV -* clear (e.g., see FWNMI in PAPR). -*/ - new_msr |= (target_ulong )MSR_HVB ; - }
Quoted 7 lines
target/ppc/excp_helper.c static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) · line 471
Quoted 4 lines
target/ppc/excp_helper.c +0
-1/* machine check exceptions don't have ME set */ new_msr &= ~((target_ulong )1 <<MSR_ME ); -/* XXX: should also have something loaded in DAR / DSISR */ DAR and DSISR don't apply for 40x, but I wonder if we should be loading something into DEAR or ESR for machine checks.
the user manuals only refers to SRR2 and SRR3.
Thanks,
C.
Quoted 23 lines
Quoted 22 lines
target/ppc/excp_helper.c +2
-16-switch (excp_model) { -case POWERPC_EXCP_40x: - srr0 = SPR_40x_SRR2; - srr1 = SPR_40x_SRR3; -break ; -case POWERPC_EXCP_BOOKE : -/* FIXME: choose one or the other based on CPU type */ - srr0 =SPR_BOOKE_MCSRR0 ; - srr1 =SPR_BOOKE_MCSRR1 ; - - env->spr[SPR_BOOKE_CSRR0 ] = env->nip; - env->spr[SPR_BOOKE_CSRR1 ] = msr; -break ; -default : -break ; - } + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]);
Re: [PATCH v2 02/14] target/ppc: 405: Add missing MSR_ME bit
In reply to Fabiano RosasQuoted 4 lines · Fabiano Rosas
The 405 MSR has the Machine Check Enable bit. We're making use of it when dispatching Machine Check, so add the bit to the
msr_mask.Signed-off-by Fabiano Rosas <[email protected]>
Thanks,
C.
Quoted 17 lines
--- target/ppc/cpu_init.c | 1 + 1 file changed, 1 insertion(+)target/ppc/cpu_init.c +1
-0@@ -2540,6 +2540,7 @@ POWERPC_FAMILY(405)(ObjectClass *oc, void *data) (1ull <<MSR_EE ) | (1ull <<MSR_PR ) | (1ull <<MSR_FP ) | + (1ull <<MSR_ME ) | (1ull <<MSR_DWE ) | (1ull <<MSR_DE ) | (1ull << MSR_IR) |
Re: [PATCH v2 03/14] target/ppc: Introduce powerpc_excp_40x
In reply to Fabiano RosasQuoted 5 lines · Fabiano Rosas
Introduce a new
powerpc_excpfunction specific for 40x CPUs. This commit copiespowerpc_excp_legacyverbatim so the next one has a clean diff.Signed-off-by Fabiano Rosas <[email protected]>
Thanks,
C.
Quoted 497 lines
--- target/ppc/excp_helper.c | 474 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+)target/ppc/excp_helper.c +474
-0@@ -392,6 +392,477 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu,check_tlb_flush (env, false); } +static void powerpc_excp_40x (PowerPCCPU *cpu,int excp) +{ +CPUState *cs =CPU (cpu); +CPUPPCState *env = &cpu->env; +int excp_model = env->excp_model; +target_ulong msr, new_msr, vector; +int srr0, srr1, lev =-1 ; + +if (excp <=POWERPC_EXCP_NONE || excp >=POWERPC_EXCP_NB ) { +cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp); + } + +qemu_log_mask (CPU_LOG_INT ,"Raise exception at " TARGET_FMT_lx +" => %s (%d) error=%02x\n" , env->nip,powerpc_excp_name (excp), + excp, env->error_code); + +/* new srr1 value excluding must-be-zero bits */ +if (excp_model ==POWERPC_EXCP_BOOKE ) { + msr = env->msr; + }else { + msr = env->msr & ~0x783f0000ULL ; + } + +/* +* new interrupt handler msr preserves existing HV and ME unless +* explicitly overriden +*/ + new_msr = env->msr & (((target_ulong )1 <<MSR_ME ) |MSR_HVB ); + +/* target registers */ + srr0 =SPR_SRR0 ; + srr1 =SPR_SRR1 ; + +/* +* check for special resume at 0x100 from doze/nap/sleep/winkle on +* P7/P8/P9 +*/ +if (env->resume_as_sreset) { + excp =powerpc_reset_wakeup (cs, env, excp, &msr); + } + +/* +* Hypervisor emulation assistance interrupt only exists on server +* arch 2.05 server or later. We also don't want to generate it if +* we don't have HVB in msr_mask (PAPR mode). +*/ + if (excp == POWERPC_EXCP_HV_EMU +#if defined(TARGET_PPC64 ) + && !(mmu_is_64bit(env->mmu_model) && (env->msr_mask & MSR_HVB)) +#endif /* defined(TARGET_PPC64) */ + + ) { + excp =POWERPC_EXCP_PROGRAM ; + } + +#ifdef TARGET_PPC64 +/* +* SPEU and VPU share the same IVOR but they exist in different +* processors. SPEU is e500v1/2 only and VPU is e6500 only. +*/ +if (excp_model ==POWERPC_EXCP_BOOKE && excp ==POWERPC_EXCP_VPU ) { + excp =POWERPC_EXCP_SPEU ; + } +#endif + + vector = env->excp_vectors[excp]; +if (vector == (target_ulong)-1ULL ) { +cpu_abort (cs,"Raised an exception without defined vector %d\n" , + excp); + } + + vector |= env->excp_prefix; + +switch (excp) { +case POWERPC_EXCP_CRITICAL :/* Critical input */ +switch (excp_model) { +case POWERPC_EXCP_40x: + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3; +break ; +case POWERPC_EXCP_BOOKE : + srr0 =SPR_BOOKE_CSRR0 ; + srr1 =SPR_BOOKE_CSRR1 ; +break ; +case POWERPC_EXCP_G2 : +break ; +default : + goto excp_invalid; + } +break ; +case POWERPC_EXCP_MCHECK :/* Machine check exception */ +if (msr_me ==0 ) { +/* +* Machine check exception is not enabled. Enter +* checkstop state. +*/ +fprintf (stderr,"Machine check while not allowed. " +"Entering checkstop state\n" ); +if (qemu_log_separate ()) { +qemu_log ("Machine check while not allowed. " +"Entering checkstop state\n" ); + } + cs->halted =1 ; +cpu_interrupt_exittb (cs); + } +if (env->msr_mask &MSR_HVB ) { +/* +* ISA specifies HV, but can be delivered to guest with HV +* clear (e.g., see FWNMI in PAPR). +*/ + new_msr |= (target_ulong )MSR_HVB ; + } + +/* machine check exceptions don't have ME set */ + new_msr &= ~((target_ulong )1 <<MSR_ME ); + +/* XXX: should also have something loaded in DAR / DSISR */ +switch (excp_model) { +case POWERPC_EXCP_40x: + srr0 = SPR_40x_SRR2; + srr1 = SPR_40x_SRR3; +break ; +case POWERPC_EXCP_BOOKE : +/* FIXME: choose one or the other based on CPU type */ + srr0 =SPR_BOOKE_MCSRR0 ; + srr1 =SPR_BOOKE_MCSRR1 ; + + env->spr[SPR_BOOKE_CSRR0 ] = env->nip; + env->spr[SPR_BOOKE_CSRR1 ] = msr; +break ; +default : +break ; + } +break ; +case POWERPC_EXCP_DSI :/* Data storage exception */ +trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]); +break ; +case POWERPC_EXCP_ISI :/* Instruction storage exception */ +trace_ppc_excp_isi (msr, env->nip); + msr |= env->error_code; +break ; +case POWERPC_EXCP_EXTERNAL :/* External input */ + { +bool lpes0; + + cs =CPU (cpu); + +/* +* Exception targeting modifiers +* +* LPES0 is supported on POWER7/8/9 +* LPES1 is not supported (old iSeries mode) +* +* On anything else, we behave as if LPES0 is 1 +* (externals don't alter MSR:HV) +*/ +#if defined(TARGET_PPC64 ) +if (excp_model ==POWERPC_EXCP_POWER7 || + excp_model ==POWERPC_EXCP_POWER8 || + excp_model ==POWERPC_EXCP_POWER9 || + excp_model ==POWERPC_EXCP_POWER10 ) { + lpes0 = !!(env->spr[SPR_LPCR ] &LPCR_LPES0 ); + } else +#endif /* defined(TARGET_PPC64) */ + { + lpes0 = true; + } + +if (!lpes0) { + new_msr |= (target_ulong )MSR_HVB ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); + srr0 =SPR_HSRR0 ; + srr1 =SPR_HSRR1 ; + } +if (env->mpic_proxy) { +/* IACK the IRQ on delivery */ + env->spr[SPR_BOOKE_EPR ] =ldl_phys (cs->as, env->mpic_iack); + } +break ; + } +case POWERPC_EXCP_ALIGN :/* Alignment exception */ +/* Get rS/rD and rA from faulting opcode */ +/* +* Note: the opcode fields will not be set properly for a +* direct store load/store, but nobody cares as nobody +* actually uses direct store segments. +*/ + env->spr[SPR_DSISR ] |= (env->error_code &0x03FF0000 ) >>16 ; +break ; +case POWERPC_EXCP_PROGRAM :/* Program exception */ +switch (env->error_code & ~0xF ) { +case POWERPC_EXCP_FP : +if ((msr_fe0 ==0 && msr_fe1 ==0 ) || msr_fp ==0 ) { +trace_ppc_excp_fp_ignore (); + cs->exception_index =POWERPC_EXCP_NONE ; + env->error_code =0 ; +return ; + } + +/* +* FP exceptions always have NIP pointing to the faulting +* instruction, so always use store_next and claim we are +* precise in the MSR. +*/ + msr |=0x00100000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_FP ; +break ; +case POWERPC_EXCP_INVAL : +trace_ppc_excp_inval (env->nip); + msr |=0x00080000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_PIL ; +break ; +case POWERPC_EXCP_PRIV : + msr |=0x00040000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_PPR ; +break ; +case POWERPC_EXCP_TRAP : + msr |=0x00020000 ; + env->spr[SPR_BOOKE_ESR ] =ESR_PTR ; +break ; +default : +/* Should never occur */ +cpu_abort (cs,"Invalid program exception %d. Aborting\n" , + env->error_code); +break ; + } +break ; +case POWERPC_EXCP_SYSCALL :/* System call exception */ + lev = env->error_code; + +if ((lev ==1 ) && cpu->vhyp) { +dump_hcall (env); + }else { +dump_syscall (env); + } + +/* +* We need to correct the NIP which in this case is supposed +* to point to the next instruction +*/ + env->nip +=4 ; + +/* "PAPR mode" built-in hypercall emulation */ +if ((lev ==1 ) && cpu->vhyp) { +PPCVirtualHypervisorClass *vhc = +PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); + vhc->hypercall (cpu->vhyp, cpu); +return ; + } +if (lev ==1 ) { + new_msr |= (target_ulong )MSR_HVB ; + } +break ; +case POWERPC_EXCP_SYSCALL_VECTORED :/* scv exception */ + lev = env->error_code; +dump_syscall (env); + env->nip +=4 ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_EE ); + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); + + vector += lev *0x20 ; + + env->lr = env->nip; + env->ctr = msr; +break ; +case POWERPC_EXCP_FPU :/* Floating-point unavailable exception */ +case POWERPC_EXCP_APU :/* Auxiliary processor unavailable */ +case POWERPC_EXCP_DECR :/* Decrementer exception */ +break ; +case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ +/* FIT on 4xx */ +trace_ppc_excp_print ("FIT" ); +break ; +case POWERPC_EXCP_WDT :/* Watchdog timer interrupt */ +trace_ppc_excp_print ("WDT" ); +switch (excp_model) { +case POWERPC_EXCP_BOOKE : + srr0 =SPR_BOOKE_CSRR0 ; + srr1 =SPR_BOOKE_CSRR1 ; +break ; +default : +break ; + } +break ; +case POWERPC_EXCP_DTLB :/* Data TLB error */ +case POWERPC_EXCP_ITLB :/* Instruction TLB error */ +break ; +case POWERPC_EXCP_DEBUG :/* Debug interrupt */ +if (env->flags &POWERPC_FLAG_DE ) { +/* FIXME: choose one or the other based on CPU type */ + srr0 =SPR_BOOKE_DSRR0 ; + srr1 =SPR_BOOKE_DSRR1 ; + + env->spr[SPR_BOOKE_CSRR0 ] = env->nip; + env->spr[SPR_BOOKE_CSRR1 ] = msr; + +/* DBSR already modified by caller */ + }else { +cpu_abort (cs,"Debug exception triggered on unsupported model\n" ); + } +break ; +case POWERPC_EXCP_SPEU :/* SPE/embedded floating-point unavailable/VPU */ + env->spr[SPR_BOOKE_ESR ] =ESR_SPV ; +break ; +case POWERPC_EXCP_DOORI :/* Embedded doorbell interrupt */ +break ; +case POWERPC_EXCP_DOORCI :/* Embedded doorbell critical interrupt */ + srr0 =SPR_BOOKE_CSRR0 ; + srr1 =SPR_BOOKE_CSRR1 ; +break ; +case POWERPC_EXCP_RESET :/* System reset exception */ +/* A power-saving exception sets ME, otherwise it is unchanged */ +if (msr_pow) { +/* indicate that we resumed from power save mode */ + msr |=0x10000 ; + new_msr |= ((target_ulong )1 <<MSR_ME ); + } +if (env->msr_mask &MSR_HVB ) { +/* +* ISA specifies HV, but can be delivered to guest with HV +* clear (e.g., see FWNMI in PAPR, NMI injection in QEMU). +*/ + new_msr |= (target_ulong )MSR_HVB ; + }else { +if (msr_pow) { +cpu_abort (cs,"Trying to deliver power-saving system reset " +"exception %d with no HV support\n" , excp); + } + } +break ; +case POWERPC_EXCP_DSEG :/* Data segment exception */ +case POWERPC_EXCP_ISEG :/* Instruction segment exception */ +case POWERPC_EXCP_TRACE :/* Trace exception */ +break ; +case POWERPC_EXCP_HISI :/* Hypervisor instruction storage exception */ + msr |= env->error_code; +/* fall through */ +case POWERPC_EXCP_HDECR :/* Hypervisor decrementer exception */ +case POWERPC_EXCP_HDSI :/* Hypervisor data storage exception */ +case POWERPC_EXCP_HDSEG :/* Hypervisor data segment exception */ +case POWERPC_EXCP_HISEG :/* Hypervisor instruction segment exception */ +case POWERPC_EXCP_SDOOR_HV :/* Hypervisor Doorbell interrupt */ +case POWERPC_EXCP_HV_EMU : +case POWERPC_EXCP_HVIRT :/* Hypervisor virtualization */ + srr0 =SPR_HSRR0 ; + srr1 =SPR_HSRR1 ; + new_msr |= (target_ulong )MSR_HVB ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); +break ; +case POWERPC_EXCP_VPU :/* Vector unavailable exception */ +case POWERPC_EXCP_VSXU :/* VSX unavailable exception */ +case POWERPC_EXCP_FU :/* Facility unavailable exception */ +#ifdef TARGET_PPC64 + env->spr[SPR_FSCR ] |= ((target_ulong )env->error_code <<56 ); +#endif +break ; +case POWERPC_EXCP_HV_FU :/* Hypervisor Facility Unavailable Exception */ +#ifdef TARGET_PPC64 + env->spr[SPR_HFSCR ] |= ((target_ulong )env->error_code <<FSCR_IC_POS ); + srr0 =SPR_HSRR0 ; + srr1 =SPR_HSRR1 ; + new_msr |= (target_ulong )MSR_HVB ; + new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); +#endif +break ; +case POWERPC_EXCP_PIT :/* Programmable interval timer interrupt */ +trace_ppc_excp_print ("PIT" ); +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 */ +switch (excp_model) { +case POWERPC_EXCP_602 : +case POWERPC_EXCP_603 : +case POWERPC_EXCP_G2 : +/* Swap temporary saved registers with GPRs */ +if (!(new_msr & ((target_ulong )1 <<MSR_TGPR ))) { + new_msr |= (target_ulong )1 <<MSR_TGPR ; +hreg_swap_gpr_tgpr (env); + } +/* fall through */ +case POWERPC_EXCP_7x5: +ppc_excp_debug_sw_tlb (env, excp); + + msr |= env->crf[0 ] <<28 ; + msr |= env->error_code;/* key, D/I, S/L bits */ +/* Set way using a LRU mechanism */ + msr |= ((env->last_way +1 ) & (env->nb_ways -1 )) <<17 ; +break ; +default : +cpu_abort (cs,"Invalid TLB miss exception\n" ); +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 */ +case POWERPC_EXCP_DABR :/* Data address breakpoint */ +case POWERPC_EXCP_IABR :/* Instruction address breakpoint */ +case POWERPC_EXCP_SMI :/* System management interrupt */ +case POWERPC_EXCP_THERM :/* Thermal interrupt */ +case POWERPC_EXCP_PERFM :/* Embedded performance monitor interrupt */ +case POWERPC_EXCP_VPUA :/* Vector assist exception */ +case POWERPC_EXCP_SOFTP :/* Soft patch exception */ +case POWERPC_EXCP_MAINT :/* Maintenance exception */ +case POWERPC_EXCP_MEXTBR :/* Maskable external breakpoint */ +case POWERPC_EXCP_NMEXTBR :/* Non maskable external breakpoint */ +cpu_abort (cs,"%s exception not implemented\n" , +powerpc_excp_name (excp)); +break ; +default : + excp_invalid: +cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp); +break ; + } + +/* Sanity check */ +if (!(env->msr_mask &MSR_HVB )) { +if (new_msr &MSR_HVB ) { +cpu_abort (cs,"Trying to deliver HV exception (MSR) %d with " +"no HV support\n" , excp); + } +if (srr0 ==SPR_HSRR0 ) { +cpu_abort (cs,"Trying to deliver HV exception (HSRR) %d with " +"no HV support\n" , excp); + } + } + +/* +* Sort out endianness of interrupt, this differs depending on the +* CPU, the HV mode, etc... +*/ +if (ppc_interrupts_little_endian (cpu, !!(new_msr &MSR_HVB ))) { + new_msr |= (target_ulong )1 <<MSR_LE ; + } + +#if defined(TARGET_PPC64 ) +if (excp_model ==POWERPC_EXCP_BOOKE ) { +if (env->spr[SPR_BOOKE_EPCR ] &EPCR_ICM ) { +/* Cat.64-bit: EPCR.ICM is copied to MSR.CM */ + new_msr |= (target_ulong )1 <<MSR_CM ; + }else { + vector = (uint32_t )vector; + } + }else { +if (!msr_isf && !mmu_is_64bit (env->mmu_model)) { + vector = (uint32_t )vector; + }else { + new_msr |= (target_ulong )1 <<MSR_SF ; + } + } +#endif + +if (excp !=POWERPC_EXCP_SYSCALL_VECTORED ) { +/* Save PC */ + env->spr[srr0] = env->nip; + +/* Save MSR */ + env->spr[srr1] = msr; + } + +/* This can update new_msr and vector if AIL applies */ +ppc_excp_apply_ail (cpu, excp_model, excp, msr, &new_msr, &vector); + + powerpc_set_excp_state(cpu, vector, new_msr); +} +/* * Note that this function should be greatly optimized when called * with a constant excp, from ppc_hw_interrupt @@ -872,6 +1343,9 @@ static void powerpc_excp(PowerPCCPU *cpu, int excp)CPUPPCState *env = &cpu->env;switch (env->excp_model) { +case POWERPC_EXCP_40x: +powerpc_excp_40x (cpu, excp); +break ;default :powerpc_excp_legacy (cpu, excp); }
Re: [PATCH v2 11/14] target/ppc: 405: Data Storage exception cleanup
In reply to David GibsonQuoted 6 lines · David Gibson
Quoted 2 lines · Fabiano Rosas
The 405 has no DSISR or DAR, so convert the trace entry to
trace_ppc_excp_print.I think it would be preferable to show ESR and DEAR here, which are very loosely equivalent to DSISR and DAR on 40x.
yes.
Quoted 2 lines
Might want to create
a new trace point explicitly for this so the terminology is clear as well.
trace_ppc_excp_print() s of my invention and not the best. I agree we should add extra traces.
Thanks,
C.
Quoted 20 lines
Quoted 19 lines
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/excp_helper.c +1
-1@@ -465,7 +465,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ -trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]); +trace_ppc_excp_print ("DSI" );break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip);
Re: [PATCH v2 01/14] target/ppc: 405: Rename MSR_POW to MSR_WE
In reply to Fabiano RosasQuoted 7 lines · Fabiano Rosas
Bit 13 is the Wait State Enable bit. Give it its proper name.
As far as I can see we don't do anything with
MSR_POWfor the 405, so this change has no effect.Suggested-by David Gibson <[email protected]>Signed-off-by Fabiano Rosas <[email protected]>
Thanks,
C.
Quoted 31 lines
--- target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)target/ppc/cpu.h +1
-0@@ -327,6 +327,7 @@ typedef enum {#define MSR_S 22/* Secure state */ #define MSR_KEY 19/* key bit on 603e */ #define MSR_POW 18/* Power management */ +#define MSR_WE 18/* Wait State Enable on 405 */ #define MSR_TGPR 17/* TGPR usage on 602/603 x */ #define MSR_CE 17/* Critical interrupt enable on embedded PowerPC x */ #define MSR_ILE 16/* Interrupt little-endian mode */ target/ppc/cpu_init.c +1
-1@@ -2535,7 +2535,7 @@ POWERPC_FAMILY(405)(ObjectClass *oc, void *data)PPC_MEM_SYNC |PPC_MEM_EIEIO | PPC_40x_TLB |PPC_MEM_TLBIA |PPC_MEM_TLBSYNC | PPC_4xx_COMMON |PPC_405_MAC | PPC_40x_EXCP; - pcc->msr_mask = (1ull <<MSR_POW ) | + pcc->msr_mask = (1ull <<MSR_WE ) | (1ull <<MSR_CE ) | (1ull <<MSR_EE ) | (1ull << MSR_PR) |
Re: [PATCH v2 13/14] target/ppc: 405: Program exception cleanup
In reply to David GibsonQuoted 8 lines · David Gibson
Quoted 5 lines · Fabiano Rosas
The 405 Program Interrupt does not set SRR1 with any diagnostic bits, just a clean copy of the MSR.
We're using the BookE Exception Syndrome Register which is different from the 405.
Hrm. We really do want to set the 40x ESR bits here, though.
Well I wrote the code and nothing changed so I dropped it. Not sure if we are even raising these properly in the translation code. I'll take another look.
Quoted 19 lines · Fabiano Rosas
changes from v1:
- New patch that renames
MSR_POWtoMSR_WEfor the 405.- New patch that adds just
MSR_MEto themsr_mask.- New patches to cleanup exceptions I missed the first time around.
- Dropped the patch that added all the missing MSR bits. We have an issue when two different MSR bits share the same number in different CPUs. Described in v1 here:
https://lists.nongnu.org/archive/html/qemu-ppc/2022-01/msg00503.html- Dropped the patch that adds missing exception vectors because Linux clearly cannot handle them. And I don't have access to real hardware to confirm some of the questions raised, so let's keep things as they are.
Quoted 7 lines
- Kept the split in two patches. One that copies
powerpc_excp_legacyand other that does the changes.Based on legoater/ppc-7.0
With only the fixes from the above branch, the ref405ep machine boots until the shell. This series doesn't change that.
FYI, with a couple of extra patches, adding a hotfoot variant machine and its PCI controller, network comes up with a rtl8139 and a virtio-net-pci devices. I2C seems fine. The only open issue is the timer which is twice too fast.
I will merge this series, unless Fabiano wants to send a v3, and the patch fixing the TLBs. The patches for the hotfoot variant can come later.
Thanks,
C.
qemu-system-ppc -M ref405ep-hotfoot -serial null -kernel /path/to/linux.git/build_ppc40x/arch/powerpc/boot/cuImage.hotfoot.elf -initrd /home/legoater/work/buildroot/images//qemu_ppc_ref405ep-latest//rootfs.cpio -net nic,model=virtio-net-pci,netdev=net0,addr=3 -netdev bridge,id=net0,helper=/usr/libexec/qemu-bridge-helper,br=virbr0 -device ds1338,address=0x68 -serial mon:stdio -nographic
Memory <- <0x0 0x8000000> (128MB)
CPU clock-frequency <- 0x7f28155 (133MHz)
CPU timebase-frequency <- 0x7f28155 (133MHz) /plb: clock-frequency <- 1fca055 (33MHz) /plb/opb: clock-frequency <- 1fca055 (33MHz) /plb/ebc: clock-frequency <- 1fca055 (33MHz) /plb/opb/serial@ef600300: clock-frequency <- 1d1079 (2MHz) /plb/opb/serial@ef600400: clock-frequency <- 1d1079 (2MHz)
ethernet0: local-mac-address <- 00:00:00:00:00:00
ethernet1: local-mac-address <- 00:00:07:f2:81:55 Fixing devtree for 4M Flash
zImage starting: loaded at 0x00700000 (sp: 0xfff7ff98) Decompression error: 'Not a gzip file'
No valid compressed data found, assume uncompressed data Allocating 0x613ee0 bytes for kernel... 0x5f391c bytes of uncompressed data copied Using loader supplied ramdisk at 0x1800000-0x1c6d800 initrd head: 0x30373037
Linux/PowerPC load:
Finalizing device tree... flat tree at 0xd1a960
Linux version 5.16.0-11200-g1d1df41c5a33-dirty (legoater@yukon) (powerpc64-linux-gnu-gcc (GCC) 11.2.1 20210728 (Red Hat Cross 11.2.1-1), GNU ld version 2.35.2-1.fc34) #127 Thu Jan 20 10:19:47 CET 2022 Found initrd at 0xc1800000:0xc1c6d800
Using PowerPC 40x Platform machine description
printk: bootconsole [udbg0] enabled
-----------------------------------------------------
phys_mem_size = 0x8000000 dcache_bsize = 0x20 icache_bsize = 0x20 cpu_features = 0x0000000000000100 possible = 0x0000000000000100 always = 0x0000000000000100
cpu_user_features = 0x86000000 0x00000000mmu_features = 0x00000004
-----------------------------------------------------
Zone ranges:
Normal [mem 0x0000000000000000-0x0000000007ffffff]
Movable zone start for each node
Early memory node ranges
node 0: [mem 0x0000000000000000-0x0000000007ffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
MMU: Allocated 1088 bytes of context maps for 255 contexts
Built 1 zonelists, mobility grouping on. Total pages: 32512
Kernel command line:
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
mem auto-init: stack:off, heap alloc:off, heap free:off
Kernel virtual memory layout:
* 0xffbdf000..0xfffff000 : fixmap
* 0xc9000000..0xffbdf000 : vmalloc & ioremap
Memory: 119108K/131072K available (4372K kernel code, 248K rwdata, 1308K rodata, 168K init, 127K bss, 11964K reserved, 0K cma-reserved)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1NR_IRQS: 512, nr_irqs: 512, preallocated irqs: 16
UIC0 (32 IRQ sources) at DCR 0xc0
clocksource: timebase: mask: 0xffffffffffffffff max_cycles: 0x1ec031343f, max_idle_ns: 440795203544 ns
clocksource: timebase mult[7800000] shift[24] registeredpid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
devtmpfs: initialized
random: get_random_u32 called from bucket_table_alloc.isra.0+0x74/0x170 with crng_init=0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 256 (order: -1, 3072 bytes, linear)
NET: Registered PF_NETLINK/PF_ROUTE protocol family
DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
thermal_sys: Registered thermal governor 'step_wise'
PCI host bridge /plb/pci@ec000000 (primary) ranges:
MEM 0x0000000080000000..0x000000009fffffff -> 0x0000000080000000
IO 0x00000000e8000000..0x00000000e800ffff -> 0x0000000000000000
4xx PCI DMA offset set to 0x00000000
4xx PCI DMA window base to 0x0000000000000000
DMA window size 0x0000000080000000
PCI: Probing PCI hardware
PCI host bridge to bus 0008:00pci_bus 0008:00: root bus resource [io 0x0000-0xffff]pci_bus 0008:00: root bus resource [mem 0x80000000-0x9fffffff]pci_bus 0008:00: root bus resource [bus 00-ff]pci_bus 0008:00: busn_res: [bus 00-ff] end is updated to ff
pci 0008:00:00.0: [1014:027f] type 00 class 0x068000
PCI: Hiding 4xx host bridge resources 0008:00:00.0
pci 0008:00:03.0: [1af4:1000] type 00 class 0x020000
pci 0008:00:03.0: reg 0x10: [io 0x0000-0x001f]
pci 0008:00:03.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
pci 0008:00:03.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]pci_bus 0008:00: busn_res: [bus 00-ff] end is updated to 00
pci 0008:00:03.0: BAR 6: assigned [mem 0x80000000-0x8003ffff pref]
pci 0008:00:03.0: BAR 4: assigned [mem 0x80040000-0x80043fff 64bit pref] pci 0008:00:03.0: BAR 0: assigned [io 0x1000-0x101f]pci_bus 0008:00: resource 4 [io 0x0000-0xffff]pci_bus 0008:00: resource 5 [mem 0x80000000-0x9fffffff]
vgaarb: loadedpps_core: LinuxPPS API ver. 1 registeredpps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]> PTP clock support registered
clocksource: Switched to clocksource timebase
NET: Registered PF_INET protocol family
IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear) tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear) TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear) TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
TCP: Hash tables configured (established 1024 bind 1024)
UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
NET: Registered PF_UNIX/PF_LOCAL protocol family
PCI: CLS 0 bytes, default 32
Trying to unpack rootfs image as initramfs...
workingset: timestamp_bits=30 max_order=15 bucket_order=0
io scheduler mq-deadline registered
io scheduler kyber registered
virtio-pci 0008:00:03.0: enabling device (0000 -> 0003)
Freeing initrd memory: 4532K
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
printk: console [ttyS0] disabled
serial8250.0: ttyS0 at MMIO 0xef600400 (irq = 16, base_baud = 119047) is a 16550A
printk: console [ttyS0] enabled
printk: console [ttyS0] enabled
printk: bootconsole [udbg0] disabled
printk: bootconsole [udbg0] disabled
serial8250.0: ttyS1 at MMIO 0xef600300 (irq = 17, base_baud = 119047) is a 16550A
printk: console [ttyS0] disabled
printk: console [ttyS0] enabled
ef600300.serial: ttyS1 at MMIO 0xef600300 (irq = 17, base_baud = 119047) is a 16550
brd: module loaded
e1000: Intel(R) PRO/1000 Network Driver
e1000: Copyright (c) 1999-2006 Intel Corporation.i2c_dev: i2c /dev entries driver
rtc-ds1307 0-0068: registered as rtc0
rtc-ds1307 0-0068: setting system clock to 2022-01-20T09:22:34 UTC (1642670554) ibm-iic ef600500.i2c: using standard (100 kHz) mode
lm75: probe of 0-004a failed with error -121
NET: Registered PF_PACKET protocol family
drmem: No dynamic reconfiguration memory found
Freeing unused kernel image (initmem) memory: 168K
Kernel memory protection not selected by kernel config.
Run /init as init process
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: random: dd: uninitialized urandom read (512 bytes read) OK
Starting network: udhcpc: started, v1.34.1
random: mktemp: uninitialized urandom read (6 bytes read)
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.199.76, server 192.168.199.1
udhcpc: lease of 192.168.199.76 obtained from 192.168.199.1, lease time 3600 deleting routers
random: mktemp: uninitialized urandom read (6 bytes read)
adding dns 192.168.199.1
OK
Welcome to Buildroot
buildroot login: root
# cat /proc/cpuinfo processor : 0 cpu : 405EP clock : 133.333333MHz revision : 9.80 (pvr 5121 0950) bogomips : 266.66
timebase : 133333333
platform : PowerPC 40x Platform
model : est,hotfoot
Memory : 128 MB
# cat /proc/interrupts
CPU0
16: 1552 UIC 1 Level ttyS0
23: 12 UIC 2 Level IBM IIC
27: 8 UIC 27 Level virtio0
LOC: 52166 Local timer interrupts for timer event device
BCT: 0 Broadcast timer interrupts for timer event device
LOC: 0 Local timer interrupts for others
SPU: 0 Spurious interrupts
PMI: 0 Performance monitoring interrupts
MCE: 0 Machine check exceptions
NMI: 0 System Reset interrupts
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.199.76/24 brd 192.168.199.255 scope global eth0
valid_lft forever preferred_lft forever
# hwclock random: fast init doneThu Jan 20 09:22:53 2022 0.000000 seconds
#
Re: [PATCH v2 13/14] target/ppc: 405: Program exception cleanup
In reply to Fabiano RosasQuoted 6 lines · Fabiano Rosas
Quoted 4 lines · David Gibson
Quoted 3 lines · Fabiano Rosas
The 405 Program Interrupt does not set SRR1 with any diagnostic bits, just a clean copy of the MSR.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
We're using the BookE Exception Syndrome Register which is different from the 405.
Hrm. We really do want to set the 40x ESR bits here, though.
Well I wrote the code and nothing changed so I dropped it. Not sure if we are even raising these properly in the translation code. I'll take another look.
For instance, this ESR bit allows Linux to handle traps correctly in some cases, like when CONFIG_DEBUG_VM=y :
@@ -488,7 +488,9 @@ static void powerpc_excp_40x(PowerPCCPU
trace_ppc_excp_inval(env->nip);
break;
case POWERPC_EXCP_PRIV:+ break;
case POWERPC_EXCP_TRAP:
+ env->spr[SPR_40x_ESR] = ESR_PTR;
break;
default:
cpu_abort(cs, "Invalid program exception %d. Aborting\n",
These could be reported to Linux :
/* On 4xx, the reason for the machine check or program exception
is in the ESR. */
#define get_reason(regs) ((regs)->esr)
#define REASON_FP ESR_FP
#define REASON_ILLEGAL (ESR_PIL | ESR_PUO)
#define REASON_PRIVILEGED ESR_PPR
#define REASON_TRAP ESR_PTR
#define REASON_PREFIXED 0
#define REASON_BOUNDARY 0
Thanks,
C.
Re: [PATCH v2 12/14] target/ppc: 405: Instruction storage interrupt cleanup
In reply to Fabiano Rosastarget/ppc/excp_helper.c static inline void powerpc_excp_legacy(PowerPCCPU *cpu, int excp)
Quoted 13 lines · Fabiano Rosas
The 405 ISI does not set SRR1 with any exception syndrome bits, only a clean copy of the MSR.
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 1 - 1 file changed, 1 deletion(-)target/ppc/excp_helper.c +0
-0@@ -715,7 +715,6 @@ static inline void powerpc_excp_legacy(PowerPCCPU *cpu, int excp)
This change is done in the wrong routine.
Thanks,
C.
Quoted 8 lines
target/ppc/excp_helper.c +0
-1break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip); - msr |= env->error_code;break ;case POWERPC_EXCP_EXTERNAL :/* External input */ {
Re: [PATCH v2 14/14] target/ppc: 405: Watchdog timer exception cleanup
In reply to Fabiano RosasQuoted 3 lines · Fabiano Rosas
Remove references to BookE.
Signed-off-by Fabiano Rosas <[email protected]>
trace point is becoming redundant. Anyhow,
Thanks,
C.
Quoted 32 lines
--- target/ppc/excp_helper.c | 9 --------- 1 file changed, 9 deletions(-)target/ppc/excp_helper.c +0
-9@@ -396,7 +396,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env; -int excp_model = env->excp_model;target_ulong msr, new_msr, vector;int srr0, srr1;@@ -511,14 +510,6 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)break ;case POWERPC_EXCP_WDT :/* Watchdog timer interrupt */ trace_ppc_excp_print ("WDT" ); -switch (excp_model) { -case POWERPC_EXCP_BOOKE : - srr0 =SPR_BOOKE_CSRR0 ; - srr1 =SPR_BOOKE_CSRR1 ; -break ; -default : -break ; - }break ;case POWERPC_EXCP_DTLB :/* Data TLB error */ case POWERPC_EXCP_ITLB :/* Instruction TLB error */
Re: [PATCH v2 12/14] target/ppc: 405: Instruction storage interrupt cleanup
In reply to Fabiano RosasQuoted 4 lines · Fabiano Rosas
The 405 ISI does not set SRR1 with any exception syndrome bits, only a clean copy of the MSR.
Signed-off-by Fabiano Rosas <[email protected]>
I changed the routine in which the removal was done. With that,
Thanks,
C.
Quoted 17 lines
--- target/ppc/excp_helper.c | 1 - 1 file changed, 1 deletion(-)target/ppc/excp_helper.c +0
-1@@ -715,7 +715,6 @@ static inline void powerpc_excp_legacy(PowerPCCPU *cpu, int excp)break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip); - msr |= env->error_code;break ;case POWERPC_EXCP_EXTERNAL :/* External input */ {
Re: [PATCH v2 11/14] target/ppc: 405: Data Storage exception cleanup
In reply to David GibsonQuoted 7 lines · David Gibson
Quoted 2 lines · Fabiano Rosas
The 405 has no DSISR or DAR, so convert the trace entry to
trace_ppc_excp_print.I think it would be preferable to show ESR and DEAR here, which are very loosely equivalent to DSISR and DAR on 40x. Might want to create a new trace point explicitly for this so the terminology is clear as well.
I changed registers to ESR and DEAR and updated commit log.
Trace point changes can come later. Some have become a bit redundant with CPU_LOG_INT.
Thanks,
C.
Quoted 21 lines
Quoted 20 lines
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/ppc/excp_helper.c +1
-1@@ -465,7 +465,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) srr1 = SPR_40x_SRR3;break ;case POWERPC_EXCP_DSI :/* Data storage exception */ -trace_ppc_excp_dsi (env->spr[SPR_DSISR ], env->spr[SPR_DAR ]); +trace_ppc_excp_print ("DSI" );break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */ trace_ppc_excp_isi (msr, env->nip);
Cédric Le Goater
Reviewed-byRe: [PATCH v2 11/14] target/ppc: 405: Data Storage exception cleanup
Quoted 5 lines · Cédric Le Goater
Quoted 4 lines · David Gibson
Quoted 2 lines · Fabiano Rosas
The 405 has no DSISR or DAR, so convert the trace entry to
trace_ppc_excp_print.
Quoted 8 lines
Quoted 3 lines
I think it would be preferable to show ESR and DEAR here, which are very loosely equivalent to DSISR and DAR on 40x. Might want to create a new trace point explicitly for this so the terminology is clear as well.
I changed registers to ESR and DEAR and updated commit log.
Trace point changes can come later. Some have become a bit redundant with
CPU_LOG_INT.
And,
Thanks,
C.
Re: [PATCH v2 13/14] target/ppc: 405: Program exception cleanup
In reply to Fabiano RosasQuoted 5 lines · Fabiano Rosas
The 405 Program Interrupt does not set SRR1 with any diagnostic bits, just a clean copy of the MSR.
We're using the BookE Exception Syndrome Register which is different from the 405.
I restored the setting of SPR_40x_ESR.
Quoted 1 line
Signed-off-by Fabiano Rosas <[email protected]>
Thanks,
C.
Quoted 40 lines
--- target/ppc/excp_helper.c | 16 ---------------- 1 file changed, 16 deletions(-)target/ppc/excp_helper.c +0
-16@@ -484,30 +484,14 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) env->error_code =0 ;return ; } - -/* -* FP exceptions always have NIP pointing to the faulting -* instruction, so always use store_next and claim we are -* precise in the MSR. -*/ - msr |=0x00100000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_FP ;break ;case POWERPC_EXCP_INVAL :trace_ppc_excp_inval (env->nip); - msr |=0x00080000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PIL ;break ;case POWERPC_EXCP_PRIV : - msr |=0x00040000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PPR ; -break ;case POWERPC_EXCP_TRAP : - msr |=0x00020000 ; - env->spr[SPR_BOOKE_ESR ] =ESR_PTR ;break ;default : -/* Should never occur */ cpu_abort (cs,"Invalid program exception %d. Aborting\n" , env->error_code);break ;
Re: [PATCH v2 08/14] target/ppc: 405: System call exception cleanup
In reply to David GibsonQuoted 8 lines · David Gibson
Quoted 1 line · Fabiano Rosas
There's no sc 1.
No... but what exactly should and will happen if you attempt to execute an "sc 1" on 40x. Will it be treated as an "sc 0", or will it cause a
0x700? If it's a0x700, better double check that that is generated at translation time, if you're removing the check on level here.
A Program Interrupt with the illegal instruction error code should be generated at translation time but it is not the case today. It never was correctly implemented AFAICT :
/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */ GEN_HANDLER(sc, 0x11, 0x11, 0xFF, 0x03FFF01D, PPC_FLOW), GEN_HANDLER(sc, 0x11, 0x01, 0xFF, 0x03FFF01D, PPC_FLOW),
We would need a simple 'sc' instruction for the PPC405 and other processors. Let's add that to the TODO list.
Thanks,
C.
Quoted 53 lines
Quoted 52 lines
Signed-off-by Fabiano Rosas <[email protected]>--- target/ppc/excp_helper.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)target/ppc/excp_helper.c +2
-19@@ -398,7 +398,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)CPUPPCState *env = &cpu->env;int excp_model = env->excp_model;target_ulong msr, new_msr, vector; -int srr0, srr1, lev =-1 ; +int srr0, srr1;if (excp <=POWERPC_EXCP_NONE || excp >=POWERPC_EXCP_NB ) {cpu_abort (cs,"Invalid PowerPC exception %d. Aborting\n" , excp);@@ -521,30 +521,13 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) }break ;case POWERPC_EXCP_SYSCALL :/* System call exception */ - lev = env->error_code; - -if ((lev ==1 ) && cpu->vhyp) { -dump_hcall (env); - }else { -dump_syscall (env); - } +dump_syscall (env);/* * We need to correct the NIP which in this case is supposed * to point to the next instruction */ env->nip +=4 ; - -/* "PAPR mode" built-in hypercall emulation */ -if ((lev ==1 ) && cpu->vhyp) { -PPCVirtualHypervisorClass *vhc = -PPC_VIRTUAL_HYPERVISOR_GET_CLASS (cpu->vhyp); - vhc->hypercall (cpu->vhyp, cpu); -return ; - } -if (lev ==1 ) { - new_msr |= (target_ulong )MSR_HVB ; - }break ;case POWERPC_EXCP_FIT :/* Fixed-interval timer interrupt */ trace_ppc_excp_print ("FIT" );
Cédric Le Goater
Reviewed-byRe: [PATCH v2 08/14] target/ppc: 405: System call exception cleanup
Quoted 14 lines · Cédric Le Goater
Quoted 8 lines · David Gibson
Quoted 1 line · Fabiano Rosas
There's no sc 1.
No... but what exactly should and will happen if you attempt to execute an "sc 1" on 40x. Will it be treated as an "sc 0", or will it cause a 0x700? If it's a
0x700, better double check that that is generated at translation time, if you're removing the check on level here.A Program Interrupt with the illegal instruction error code should be generated at translation time but it is not the case today. It never was correctly implemented AFAICT :
Quoted 6 lines
/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */
GEN_HANDLER(sc, 0x11, 0x11, 0xFF, 0x03FFF01D, PPC_FLOW),GEN_HANDLER(sc, 0x11, 0x01, 0xFF, 0x03FFF01D, PPC_FLOW),We would need a simple 'sc' instruction for the PPC405 and other processors. Let's add that to the TODO list.
The ref405ep machine now boots a mainline Linux with a buildroot user space. Let's get this series merged first.
Thanks,
C.
Re: [PATCH v2 08/14] target/ppc: 405: System call exception cleanup
In reply to Cédric Le GoaterQuoted 14 lines · Cédric Le Goater
Quoted 8 lines · David Gibson
Quoted 1 line · Fabiano Rosas
There's no sc 1.
No... but what exactly should and will happen if you attempt to execute an "sc 1" on 40x. Will it be treated as an "sc 0", or will it cause a
0x700? If it's a0x700, better double check that that is generated at translation time, if you're removing the check on level here.A Program Interrupt with the illegal instruction error code should be generated at translation time but it is not the case today. It never was correctly implemented AFAICT :
Quoted 6 lines
/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */
GEN_HANDLER(sc, 0x11, 0x11, 0xFF, 0x03FFF01D, PPC_FLOW),GEN_HANDLER(sc, 0x11, 0x01, 0xFF, 0x03FFF01D, PPC_FLOW),We would need a simple 'sc' instruction for the PPC405 and other processors. Let's add that to the TODO list.
Not directly related to this but as a reminder: if I remember correctly VOF uses sc 1 for hypercalls and I use VOF on pegasos2 which has a G4 or G3 CPU that does not have this instruction but we emulate that anyway so this works now at least with TCG. AFAICT changes so far did not break this but please consider this when getting there. We could use a different method for hypercalls in VOF but that would either result in different VOF binary for different machines or needing more changes to spap,r neither of which is desirable, so we chose this solution for now to allow hypercalls on 32bit PPC if the vhyp is set. This was in commit 5e994fc019862.
Regards,
BALATON Zoltan
Re: [PATCH v2 03/14] target/ppc: Introduce powerpc_excp_40x
In reply to Fabiano RosasQuoted 8 lines · Fabiano Rosas
Introduce a new
powerpc_excpfunction specific for 40x CPUs. This commit copiespowerpc_excp_legacyverbatim so the next one has a clean diff.Signed-off-by Fabiano Rosas<[email protected]>--- target/ppc/excp_helper.c | 474 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+)
r~
Re: [PATCH v2 07/14] target/ppc: 405: External exception cleanup
In reply to Fabiano RosasQuoted 44 lines · Fabiano Rosas
405 has no
MSR_HVand EPR is BookE only so we can remove it all.Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by David Gibson <[email protected]>--- target/ppc/excp_helper.c | 37 ------------------------------------- 1 file changed, 37 deletions(-)target/ppc/excp_helper.c +0
-28@@ -472,44 +472,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) msr |= env->error_code;break ;case POWERPC_EXCP_EXTERNAL :/* External input */ - { -bool lpes0; - - cs =CPU (cpu); - -/* -* Exception targeting modifiers -* -* LPES0 is supported on POWER7/8/9 -* LPES1 is not supported (old iSeries mode) -* -* On anything else, we behave as if LPES0 is 1 -* (externals don't alter MSR:HV) -*/ -#if defined(TARGET_PPC64 ) -if (excp_model ==POWERPC_EXCP_POWER7 || - excp_model ==POWERPC_EXCP_POWER8 || - excp_model ==POWERPC_EXCP_POWER9 || - excp_model ==POWERPC_EXCP_POWER10 ) { - lpes0 = !!(env->spr[SPR_LPCR ] &LPCR_LPES0 ); - } else -#endif /* defined(TARGET_PPC64) */ - { - lpes0 = true; - } - -if (!lpes0) { - new_msr |= (target_ulong )MSR_HVB ;
target/ppc/excp_helper.c static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) · line 512
Quoted 10 lines
target/ppc/excp_helper.c +0
-9- new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - } -if (env->mpic_proxy) { -/* IACK the IRQ on delivery */ - env->spr[SPR_BOOKE_EPR ] =ldl_phys (cs->as, env->mpic_iack); - }break ; - }
Bare break? Should this be reachable at all?
Should it in fact be g_assert_not_reached()?
r~
Re: [PATCH v2 05/14] target/ppc: 405: Critical exceptions cleanup
In reply to Fabiano RosasQuoted 8 lines · Fabiano Rosas
In
powerpc_excp_40xthe Critical exception is now for 405 only, so we can remove the BookE and G2 blocks.Signed-off-by Fabiano Rosas<[email protected]>Reviewed-by David Gibson<[email protected]>--- target/ppc/excp_helper.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
r~
Re: [PATCH v2 08/14] target/ppc: 405: System call exception cleanup
In reply to Fabiano RosasQuoted 6 lines · Fabiano Rosas
There's no sc 1.
Signed-off-by Fabiano Rosas<[email protected]>--- target/ppc/excp_helper.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
r~
Re: [PATCH v2 07/14] target/ppc: 405: External exception cleanup
In reply to Richard HendersonQuoted 50 lines · Richard Henderson
Quoted 49 lines · Fabiano Rosas
405 has no
MSR_HVand EPR is BookE only so we can remove it all.Signed-off-by Fabiano Rosas <[email protected]>Reviewed-by David Gibson <[email protected]>--- target/ppc/excp_helper.c | 37 ------------------------------------- 1 file changed, 37 deletions(-)target/ppc/excp_helper.c +0
-33@@ -472,44 +472,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) msr |= env->error_code;break ;case POWERPC_EXCP_EXTERNAL :/* External input */ - { -bool lpes0; - - cs =CPU (cpu); - -/* -* Exception targeting modifiers -* -* LPES0 is supported on POWER7/8/9 -* LPES1 is not supported (old iSeries mode) -* -* On anything else, we behave as if LPES0 is 1 -* (externals don't alter MSR:HV) -*/ -#if defined(TARGET_PPC64 ) -if (excp_model ==POWERPC_EXCP_POWER7 || - excp_model ==POWERPC_EXCP_POWER8 || - excp_model ==POWERPC_EXCP_POWER9 || - excp_model ==POWERPC_EXCP_POWER10 ) { - lpes0 = !!(env->spr[SPR_LPCR ] &LPCR_LPES0 ); - } else -#endif /* defined(TARGET_PPC64) */ - { - lpes0 = true; - } - -if (!lpes0) { - new_msr |= (target_ulong )MSR_HVB ; - new_msr |= env->msr & ((target_ulong )1 <<MSR_RI ); - srr0 =SPR_HSRR0 ; - srr1 =SPR_HSRR1 ; - } -if (env->mpic_proxy) {
Quoted 8 lines
target/ppc/excp_helper.c static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) · line 512
Quoted 5 lines
target/ppc/excp_helper.c +0
-4-/* IACK the IRQ on delivery */ - env->spr[SPR_BOOKE_EPR ] =ldl_phys (cs->as, env->mpic_iack); - }break ; - }Bare break? Should this be reachable at all?
Should it in fact beg_assert_not_reached()?
It should be reachable. It is a valid exception for this CPU. We just don't have anything else to do to dispatch it aside from what is done in the generic code outside the switch statement.