Skip to contentSkip to conversation

KVM: arm64: Fix parameter ordering for VBAR_EL1 assignment

PATCH Applied Fuad Tabba 2 participants 2 messages Sep 8, 2025

Subsystems (2)
lore
Share & tools
lore

Fuad Tabba

author
#0 lore raw

PATCH 1/1 KVM: arm64: Fix parameter ordering for VBAR_EL1 assignment

The __vcpu_assign_sys_reg() helper expects the register ID as the second argument and the value to be assigned as the third. However, the existing code was passing these parameters in the incorrect order.

Fix the function call to properly 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.

Fixes 798eb5978700 ("KVM: arm64: Sync protected guest VBAR_EL1 on injecting an undef exception")
---
 arch/arm64/kvm/hyp/nvhe/sys_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +1 -1
index 71d2fc97f004..82da9b03692d 100644
@@ -253,7 +253,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_assign_sys_reg(vcpu, read_sysreg_el1(SYS_VBAR), VBAR_EL1);
+	__vcpu_assign_sys_reg(vcpu, VBAR_EL1, read_sysreg_el1(SYS_VBAR));
 
 	kvm_pend_exception(vcpu, EXCEPT_AA64_EL1_SYNC);
 

base-commit: 76eeb9b8de9880ca38696b2fb56ac45ac0a25c6c

Signature · 1 line
2.51.0.355.g5224444f11-goog
Applied
#1 lore raw
Quoted 11 lines · Fuad Tabba

The __vcpu_assign_sys_reg() helper expects the register ID as the second argument and the value to be assigned as the third. However, the existing code was passing these parameters in the incorrect order.

Fix the function call to properly 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.

[...]

Applied to fixes, thanks!

[1/1] KVM: arm64: Fix parameter ordering for VBAR_EL1 assignment

      https://git.kernel.org/kvmarm/kvmarm/c/9f8073411c13

--
Best,
Oliver