All of lore.kernel.org
 help / color / mirror / Atom feed
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>
Subject: [PATCH 2/3] KVM: nSVM: Call svm_update_lbrv() outside nested_vmcb02_prepare_save()
Date: Sat,  5 Dec 2026 01:11:06 +0000	[thread overview]
Message-ID: <20261205011107.2050815-3-yosry@kernel.org> (raw)
In-Reply-To: <20261205011107.2050815-1-yosry@kernel.org>

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@kernel.org>
---
 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


  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 ` [PATCH 1/3] KVM: nSVM: Update virtual LBR state/intercepts on KVM_SET_NESTED_STATE Yosry Ahmed
2026-12-05  1:35   ` sashiko-bot
2026-12-05  1:11 ` Yosry Ahmed [this message]
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-3-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 \
    /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.