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: pkvm: Add a generic synchronous exception injection primitive

Similarly to the "classic" KVM code, pKVM doesn't have an "anything
goes" synchronous exception injection primitive.

Carve one out of the UNDEF injection code.

Link: https://patch.msgid.link/20260108173233.2911955-8-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>

+15 -7
+15 -7
arch/arm64/kvm/hyp/nvhe/sys_regs.c
··· 243 243 } 244 244 } 245 245 246 - /* 247 - * Inject an unknown/undefined exception to an AArch64 guest while most of its 248 - * sysregs are live. 249 - */ 250 - static void inject_undef64(struct kvm_vcpu *vcpu) 246 + static void inject_sync64(struct kvm_vcpu *vcpu, u64 esr) 251 247 { 252 - u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT); 253 - 254 248 *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR); 255 249 *vcpu_cpsr(vcpu) = read_sysreg_el2(SYS_SPSR); 250 + 251 + /* 252 + * Make sure we have the latest update to VBAR_EL1, as pKVM 253 + * handles traps very early, before sysregs are resync'ed 254 + */ 256 255 __vcpu_assign_sys_reg(vcpu, VBAR_EL1, read_sysreg_el1(SYS_VBAR)); 257 256 258 257 kvm_pend_exception(vcpu, EXCEPT_AA64_EL1_SYNC); ··· 262 263 write_sysreg_el1(read_sysreg_el2(SYS_ELR), SYS_ELR); 263 264 write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR); 264 265 write_sysreg_el2(*vcpu_cpsr(vcpu), SYS_SPSR); 266 + } 267 + 268 + /* 269 + * Inject an unknown/undefined exception to an AArch64 guest while most of its 270 + * sysregs are live. 271 + */ 272 + static void inject_undef64(struct kvm_vcpu *vcpu) 273 + { 274 + inject_sync64(vcpu, (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT)); 265 275 } 266 276 267 277 static u64 read_id_reg(const struct kvm_vcpu *vcpu,