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 3/3] KVM: nSVM: Explicitly initialize misc_ctl2 in vmcb02
Date: Sat,  5 Dec 2026 01:11:07 +0000	[thread overview]
Message-ID: <20261205011107.2050815-4-yosry@kernel.org> (raw)
In-Reply-To: <20261205011107.2050815-1-yosry@kernel.org>

misc_ctl2 is currently not fully initialized on nested VMRUN when
preparing vmcb02. nested_vmcb02_prepare_control() sets
ENABLE_V_VMLOAD_VMSAVE if L1 enables VLS (and is allowed to), but it
never clears the bit. Instead, it relies on
nested_vmcb02_recalc_intercepts() setting VMSAVE/VMLOAD intercepts
otherwise, which renders enabling VLS ineffective.

The only other bit that KVM ever sets is ENABLE_V_LBR, and it relies on
svm_update_lbrv() to explicitly set it or clear it after vmcb02 is set
up.

Explicitly clear misc_ctl2 when preparing vmcb02 for better hygiene, and
to harden against accidentally leaving bits set across different nested
VMRUNs when they shouldn't be.

Suggested-by: Sean Christopherson <seanjc@google.com>
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 44afa4068e05b..c4ac245a49cf8 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -990,7 +990,7 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm)
 	}
 
 	/* SVM_MISC2_ENABLE_V_LBR is controlled by svm_update_lbrv() */
-
+	vmcb02->control.misc_ctl2 = 0;
 	if (!nested_vmcb_needs_vls_intercept(svm))
 		vmcb02->control.misc_ctl2 |= SVM_MISC2_ENABLE_V_VMLOAD_VMSAVE;
 
-- 
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 ` [PATCH 2/3] KVM: nSVM: Call svm_update_lbrv() outside nested_vmcb02_prepare_save() Yosry Ahmed
2026-12-05  1:11 ` Yosry Ahmed [this message]

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-4-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.