]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: nVMX: Setup VMX MSRs on loading CPU during nested_vmx_hardware_setup()
authorSean Christopherson <seanjc@google.com>
Thu, 15 Jan 2026 17:34:24 +0000 (09:34 -0800)
committerSean Christopherson <seanjc@google.com>
Fri, 16 Jan 2026 15:47:59 +0000 (07:47 -0800)
Move the call to nested_vmx_setup_ctls_msrs() from vmx_hardware_setup() to
nested_vmx_hardware_setup() so that the nested code can deal with ordering
dependencies without having to straddle vmx_hardware_setup() and
nested_vmx_hardware_setup().  Specifically, an upcoming change will
sanitize the vmcs12 fields based on hardware support, and that code needs
to run _before_ the MSRs are configured, because the lovely vmcs_enum MSR
depends on the max support vmcs12 field.

No functional change intended.

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://patch.msgid.link/20260115173427.716021-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/vmx/vmx.c

index 6137e5307d0f6c319a62b9c1d2e6af080091c871..61113ead3d7bd2e759c26a116c401e57034ad381 100644 (file)
@@ -7407,6 +7407,8 @@ __init int nested_vmx_hardware_setup(int (*exit_handlers[])(struct kvm_vcpu *))
 {
        int i;
 
+       nested_vmx_setup_ctls_msrs(&vmcs_config, vmx_capability.ept);
+
        if (!cpu_has_vmx_shadow_vmcs())
                enable_shadow_vmcs = 0;
        if (enable_shadow_vmcs) {
index ccca182a346d286c4e075ba5ad4538eb6ac9ac84..8438799eed741b0c878cff047a2eac9a4baa7829 100644 (file)
@@ -8700,8 +8700,6 @@ __init int vmx_hardware_setup(void)
         * can hide/show features based on kvm_cpu_cap_has().
         */
        if (nested) {
-               nested_vmx_setup_ctls_msrs(&vmcs_config, vmx_capability.ept);
-
                r = nested_vmx_hardware_setup(kvm_vmx_exit_handlers);
                if (r)
                        return r;