From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796157911; b=FJrWoviv27WvbO3H8P7+FZbZ4IwHgOinL4kB6FjOYHWjVPmOcOGWovsMMmhSPEN5ruFN JnwExTzFK3Mzdg8zgwEwEgL5Q143npNhqTEV75d198//aDzBfIdHpKQ09X20PotXXv66V Z9a6A3WxGHIfVxaLcDCdzf+0MEBAS6kLPFUYHxHdgAE3cIeG0bT1UhMItbDw+garEiJ7A IekkX9eHNsvxVNz1qlTTCySu3OgPumYLgzL8LoVATnW3nwJaapp0KLvvZ14Lr0amTVmDv Fv5EVDfIr5FogN7hfBVm+48+TuxSszWLGbp9JCzZqmD0TOBimuMaMtX8H0OO2QV8KOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157911; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=HA6ulGA6lTZodlBmBySq6VXrS7UgxPROmr/t47HvV0U=; b=ZPCGeeyRyX8gdfZR9HDK+IxX4TKVnXZfLRSy27HvXBQ9eTL349VwMu9oMBClu7xhy5xi g/p0Ipqj5xjCBD6Q5jLWHKWejM/hNLj4ZlUbz3YqOVquIhJgNF8C3GB/uWopsuOqOs/ic veMxxdY+PoxURJA9T+94Je+q0KG69PneDHEw1WMIc3rF7ieD9QR8iOqOqq9bOyB7x+CBZ yfCg4d3YNX33FtOVeeC8EBnaZktu41T5rfRhcv+2l5nfSx63A/0X8xQ8q/DBNCytbmeZl WiIhJg5AVH1KitXlgBAp0nfDVd6An5f9WrVWVuZ6WZaNDjYUmbuE/CKIX7BJQqsJTOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fxhcnlBa; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2EF7606A69A; Tue, 1 Dec 2026 20:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=fxhcnlBa Received: by smtp.kernel.org (Postfix) with ESMTPSA id E34411F0092B; Tue, 1 Dec 2026 20:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796157911; bh=HA6ulGA6lTZodlBmBySq6VXrS7UgxPROmr/t47HvV0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fxhcnlBaz4o77cCYkz3X6D/+AzsZ5P1Grk1hCKuMwhhvLoHbnQneD58dMthYvXQxE rfpfGAgkkHuWqNccWVVuu2SxI7vqUFqO+8PJw2woP94lein8GoUQNG+Zmm0JUBm92Q WVtlheSgK3V4P7e9aZlIeoqAO9T+HUgBn9cO5DzYg9SGH4k2iJS+fv8HLObBAGG21x tcTgIjjbI+7BE3QNXhAkoulbX/t4mZs9VA9sPvgEqRiDXUpRymqZM1nBptkZubZXPE bm5qY0vQCc5rNabYrWwrZlkbuQww+S3CVXipM9orSQEL77JiY7Dx8+XHGIX103sXOT L5wZD0drW0MEA== From: Oliver Upton To: Marc Zyngier , Oliver Upton , Catalin Marinas , Will Deacon , Sven Peter , Janne Grunau , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Mark Rutland , Neal Gompa , Radu Rendec , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , 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 Message-ID: <20261201204502.1813335-4-oupton@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201204502.1813335-1-oupton@kernel.org> References: <20261201204502.1813335-1-oupton@kernel.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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