* [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE
[not found] <20261205011107.2050815-1-yosry@kernel.org>
@ 2026-12-05 1:11 ` Yosry Ahmed
0 siblings, 0 replies; only message in thread
From: Yosry Ahmed @ 2026-12-05 1:11 UTC (permalink / raw)
To: Sean Christopherson
Cc: Paolo Bonzini, kvm, linux-kernel, Yosry Ahmed, stable,
Ulfar Erlingsson
KVM calls svm_update_lbrv() to check if virtual LBR (i.e.
SVM_MISC2_ENABLE_V_LBR) needs to be enabled in the VMCB and update the
intercepts accordingly on nested transitions, and when
MSR_IA32_DEBUGCTLMSR is updated.
During live migration, if MSR_IA32_DEBUGCTLMSR is restored before nested
state, and the vCPU is restored into guest mode, svm_update_lbrv() is
not called again to recompute virtual LBR state after vmcb02 is updated
(e.g. to account for L1 enabling/disabling virtual LBR).
Call svm_update_lbrv() after updating vmcb02 in the restore path to
set up virtual LBR accordingly.
Fixes: 8a4821412cf2 ("KVM: nSVM: Fix and simplify LBR virtualization handling with nested")
Cc: stable@vger.kernel.org
Reported-by: Ulfar Erlingsson <ulfar@google.com>
Reported-by: Sean Christopherson <seanjc@google.com>
Closes: https://lore.kernel.org/kvm/atpGGKVAL3bAnmnk@google.com/
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
---
arch/x86/kvm/svm/nested.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 81d768ec82419..c5a572b58be07 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -2091,6 +2091,12 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
nested_vmcb02_prepare_control(svm);
+ /*
+ * Update virtual LBR state after setting up vmcb02's control area in
+ * case DEBUGCTLMSR was already restored.
+ */
+ svm_update_lbrv(vcpu);
+
/*
* Any previously restored state (e.g. KVM_SET_SREGS) would mark fields
* dirty in vmcb01 instead of vmcb02, so mark all of vmcb02 dirty here.
--
2.56.1.987.g2ec0ab4260-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-05 1:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261205011107.2050815-1-yosry@kernel.org>
2026-12-05 1:11 ` [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE Yosry Ahmed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox