Skip to content

Commit 19f7567

Browse files
author
Marc Zyngier
committed
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>
1 parent 1ad9767 commit 19f7567

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ bool kvm_condition_valid32(const struct kvm_vcpu *vcpu);
4545
void kvm_skip_instr32(struct kvm_vcpu *vcpu);
4646

4747
void kvm_inject_undefined(struct kvm_vcpu *vcpu);
48+
void kvm_inject_sync(struct kvm_vcpu *vcpu, u64 esr);
4849
int kvm_inject_serror_esr(struct kvm_vcpu *vcpu, u64 esr);
4950
int kvm_inject_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr);
5051
void kvm_inject_size_fault(struct kvm_vcpu *vcpu);

arch/arm64/kvm/inject_fault.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,24 @@ static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr
162162
vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu));
163163
}
164164

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+
165171
static void inject_undef64(struct kvm_vcpu *vcpu)
166172
{
167173
u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT);
168174

169-
pend_sync_exception(vcpu);
170-
171175
/*
172176
* Build an unknown exception, depending on the instruction
173177
* set.
174178
*/
175179
if (kvm_vcpu_trap_il_is32bit(vcpu))
176180
esr |= ESR_ELx_IL;
177181

178-
vcpu_write_sys_reg(vcpu, esr, exception_esr_elx(vcpu));
182+
kvm_inject_sync(vcpu, esr);
179183
}
180184

181185
#define DFSR_FSC_EXTABT_LPAE 0x10

0 commit comments

Comments
 (0)