Skip to content

Commit 496c917

Browse files
Yu Zhangsean-jc
authored andcommitted
KVM: nVMX: Simplify the setting of SECONDARY_EXEC_ENABLE_VMFUNC for nested.
Values of base settings for nested proc-based VM-Execution control MSR come from the ones for non-nested. And for SECONDARY_EXEC_ENABLE_VMFUNC flag, KVM currently a) first mask off it from vmcs_conf->cpu_based_2nd_exec_ctrl; b) then check it against the same source; c) and reset it again if host has it. So just simplify this, by not masking off SECONDARY_EXEC_ENABLE_VMFUNC in the first place. No functional change. Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com> Link: https://lore.kernel.org/r/20221109075413.1405803-3-yu.c.zhang@linux.intel.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 41acdd4 commit 496c917

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6880,6 +6880,7 @@ void nested_vmx_setup_ctls_msrs(struct vmcs_config *vmcs_conf, u32 ept_caps)
68806880
SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
68816881
SECONDARY_EXEC_RDRAND_EXITING |
68826882
SECONDARY_EXEC_ENABLE_INVPCID |
6883+
SECONDARY_EXEC_ENABLE_VMFUNC |
68836884
SECONDARY_EXEC_RDSEED_EXITING |
68846885
SECONDARY_EXEC_XSAVES |
68856886
SECONDARY_EXEC_TSC_SCALING |
@@ -6912,18 +6913,13 @@ void nested_vmx_setup_ctls_msrs(struct vmcs_config *vmcs_conf, u32 ept_caps)
69126913
SECONDARY_EXEC_ENABLE_PML;
69136914
msrs->ept_caps |= VMX_EPT_AD_BIT;
69146915
}
6915-
}
69166916

6917-
if (cpu_has_vmx_vmfunc()) {
6918-
msrs->secondary_ctls_high |=
6919-
SECONDARY_EXEC_ENABLE_VMFUNC;
69206917
/*
6921-
* Advertise EPTP switching unconditionally
6922-
* since we emulate it
6918+
* Advertise EPTP switching irrespective of hardware support,
6919+
* KVM emulates it in software so long as VMFUNC is supported.
69236920
*/
6924-
if (enable_ept)
6925-
msrs->vmfunc_controls =
6926-
VMX_VMFUNC_EPTP_SWITCHING;
6921+
if (cpu_has_vmx_vmfunc())
6922+
msrs->vmfunc_controls = VMX_VMFUNC_EPTP_SWITCHING;
69276923
}
69286924

69296925
/*

0 commit comments

Comments
 (0)