Skip to content

Commit b510ef2

Browse files
Fuad Tabbawinzkh
authored andcommitted
BACKPORT: FROMGIT: KVM: arm64: Sync protected guest VBAR_EL1 on injecting an undef exception
In pKVM, a race condition can occur if a guest updates its VBAR_EL1 register and, before a vCPU exit synchronizes this change, the hypervisor needs to inject an undefined exception into a protected guest. In this scenario, the vCPU still holds the stale VBAR_EL1 value from before the guest's update. When pKVM injects the exception, it ends up using the stale value. Explicitly read the live value of VBAR_EL1 from the guest and update the vCPU value immediately before pending the exception. This ensures the vCPU's value is the same as the guest's and that the exception will be handled at the correct address upon resuming the guest. Bug: 435160789 (cherry picked from commit 798eb597870064bff28d8a41cb5197725f7dc6f2 https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git fixes) Reported-by: Keir Fraser <[email protected]> Change-Id: I85a6106392e4af581f1cb57813f3fc1acd6b0463 Signed-off-by: Fuad Tabba <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 90ff386 commit b510ef2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

arch/arm64/kvm/hyp/nvhe/sys_regs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void inject_undef64(struct kvm_vcpu *vcpu)
3838

3939
*vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR);
4040
*vcpu_cpsr(vcpu) = read_sysreg_el2(SYS_SPSR);
41+
__vcpu_sys_reg(vcpu, VBAR_EL1) = read_sysreg_el1(SYS_VBAR);
4142

4243
kvm_pend_exception(vcpu, EXCEPT_AA64_EL1_SYNC);
4344

0 commit comments

Comments
 (0)