[PATCH 2/3] KVM: nSVM: Call svm_update_lbrv() outside nested_vmcb02_prepare_save()
From: Yosry Ahmed
Date: Fri Dec 04 2026 - 20:11:39 EST
svm_update_lbrv() must be called after both the save and control areas
of vmcb02 are set up as it uses fields from both areas. In the nested
VMRUN path, it is called at the end of nested_vmcb02_prepare_save().
Move it to its only caller, enter_svm_guest_mode(), to make it more
obvious and consistent with svm_set_nested_state().
No functional change intended.
Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
---
arch/x86/kvm/svm/nested.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index c5a572b58be07..44afa4068e05b 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -821,7 +821,6 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm)
svm_copy_lbrs(&vmcb02->save, &vmcb01->save);
}
vmcb_mark_dirty(vmcb02, VMCB_LBR);
- svm_update_lbrv(&svm->vcpu);
}
static inline bool is_evtinj_soft(u32 evtinj)
@@ -1070,6 +1069,7 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, bool from_vmrun)
svm_switch_vmcb(svm, &svm->nested.vmcb02);
nested_vmcb02_prepare_control(svm);
nested_vmcb02_prepare_save(svm);
+ svm_update_lbrv(vcpu);
ret = nested_svm_load_cr3(&svm->vcpu, svm->nested.save.cr3,
nested_npt_enabled(svm), from_vmrun);
--
2.56.1.987.g2ec0ab4260-goog