On Sun, Oct 26, 2025 at 01:19:10PM -0700, Xin Li (Intel) wrote:
>From: Xin Li <xin3.li@intel.com>
>
>Permit use of VMX FRED controls in nested VMX now that support for nested
>FRED is implemented.
>
>Signed-off-by: Xin Li <xin3.li@intel.com>
>Signed-off-by: Xin Li (Intel) <xin@zytor.com>
>Tested-by: Shan Kang <shan.kang@intel.com>
>Tested-by: Xuelian Guo <xuelian.guo@intel.com>
Reviewed-by: Chao Gao <chao.gao@intel.com>
>---
>
>Change in v5:
>* Add TB from Xuelian Guo.
>---
> arch/x86/kvm/vmx/nested.c | 5 +++--
> arch/x86/kvm/vmx/vmx.c | 1 +
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
>index 37ab8250dd31..655257b34d15 100644
>--- a/arch/x86/kvm/vmx/nested.c
>+++ b/arch/x86/kvm/vmx/nested.c
>@@ -7397,7 +7397,8 @@ static void nested_vmx_setup_exit_ctls(struct vmcs_config *vmcs_conf,
> * advertise any feature in it to nVMX until its nVMX support
> * is ready.
> */
Shouldn't this comment be removed? I suppose it was a note to reviewers
explaining why it's hard-coded to 0. Since some features have been added, the
comment can be dropped.
>- msrs->secondary_exit_ctls &= 0;
>+ msrs->secondary_exit_ctls &= SECONDARY_VM_EXIT_SAVE_IA32_FRED |
>+ SECONDARY_VM_EXIT_LOAD_IA32_FRED;
> }
> }
>
>@@ -7413,7 +7414,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 04442f869abb..8f3805a71a97 100644
>--- a/arch/x86/kvm/vmx/vmx.c
>+++ b/arch/x86/kvm/vmx/vmx.c
>@@ -7994,6 +7994,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.51.0
>