[PATCH 3/4] KVM: arm64: Let the irqchip provide a fixup for FIQs taken to EL2

Oliver Upton oupton at kernel.org
Tue Dec 1 12:45:01 PST 2026


Certain implementations suffer from disappearing FIQs which are no
longer pending by the time KVM unmasks interrupts. That's no good; give
the irqchip a hook to intervene on FIQ exceptions taken from the guest.

Signed-off-by: Oliver Upton <oupton at kernel.org>
---
 arch/arm64/kvm/arm.c                  | 3 +++
 arch/arm64/kvm/vgic/vgic-init.c       | 6 ++++++
 arch/arm64/kvm/vgic/vgic.h            | 9 +++++++++
 include/kvm/arm_vgic.h                | 4 ++++
 include/linux/irqchip/arm-vgic-info.h | 3 +++
 5 files changed, 25 insertions(+)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index a6123defd7e6..e69e23b1541b 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1537,6 +1537,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
 		 */
 		smp_store_release(&vcpu->mode, OUTSIDE_GUEST_MODE);
 
+		/* Fixup a borked asynchronous exception before unmasking IRQs */
+		vgic_fixup_async_exception(ret);
+
 		/*
 		 * We must ensure that any pending interrupts are taken before
 		 * we exit guest timing so that timer ticks are accounted as
diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
index c9991e24cb6b..c44066d8419e 100644
--- a/arch/arm64/kvm/vgic/vgic-init.c
+++ b/arch/arm64/kvm/vgic/vgic-init.c
@@ -912,6 +912,12 @@ int kvm_vgic_hyp_init(void)
 		ret = -ENODEV;
 	}
 
+	if (gic_kvm_info->fixup_fiq_exception) {
+		kvm_vgic_global_state.fixup_fiq_exception = gic_kvm_info->fixup_fiq_exception;
+		static_branch_enable(&kvm_vgic_global_state.needs_fiq_exception_fixup);
+		kvm_info("irqchip requires FIQ exception fixup\n");
+	}
+
 	kvm_vgic_global_state.maint_irq = gic_kvm_info->maint_irq;
 
 out_free:
diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h
index 97fc3bdf520e..d4fcc6f2fe97 100644
--- a/arch/arm64/kvm/vgic/vgic.h
+++ b/arch/arm64/kvm/vgic/vgic.h
@@ -536,4 +536,13 @@ static inline bool vgic_supports_direct_irqs(struct kvm *kvm)
 int vgic_its_debug_init(struct kvm_device *dev);
 void vgic_its_debug_destroy(struct kvm_device *dev);
 
+static inline void vgic_fixup_async_exception(int ret)
+{
+	if (!static_branch_unlikely(&kvm_vgic_global_state.needs_fiq_exception_fixup))
+		return;
+
+	if (ARM_EXCEPTION_CODE(ret) == ARM_EXCEPTION_FIQ)
+		kvm_vgic_global_state.fixup_fiq_exception();
+}
+
 #endif
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index 4b2c41917b77..962ca522831c 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -202,6 +202,10 @@ struct vgic_global {
 	/* GICv3 system register CPU interface */
 	struct static_key_false gicv3_cpuif;
 
+	/* Hot garbage irqchip that loses FIQs */
+	struct static_key_false needs_fiq_exception_fixup;
+	void			(*fixup_fiq_exception)(void);
+
 	/* GICv3 compat mode on a GICv5 host */
 	bool			has_gcie_v3_compat;
 
diff --git a/include/linux/irqchip/arm-vgic-info.h b/include/linux/irqchip/arm-vgic-info.h
index f05370e2debf..67d36d4b6214 100644
--- a/include/linux/irqchip/arm-vgic-info.h
+++ b/include/linux/irqchip/arm-vgic-info.h
@@ -43,6 +43,9 @@ struct gic_kvm_info {
 		void __iomem	*base;
 		bool		non_coherent;
 	}		gicv5_irs;
+
+	/* Disappearing FIQs, need to rematerialize */
+	void		(*fixup_fiq_exception)(void);
 };
 
 #ifdef CONFIG_KVM
-- 
2.47.3




More information about the linux-arm-kernel mailing list