From: Oliver Upton <oupton@kernel.org>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Sven Peter <sven@kernel.org>,
Janne Grunau <j@jannau.net>, Thomas Gleixner <tglx@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Cc: Fuad Tabba <fuad.tabba@linux.dev>,
Joey Gouly <joey.gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Mark Rutland <mark.rutland@arm.com>, Neal Gompa <neal@gompa.dev>,
Radu Rendec <radu@rendec.net>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, asahi@lists.linux.dev,
linux-perf-users@vger.kernel.org
Subject: [PATCH 3/4] KVM: arm64: Let the irqchip provide a fixup for FIQs taken to EL2
Date: Tue, 1 Dec 2026 12:45:01 -0800 [thread overview]
Message-ID: <20261201204502.1813335-4-oupton@kernel.org> (raw)
In-Reply-To: <20261201204502.1813335-1-oupton@kernel.org>
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@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
next prev parent reply other threads:[~2026-12-01 20:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 20:44 [PATCH 0/4] KVM: arm64: Fixes for guest-only PMU event overflows on Apple Silicon Oliver Upton
2026-12-01 20:44 ` [PATCH 1/4] KVM: arm64: Track IRQ and FIQ exceptions separately Oliver Upton
2026-12-01 20:45 ` [PATCH 2/4] perf kvm stat: Add new 'ARM_EXCEPTION_FIQ' exception type Oliver Upton
2026-12-01 20:45 ` Oliver Upton [this message]
2026-12-01 20:45 ` [PATCH 4/4] irqchip/apple-aic: Work around FIQ storms upon vPMU counter overflow Oliver Upton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201204502.1813335-4-oupton@kernel.org \
--to=oupton@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=asahi@lists.linux.dev \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=irogers@google.com \
--cc=j@jannau.net \
--cc=james.clark@linaro.org \
--cc=joey.gouly@arm.com \
--cc=jolsa@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=neal@gompa.dev \
--cc=peterz@infradead.org \
--cc=radu@rendec.net \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=sven@kernel.org \
--cc=tglx@kernel.org \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox