Skip to content

Commit 4687a2c

Browse files
committed
KVM: VMX: Setup canonical VMCS config prior to kvm_x86_vendor_init()
Setup the golden VMCS config during vmx_init(), before the call to kvm_x86_vendor_init(), instead of waiting until the callback to do hardware setup. setup_vmcs_config() only touches VMX state, i.e. doesn't poke anything in kvm.ko, and has no runtime dependencies beyond hv_init_evmcs(). Setting the VMCS config early on will allow referencing VMCS and VMX capabilities at any point during setup, e.g. to check for PERF_GLOBAL_CTRL save/load support during mediated PMU initialization. Tested-by: Xudong Hao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 5b5133e commit 4687a2c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

arch/x86/kvm/vmx/vmx.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8359,8 +8359,6 @@ __init int vmx_hardware_setup(void)
83598359

83608360
vmx_setup_user_return_msrs();
83618361

8362-
if (setup_vmcs_config(&vmcs_config, &vmx_capability) < 0)
8363-
return -EIO;
83648362

83658363
if (boot_cpu_has(X86_FEATURE_NX))
83668364
kvm_enable_efer_bits(EFER_NX);
@@ -8584,11 +8582,18 @@ int __init vmx_init(void)
85848582
return -EOPNOTSUPP;
85858583

85868584
/*
8587-
* Note, hv_init_evmcs() touches only VMX knobs, i.e. there's nothing
8588-
* to unwind if a later step fails.
8585+
* Note, VMCS and eVMCS configuration only touch VMX knobs/variables,
8586+
* i.e. there's nothing to unwind if a later step fails.
85898587
*/
85908588
hv_init_evmcs();
85918589

8590+
/*
8591+
* Parse the VMCS config and VMX capabilities before anything else, so
8592+
* that the information is available to all setup flows.
8593+
*/
8594+
if (setup_vmcs_config(&vmcs_config, &vmx_capability) < 0)
8595+
return -EIO;
8596+
85928597
r = kvm_x86_vendor_init(&vt_init_ops);
85938598
if (r)
85948599
return r;

0 commit comments

Comments
 (0)