Skip to content

Commit ecd1070

Browse files
npigginmpe
authored andcommitted
KVM: PPC: Book3S HV: Handle pending exceptions on guest entry with MSR_EE
Commit 026728d ("KVM: PPC: Book3S HV P9: Inject pending xive interrupts at guest entry") changed guest entry so that if external interrupts are enabled, BOOK3S_IRQPRIO_EXTERNAL is not tested for. Test for this regardless of MSR_EE. For an L1 host, do not inject an interrupt, but always use LPCR_MER. If the L0 desires it can inject an interrupt. Fixes: 026728d ("KVM: PPC: Book3S HV P9: Inject pending xive interrupts at guest entry") Signed-off-by: Nicholas Piggin <npiggin@gmail.com> [jpn: use kvmpcc_get_msr(), write commit message] Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20231201132618.555031-7-vaibhav@linux.ibm.com
1 parent ec0f663 commit ecd1070

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

arch/powerpc/kvm/book3s_hv.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4738,13 +4738,19 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,
47384738

47394739
if (!nested) {
47404740
kvmppc_core_prepare_to_enter(vcpu);
4741-
if (__kvmppc_get_msr_hv(vcpu) & MSR_EE) {
4742-
if (xive_interrupt_pending(vcpu))
4741+
if (test_bit(BOOK3S_IRQPRIO_EXTERNAL,
4742+
&vcpu->arch.pending_exceptions) ||
4743+
xive_interrupt_pending(vcpu)) {
4744+
/*
4745+
* For nested HV, don't synthesize but always pass MER,
4746+
* the L0 will be able to optimise that more
4747+
* effectively than manipulating registers directly.
4748+
*/
4749+
if (!kvmhv_on_pseries() && (__kvmppc_get_msr_hv(vcpu) & MSR_EE))
47434750
kvmppc_inject_interrupt_hv(vcpu,
4744-
BOOK3S_INTERRUPT_EXTERNAL, 0);
4745-
} else if (test_bit(BOOK3S_IRQPRIO_EXTERNAL,
4746-
&vcpu->arch.pending_exceptions)) {
4747-
lpcr |= LPCR_MER;
4751+
BOOK3S_INTERRUPT_EXTERNAL, 0);
4752+
else
4753+
lpcr |= LPCR_MER;
47484754
}
47494755
} else if (vcpu->arch.pending_exceptions ||
47504756
vcpu->arch.doorbell_request ||

0 commit comments

Comments
 (0)