From: Yosry Ahmed <yosry@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Yosry Ahmed <yosry@kernel.org>,
stable@vger.kernel.org, Ulfar Erlingsson <ulfar@google.com>
Subject: [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE
Date: Sat, 5 Dec 2026 01:11:05 +0000 [thread overview]
Message-ID: <20261205011107.2050815-2-yosry@kernel.org> (raw)
In-Reply-To: <20261205011107.2050815-1-yosry@kernel.org>
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
next prev parent reply other threads:[~2026-12-05 1:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 1:11 [PATCH 0/3] KVM: nSVM: Nested virtual LBR fix and cleanups Yosry Ahmed
2026-12-05 1:11 ` Yosry Ahmed [this message]
2026-12-05 1:35 ` [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE sashiko-bot
2026-12-05 1:11 ` [PATCH 2/3] KVM: nSVM: Call svm_update_lbrv() outside nested_vmcb02_prepare_save() Yosry Ahmed
2026-12-05 1:11 ` [PATCH 3/3] KVM: nSVM: Explicitly initialize misc_ctl2 in vmcb02 Yosry Ahmed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261205011107.2050815-2-yosry@kernel.org \
--to=yosry@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=ulfar@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.