[PATCH v3 34/44] KVM: arm64: Propagate ALLINT masking on exception injection
Vladimir Murzin
vladimir.murzin at arm.com
Mon Nov 30 07:54:56 PST 2026
From: Marc Zyngier <maz at kernel.org>
Hardware with FEAT_NMI implemented always sets PSTATE.ALLINT to
the inverse of SCTLR_ELx.SPINTMASK on taking the exception
regardless of the value of SCTLR_ELx.NMI. Reflect hardware
behavior when injecting an exception.
Signed-off-by: Marc Zyngier <maz at kernel.org>
[vm] add nVHE side, add commit message
Signed-off-by: Vladimir Murzin <vladimir.murzin at arm.com>
---
arch/arm64/kvm/hyp/exception.c | 5 +++++
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 3 +++
2 files changed, 8 insertions(+)
diff --git a/arch/arm64/kvm/hyp/exception.c b/arch/arm64/kvm/hyp/exception.c
index 7521bddf73e4..4cb278bb12ac 100644
--- a/arch/arm64/kvm/hyp/exception.c
+++ b/arch/arm64/kvm/hyp/exception.c
@@ -138,6 +138,11 @@ static void enter_exception64(struct kvm_vcpu *vcpu, unsigned long target_mode,
if (sctlr & SCTLR_ELx_DSSBS)
new |= PSR_SSBS_BIT;
+ // PSTATE.ALLINT is set to the inverse value of SCTLR_ELx.SPINTMASK
+ // See ARM DDI 0487M.a.a, R_WTXBY
+ if (system_supports_nmi() && !(sctlr & SCTLR_EL1_SPINTMASK))
+ new |= PSR_ALLINT_BIT;
+
// PSTATE.BTYPE is set to zero upon any exception to AArch64
// See ARM DDI 0487E.a, pages D1-2293 to D1-2294.
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index 0c023ee0cf42..5fde28bffef5 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -1726,6 +1726,9 @@ void inject_host_exception(u64 esr)
if (system_supports_mte())
spsr_el2 |= PSR_TCO_BIT;
+ if (system_supports_nmi() && !(sctlr & SCTLR_EL1_SPINTMASK))
+ spsr_el2 |= PSR_ALLINT_BIT;
+
if (esr_fsc_is_translation_fault(esr))
write_sysreg_el1(read_sysreg_el2(SYS_FAR), SYS_FAR);
--
2.34.1
More information about the linux-arm-kernel
mailing list