From: "Xin Li (Intel)" <[email protected]>

Permit use of VMX FRED controls in nested VMX now that support for nested
FRED is implemented.

Signed-off-by: Xin Li (Intel) <[email protected]>
Signed-off-by: Sohil Mehta <[email protected]>
Reviewed-by: Chao Gao <[email protected]>
---
v10:
 - Remove an obsolete comment (Chao).
---
 arch/x86/kvm/vmx/nested.c | 10 +++-------
 arch/x86/kvm/vmx/vmx.c    |  1 +
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 3e0a1ed6440d..4fad9728a2ea 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -7371,12 +7371,8 @@ static void nested_vmx_setup_exit_ctls(struct 
vmcs_config *vmcs_conf,
 
        if (msrs->exit_ctls_high & VM_EXIT_ACTIVATE_SECONDARY_CONTROLS) {
                msrs->secondary_exit_ctls = vmcs_conf->vmexit_2nd_ctrl;
-               /*
-                * As the secondary VM exit control is always loaded, do not
-                * advertise any feature in it to nVMX until its nVMX support
-                * is ready.
-                */
-               msrs->secondary_exit_ctls &= 0;
+               msrs->secondary_exit_ctls &= SECONDARY_VM_EXIT_SAVE_IA32_FRED |
+                                            SECONDARY_VM_EXIT_LOAD_IA32_FRED;
        }
 }
 
@@ -7392,7 +7388,7 @@ static void nested_vmx_setup_entry_ctls(struct 
vmcs_config *vmcs_conf,
                VM_ENTRY_IA32E_MODE |
 #endif
                VM_ENTRY_LOAD_IA32_PAT | VM_ENTRY_LOAD_BNDCFGS |
-               VM_ENTRY_LOAD_CET_STATE;
+               VM_ENTRY_LOAD_CET_STATE | VM_ENTRY_LOAD_IA32_FRED;
        msrs->entry_ctls_high |=
                (VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER |
                 VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL);
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 3a3315a7fc11..f673cd4e8956 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -8150,6 +8150,7 @@ static void nested_vmx_cr_fixed1_bits_update(struct 
kvm_vcpu *vcpu)
 
        entry = kvm_find_cpuid_entry_index(vcpu, 0x7, 1);
        cr4_fixed1_update(X86_CR4_LAM_SUP,    eax, feature_bit(LAM));
+       cr4_fixed1_update(X86_CR4_FRED,       eax, feature_bit(FRED));
 
 #undef cr4_fixed1_update
 }
-- 
2.43.0


Reply via email to