Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Add a generic synchronous exception injection primitive

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>

+8 -3
+1
arch/arm64/include/asm/kvm_emulate.h
··· 45 45 void kvm_skip_instr32(struct kvm_vcpu *vcpu); 46 46 47 47 void kvm_inject_undefined(struct kvm_vcpu *vcpu); 48 + void kvm_inject_sync(struct kvm_vcpu *vcpu, u64 esr); 48 49 int kvm_inject_serror_esr(struct kvm_vcpu *vcpu, u64 esr); 49 50 int kvm_inject_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr); 50 51 void kvm_inject_size_fault(struct kvm_vcpu *vcpu);
+7 -3
arch/arm64/kvm/inject_fault.c
··· 162 162 vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu)); 163 163 } 164 164 165 + void kvm_inject_sync(struct kvm_vcpu *vcpu, u64 esr) 166 + { 167 + pend_sync_exception(vcpu); 168 + vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu)); 169 + } 170 + 165 171 static void inject_undef64(struct kvm_vcpu *vcpu) 166 172 { 167 173 u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT); 168 - 169 - pend_sync_exception(vcpu); 170 174 171 175 /* 172 176 * Build an unknown exception, depending on the instruction ··· 179 175 if (kvm_vcpu_trap_il_is32bit(vcpu)) 180 176 esr |= ESR_ELx_IL; 181 177 182 - vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu)); 178 + kvm_inject_sync(vcpu, esr); 183 179 } 184 180 185 181 #define DFSR_FSC_EXTABT_LPAE 0x10