diff mbox series

[RFC,v2,09/12] target/ppc: Use common code for Hypervisor interrupts

Message ID 20211220181903.3456898-10-farosas@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series target/ppc: powerpc_excp improvements | expand

Commit Message

Fabiano Rosas Dec. 20, 2021, 6:19 p.m. UTC
The Hypervisor interrupts all set the MSR_HV bit, and use HSRRs
instead of SRRs, so we can use the same code to setup them all.

No functional change.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---
 target/ppc/interrupts.c | 128 +++++++---------------------------------
 target/ppc/ppc_intr.h   |   8 +--
 2 files changed, 21 insertions(+), 115 deletions(-)
diff mbox series

Patch

diff --git a/target/ppc/interrupts.c b/target/ppc/interrupts.c
index 1e4fb2d6db..61a7dec682 100644
--- a/target/ppc/interrupts.c
+++ b/target/ppc/interrupts.c
@@ -364,86 +364,22 @@  void ppc_intr_system_reset(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
     }
 }
 
+void ppc_intr_hv(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
+{
+    CPUPPCState *env = &cpu->env;
+
+    regs->sprn_srr0 = SPR_HSRR0;
+    regs->sprn_srr1 = SPR_HSRR1;
+    regs->new_msr |= (target_ulong)MSR_HVB;
+    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
+}
+
 void ppc_intr_hv_insn_storage(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
 {
     CPUPPCState *env = &cpu->env;
 
     regs->msr |= env->error_code;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_decrementer(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_data_storage(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_data_segment(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_insn_segment(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_doorbell(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_emulation(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
-}
-
-void ppc_intr_hv_virtualization(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
-{
-    CPUPPCState *env = &cpu->env;
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
+    ppc_intr_hv(cpu, regs, ignore);
 }
 
 void ppc_intr_facility_unavail(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore)
@@ -459,11 +395,7 @@  void ppc_intr_hv_facility_unavail(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *igno
 #ifdef TARGET_PPC64
     CPUPPCState *env = &cpu->env;
     env->spr[SPR_FSCR] |= ((target_ulong)env->error_code << FSCR_IC_POS);
-
-    regs->sprn_srr0 = SPR_HSRR0;
-    regs->sprn_srr1 = SPR_HSRR1;
-    regs->new_msr |= (target_ulong)MSR_HVB;
-    regs->new_msr |= env->msr & ((target_ulong)1 << MSR_RI);
+    ppc_intr_hv(cpu, regs, ignore);
 #endif
 }
 
@@ -571,34 +503,10 @@  PPCInterrupt interrupts[POWERPC_EXCP_NB] = {
         "Facility unavailable", ppc_intr_facility_unavail
     },
 
-    [POWERPC_EXCP_HDECR] = {
-        "Hypervisor decrementer", ppc_intr_hv_decrementer
-    },
-
-    [POWERPC_EXCP_HDSEG] = {
-        "Hypervisor data segment", ppc_intr_hv_data_segment
-    },
-
-    [POWERPC_EXCP_HDSI] = {
-        "Hypervisor data storage", ppc_intr_hv_data_storage
-    },
-
-    [POWERPC_EXCP_HISEG] = {
-        "Hypervisor insn segment", ppc_intr_hv_insn_segment
-    },
-
     [POWERPC_EXCP_HISI] = {
         "Hypervisor instruction storage", ppc_intr_hv_insn_storage
     },
 
-    [POWERPC_EXCP_HVIRT] = {
-        "Hypervisor virtualization", ppc_intr_hv_virtualization
-    },
-
-    [POWERPC_EXCP_HV_EMU] = {
-        "Hypervisor emulation assist", ppc_intr_hv_emulation
-    },
-
     [POWERPC_EXCP_HV_FU] = {
         "Hypervisor facility unavailable" , ppc_intr_hv_facility_unavail
     },
@@ -627,10 +535,6 @@  PPCInterrupt interrupts[POWERPC_EXCP_NB] = {
         "System reset", ppc_intr_system_reset
     },
 
-    [POWERPC_EXCP_SDOOR_HV] = {
-        "Hypervisor doorbell", ppc_intr_hv_doorbell
-    },
-
     [POWERPC_EXCP_SPEU] = {
         "SPE/embedded FP unavailable/VPU", ppc_intr_spe_unavailable
     },
@@ -655,6 +559,14 @@  PPCInterrupt interrupts[POWERPC_EXCP_NB] = {
         "Watchdog timer", ppc_intr_watchdog
     },
 
+    [POWERPC_EXCP_HDECR]    = { "Hypervisor decrementer",         ppc_intr_hv },
+    [POWERPC_EXCP_HDSEG]    = { "Hypervisor data segment",        ppc_intr_hv },
+    [POWERPC_EXCP_HDSI]     = { "Hypervisor data storage",        ppc_intr_hv },
+    [POWERPC_EXCP_HISEG]    = { "Hypervisor insn segment",        ppc_intr_hv },
+    [POWERPC_EXCP_HVIRT]    = { "Hypervisor virtualization",      ppc_intr_hv },
+    [POWERPC_EXCP_HV_EMU]   = { "Hypervisor emulation assist",    ppc_intr_hv },
+    [POWERPC_EXCP_SDOOR_HV] = { "Hypervisor doorbell",            ppc_intr_hv },
+
     [POWERPC_EXCP_APU]   = { "Aux. processor unavailable", ppc_intr_noop },
     [POWERPC_EXCP_DECR]  = { "Decrementer",                ppc_intr_noop },
     [POWERPC_EXCP_DOORI] = { "Embedded doorbell",          ppc_intr_noop },
diff --git a/target/ppc/ppc_intr.h b/target/ppc/ppc_intr.h
index a96062c583..078906ed68 100644
--- a/target/ppc/ppc_intr.h
+++ b/target/ppc/ppc_intr.h
@@ -27,15 +27,9 @@  void ppc_intr_embedded_doorbell_crit(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *i
 void ppc_intr_external(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_facility_unavail(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_fit(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_data_segment(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_data_storage(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_decrementer(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_doorbell(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_emulation(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
+void ppc_intr_hv(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_hv_facility_unavail(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_insn_segment(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_hv_insn_storage(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
-void ppc_intr_hv_virtualization(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_insn_storage(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_machine_check(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);
 void ppc_intr_noop(PowerPCCPU *cpu, PPCIntrArgs *regs, bool *ignore);