Message ID | 20200325144147.221875-2-npiggin@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ppc: sreset and machine check injection | expand |
On 3/25/20 3:41 PM, Nicholas Piggin wrote: > Rather than have the helper take an optional vector address > override, instead have its caller modify env->nip itself. > This is more consistent when adding pnv nmi support, and also > with mce injection added later. > > Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> > --- > hw/ppc/spapr.c | 9 ++++++--- > target/ppc/cpu.h | 2 +- > target/ppc/excp_helper.c | 5 +---- > 3 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 9a2bd501aa..785c41d205 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3385,13 +3385,13 @@ static void spapr_machine_finalizefn(Object *obj) > void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) > { > SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); > + PowerPCCPU *cpu = POWERPC_CPU(cs); > + CPUPPCState *env = &cpu->env; > > cpu_synchronize_state(cs); > /* If FWNMI is inactive, addr will be -1, which will deliver to 0x100 */ > if (spapr->fwnmi_system_reset_addr != -1) { > uint64_t rtas_addr, addr; > - PowerPCCPU *cpu = POWERPC_CPU(cs); > - CPUPPCState *env = &cpu->env; > > /* get rtas addr from fdt */ > rtas_addr = spapr_get_rtas_addr(); > @@ -3405,7 +3405,10 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) > stq_be_phys(&address_space_memory, addr + sizeof(uint64_t), 0); > env->gpr[3] = addr; > } > - ppc_cpu_do_system_reset(cs, spapr->fwnmi_system_reset_addr); > + ppc_cpu_do_system_reset(cs); > + if (spapr->fwnmi_system_reset_addr != -1) { > + env->nip = spapr->fwnmi_system_reset_addr; > + } > } > > static void spapr_nmi(NMIState *n, int cpu_index, Error **errp) > diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h > index 88d9449555..f4a5304d43 100644 > --- a/target/ppc/cpu.h > +++ b/target/ppc/cpu.h > @@ -1220,7 +1220,7 @@ int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, > int ppc32_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, > int cpuid, void *opaque); > #ifndef CONFIG_USER_ONLY > -void ppc_cpu_do_system_reset(CPUState *cs, target_ulong vector); > +void ppc_cpu_do_system_reset(CPUState *cs); > void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector); > extern const VMStateDescription vmstate_ppc_cpu; > #endif > diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c > index 08bc885ca6..7f2b5899d3 100644 > --- a/target/ppc/excp_helper.c > +++ b/target/ppc/excp_helper.c > @@ -961,15 +961,12 @@ static void ppc_hw_interrupt(CPUPPCState *env) > } > } > > -void ppc_cpu_do_system_reset(CPUState *cs, target_ulong vector) > +void ppc_cpu_do_system_reset(CPUState *cs) > { > PowerPCCPU *cpu = POWERPC_CPU(cs); > CPUPPCState *env = &cpu->env; > > powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); > - if (vector != -1) { > - env->nip = vector; > - } > } > > void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector) >
On Thu, Mar 26, 2020 at 12:41:43AM +1000, Nicholas Piggin wrote: > Rather than have the helper take an optional vector address > override, instead have its caller modify env->nip itself. > This is more consistent when adding pnv nmi support, and also > with mce injection added later. > > Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Applied to ppc-for-5.1. > --- > hw/ppc/spapr.c | 9 ++++++--- > target/ppc/cpu.h | 2 +- > target/ppc/excp_helper.c | 5 +---- > 3 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 9a2bd501aa..785c41d205 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -3385,13 +3385,13 @@ static void spapr_machine_finalizefn(Object *obj) > void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) > { > SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); > + PowerPCCPU *cpu = POWERPC_CPU(cs); > + CPUPPCState *env = &cpu->env; > > cpu_synchronize_state(cs); > /* If FWNMI is inactive, addr will be -1, which will deliver to 0x100 */ > if (spapr->fwnmi_system_reset_addr != -1) { > uint64_t rtas_addr, addr; > - PowerPCCPU *cpu = POWERPC_CPU(cs); > - CPUPPCState *env = &cpu->env; > > /* get rtas addr from fdt */ > rtas_addr = spapr_get_rtas_addr(); > @@ -3405,7 +3405,10 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) > stq_be_phys(&address_space_memory, addr + sizeof(uint64_t), 0); > env->gpr[3] = addr; > } > - ppc_cpu_do_system_reset(cs, spapr->fwnmi_system_reset_addr); > + ppc_cpu_do_system_reset(cs); > + if (spapr->fwnmi_system_reset_addr != -1) { > + env->nip = spapr->fwnmi_system_reset_addr; > + } > } > > static void spapr_nmi(NMIState *n, int cpu_index, Error **errp) > diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h > index 88d9449555..f4a5304d43 100644 > --- a/target/ppc/cpu.h > +++ b/target/ppc/cpu.h > @@ -1220,7 +1220,7 @@ int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, > int ppc32_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, > int cpuid, void *opaque); > #ifndef CONFIG_USER_ONLY > -void ppc_cpu_do_system_reset(CPUState *cs, target_ulong vector); > +void ppc_cpu_do_system_reset(CPUState *cs); > void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector); > extern const VMStateDescription vmstate_ppc_cpu; > #endif > diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c > index 08bc885ca6..7f2b5899d3 100644 > --- a/target/ppc/excp_helper.c > +++ b/target/ppc/excp_helper.c > @@ -961,15 +961,12 @@ static void ppc_hw_interrupt(CPUPPCState *env) > } > } > > -void ppc_cpu_do_system_reset(CPUState *cs, target_ulong vector) > +void ppc_cpu_do_system_reset(CPUState *cs) > { > PowerPCCPU *cpu = POWERPC_CPU(cs); > CPUPPCState *env = &cpu->env; > > powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); > - if (vector != -1) { > - env->nip = vector; > - } > } > > void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9a2bd501aa..785c41d205 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3385,13 +3385,13 @@ static void spapr_machine_finalizefn(Object *obj) void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) { SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; cpu_synchronize_state(cs); /* If FWNMI is inactive, addr will be -1, which will deliver to 0x100 */ if (spapr->fwnmi_system_reset_addr != -1) { uint64_t rtas_addr, addr; - PowerPCCPU *cpu = POWERPC_CPU(cs); - CPUPPCState *env = &cpu->env; /* get rtas addr from fdt */ rtas_addr = spapr_get_rtas_addr(); @@ -3405,7 +3405,10 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg) stq_be_phys(&address_space_memory, addr + sizeof(uint64_t), 0); env->gpr[3] = addr; } - ppc_cpu_do_system_reset(cs, spapr->fwnmi_system_reset_addr); + ppc_cpu_do_system_reset(cs); + if (spapr->fwnmi_system_reset_addr != -1) { + env->nip = spapr->fwnmi_system_reset_addr; + } } static void spapr_nmi(NMIState *n, int cpu_index, Error **errp) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 88d9449555..f4a5304d43 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1220,7 +1220,7 @@ int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int ppc32_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque); #ifndef CONFIG_USER_ONLY -void ppc_cpu_do_system_reset(CPUState *cs, target_ulong vector); +void ppc_cpu_do_system_reset(CPUState *cs); void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector); extern const VMStateDescription vmstate_ppc_cpu; #endif diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 08bc885ca6..7f2b5899d3 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -961,15 +961,12 @@ static void ppc_hw_interrupt(CPUPPCState *env) } } -void ppc_cpu_do_system_reset(CPUState *cs, target_ulong vector) +void ppc_cpu_do_system_reset(CPUState *cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; powerpc_excp(cpu, env->excp_model, POWERPC_EXCP_RESET); - if (vector != -1) { - env->nip = vector; - } } void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector)
Rather than have the helper take an optional vector address override, instead have its caller modify env->nip itself. This is more consistent when adding pnv nmi support, and also with mce injection added later. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- hw/ppc/spapr.c | 9 ++++++--- target/ppc/cpu.h | 2 +- target/ppc/excp_helper.c | 5 +---- 3 files changed, 8 insertions(+), 8 deletions(-)