[PATCH v2 3/4] KVM: PPC: Book3S HV: XICS: Avoid masking VP IPI on init failure

From: Gautam Menghani

Date: Fri Oct 09 2026 - 09:36:17 EST


In kvmppc_xive_connect_vcpu() if there is a failure before
xc->vp_ipi_data is setup, it can result in a NULL pointer dereference in
kvmppc_xive_cleanup_vcpu(). Fix this by adding a check before masking
the VP IPI before accessing the MMIO pages.

Signed-off-by: Gautam Menghani <gautam@xxxxxxxxxxxxx>
---
arch/powerpc/kvm/book3s_xive.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
index 67219044fb8c..b27127c43315 100644
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1818,7 +1818,8 @@ void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
kvmppc_xive_disable_vcpu_interrupts(vcpu);

/* Mask the VP IPI */
- xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);
+ if (xc->vp_ipi_data.eoi_mmio)
+ xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);

/* Free escalations */
for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {
--
2.55.0