diff mbox series

[v1,11/12] KVM: arm64: Update vcpu state with live value of VBAR_EL1 on injecting an exception

Message ID 20241120105254.2842020-12-tabba@google.com (mailing list archive)
State New
Headers show
Series KVM: arm64: Rework guest VM fixed feature handling and trapping in pKVM | expand

Commit Message

Fuad Tabba Nov. 20, 2024, 10:52 a.m. UTC
If the injection happens early, when VBAR_EL1 has just been set,
it's value wouldn't be up to date in the vcpu structure,
resulting in it being clobbered before returning to the guest
with the injected exception, which the guest wouldn't be able to
handle properly. Although this probably means that the guest
cannot properly run, this behavior is unexpected and makes
debugging harder.

Signed-off-by: Fuad Tabba <tabba@google.com>
---
 arch/arm64/kvm/hyp/nvhe/sys_regs.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
index 17783c8ddb92..54f23d9fea18 100644
--- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c
+++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
@@ -250,6 +250,7 @@  static void inject_undef64(struct kvm_vcpu *vcpu)
 
 	*vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR);
 	*vcpu_cpsr(vcpu) = read_sysreg_el2(SYS_SPSR);
+	vcpu_write_sys_reg(vcpu, read_sysreg(VBAR_EL1), VBAR_EL1);
 
 	kvm_pend_exception(vcpu, EXCEPT_AA64_EL1_SYNC);