[PATCH 3/3] KVM: nSVM: Explicitly initialize misc_ctl2 in vmcb02

From: Yosry Ahmed

Date: Fri Dec 04 2026 - 20:11:37 EST


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@xxxxxxxxxx>
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 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