]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: Add a generic synchronous exception injection primitive
authorMarc Zyngier <maz@kernel.org>
Thu, 8 Jan 2026 17:32:27 +0000 (17:32 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 15 Jan 2026 11:58:56 +0000 (11:58 +0000)
Maybe in a surprising way, we don't currently have a generic way
to inject a synchronous exception at the EL the vcpu is currently
running at.

Extract such primitive from the UNDEF injection code.

Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Link: https://patch.msgid.link/20260108173233.2911955-4-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/inject_fault.c

index c9eab316398e2ea4c1a5b937ff9d476927fbcd58..df20d47f0d25699910299cb93148add96e50cf87 100644 (file)
@@ -45,6 +45,7 @@ bool kvm_condition_valid32(const struct kvm_vcpu *vcpu);
 void kvm_skip_instr32(struct kvm_vcpu *vcpu);
 
 void kvm_inject_undefined(struct kvm_vcpu *vcpu);
+void kvm_inject_sync(struct kvm_vcpu *vcpu, u64 esr);
 int kvm_inject_serror_esr(struct kvm_vcpu *vcpu, u64 esr);
 int kvm_inject_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr);
 void kvm_inject_size_fault(struct kvm_vcpu *vcpu);
index dfcd66c6551799774c130eafddb9424ca00f72f0..7102424a3fa5e5daf3d6d6d0fb2aebc2d604dd11 100644 (file)
@@ -162,12 +162,16 @@ static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr
        vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu));
 }
 
+void kvm_inject_sync(struct kvm_vcpu *vcpu, u64 esr)
+{
+       pend_sync_exception(vcpu);
+       vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu));
+}
+
 static void inject_undef64(struct kvm_vcpu *vcpu)
 {
        u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT);
 
-       pend_sync_exception(vcpu);
-
        /*
         * Build an unknown exception, depending on the instruction
         * set.
@@ -175,7 +179,7 @@ static void inject_undef64(struct kvm_vcpu *vcpu)
        if (kvm_vcpu_trap_il_is32bit(vcpu))
                esr |= ESR_ELx_IL;
 
-       vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu));
+       kvm_inject_sync(vcpu, esr);
 }
 
 #define DFSR_FSC_EXTABT_LPAE   0x10