Skip to contentSkip to conversation

target/ppc: Fix nested-hv HEAI delivery

PATCH Superseded Nicholas Piggin 3 participants 3 messages May 5, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/ppc: Fix nested-hv HEAI delivery

ppc hypervisors turn HEAI interrupts into program interrupts injected into the guest that executed the illegal instruction, if the hypervisor doesn't handle it some other way.

The nexted-hv implementation failed to account for this HEAI->program conversion. The virtual hypervisor wants to see the HEAI when running a nested guest, so that interrupt type can be returned to its KVM caller.

Fixes 7cebc5db2eba6 ("target/ppc: Introduce a vhyp framework for nested HV support")
---
 target/ppc/excp_helper.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
target/ppc/excp_helper.c +5 -2
index 199328f4b6..a833efa8f9 100644
@@ -1358,10 +1358,13 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
 
     /*
      * We don't want to generate a Hypervisor Emulation Assistance
-     * Interrupt if we don't have HVB in msr_mask (PAPR mode).
+     * Interrupt if we don't have HVB in msr_mask (PAPR mode),
+     * unless running a nested-hv guest, in which case the L1
+     * kernel wants the interrupt.
      */
     if (excp == POWERPC_EXCP_HV_EMU && !(env->msr_mask & MSR_HVB)) {
-        excp = POWERPC_EXCP_PROGRAM;
+        if (!books_vhyp_handles_hv_excp(cpu))
+            excp = POWERPC_EXCP_PROGRAM;
     }
 
     vector = env->excp_vectors[excp];
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Nicholas Piggin

ppc hypervisors turn HEAI interrupts into program interrupts injected into the guest that executed the illegal instruction, if the hypervisor doesn't handle it some other way.

The nexted-hv implementation failed to account for this HEAI->program conversion. The virtual hypervisor wants to see the HEAI when running a nested guest, so that interrupt type can be returned to its KVM caller.

Fixes 7cebc5db2eba6 ("target/ppc: Introduce a vhyp framework for nested HV support")
#2 lore raw
In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

ppc hypervisors turn HEAI interrupts into program interrupts injected into the guest that executed the illegal instruction, if the hypervisor doesn't handle it some other way.

The nexted-hv implementation failed to account for this HEAI->program

Typo: nested-hv?

Quoted 16 lines

conversion. The virtual hypervisor wants to see the HEAI when running a nested guest, so that interrupt type can be returned to its KVM caller.

Fixes 7cebc5db2eba6 ("target/ppc: Introduce a vhyp framework for nested HV support")

---
target/ppc/excp_helper.c | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
target/ppc/excp_helper.c +0 -0
index 199328f4b6..a833efa8f9 100644
@@ -1358,10 +1358,13 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
 

target/ppc/excp_helper.c static void powerpc_excp_books(PowerPCCPU *cpu, int excp) · line 1366

Quoted 10 lines
target/ppc/excp_helper.c +4 -2
    /*
     * We don't want to generate a Hypervisor Emulation Assistance
-     * Interrupt if we don't have HVB in msr_mask (PAPR mode).
+     * Interrupt if we don't have HVB in msr_mask (PAPR mode),
+     * unless running a nested-hv guest, in which case the L1
+     * kernel wants the interrupt.
     */
    if (excp == POWERPC_EXCP_HV_EMU && !(env->msr_mask & MSR_HVB)) {
-        excp = POWERPC_EXCP_PROGRAM;
+        if (!books_vhyp_handles_hv_excp(cpu))

You could instead write:

     if (excp == POWERPC_EXCP_HV_EMU && !(env->msr_mask & MSR_HVB) &&
         !books_vhyp_handles_hv_excp(cpu)) {

Regards.
BALATON Zoltan

Quoted 5 lines
target/ppc/excp_helper.c +1 -0
+            excp = POWERPC_EXCP_PROGRAM;
    }
 
    vector = env->excp_vectors[excp];