]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Unconditionally set IL for injected undefined exceptions
authorFuad Tabba <tabba@google.com>
Thu, 18 Jun 2026 12:16:38 +0000 (13:16 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 22 Jun 2026 09:44:08 +0000 (10:44 +0100)
inject_undef64() derives IL from the triggering trap's instruction
length (kvm_vcpu_trap_il_is32bit()), but the IL of the injected
exception is fixed by its EC, not by the triggering instruction. The
architecture mandates IL=1 for EC=0 (Unknown) unconditionally, so the
conditional is wrong. The undef-injection paths are not reached from
16-bit instructions, so there is no functional change today, but the
logic should not rely on that.

Set ESR_ELx_IL unconditionally.

Fixes: aa8eff9bfbd5 ("arm64: KVM: fault injection into a guest")
Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260618121643.4105064-3-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/inject_fault.c

index 89982bd3345f6deccf6a18fd80f1cad123128426..9dfae1bcdf9924954494c5f1f4ab2b633a1d9ef5 100644 (file)
@@ -170,14 +170,7 @@ void kvm_inject_sync(struct kvm_vcpu *vcpu, u64 esr)
 
 static void inject_undef64(struct kvm_vcpu *vcpu)
 {
-       u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT);
-
-       /*
-        * Build an unknown exception, depending on the instruction
-        * set.
-        */
-       if (kvm_vcpu_trap_il_is32bit(vcpu))
-               esr |= ESR_ELx_IL;
+       u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT) | ESR_ELx_IL;
 
        kvm_inject_sync(vcpu, esr);
 }