[PATCH 2/3] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work

From: Gautam Menghani

Date: Thu Oct 01 2026 - 06:03:09 EST


In kvmppc_xive_connect_vcpu(), if any failures are encountered, the
control flow jumps to the 'bail' label where kvmppc_xive_cleanup_vcpu()
is called. This cleanup function exits prematurely since
vcpu->arch.irq_type is set to KVMPPC_IRQ_DEFAULT at this point. This ends
up resulting in wasted memory.

Fix this by setting irq_type to KVMPPC_IRQ_XICS before vcpu configuration
starts. This makes XICS initialization symmetrical to XIVE
initialization done in kvmppc_xive_native_connect_vcpu().

Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Cc: stable@xxxxxxxxxxxxxxx # 4.12+
Signed-off-by: Gautam Menghani <gautam@xxxxxxxxxxxxx>
---
arch/powerpc/kvm/book3s_xive.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
index 1d67237783b7..67219044fb8c 100644
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1937,6 +1937,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
xc->vp_id = vp_id;
xc->mfrr = 0xff;
xc->valid = true;
+ vcpu->arch.irq_type = KVMPPC_IRQ_XICS;

r = xive_native_get_vp_info(xc->vp_id, &xc->vp_cam, &xc->vp_chip_id);
if (r)
@@ -2025,7 +2026,6 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
return r;
}

- vcpu->arch.irq_type = KVMPPC_IRQ_XICS;
return 0;
}

--
2.52.0