Re: [PATCH v1 05/23] KVM: VMX: Initialize FRED VM entry/exit controls in vmcs_config

From: Sean Christopherson
Date: Fri Nov 10 2023 - 13:21:26 EST


On Fri, Nov 10, 2023, Xin3 Li wrote:
> > > >+ if (cpu_feature_enabled(X86_FEATURE_FRED) &&
> > > >+ !(_vmentry_control & VM_ENTRY_LOAD_IA32_FRED)) {
> > > >+ pr_warn_once("FRED enabled but no VMX VM-Entry
> > LOAD_IA32_FRED control: %x\n",
> > > >+ _vmentry_control);
> > >
> > > Can we just hide FRED from guests like what KVM does for other
> > > features which have similar dependencies? see vmx_set_cpu_caps().
> >
> > Both of these warnings should simply be dropped. The
> > error_on_inconsistent_vmcs_config stuff is for inconsistencies within the allowed
> > VMCS fields. Having a feature that is supported in bare metal but not virtualized
> > is perfectly legal, if uncommon.
>
> I deliberately keep it, at least for now, because these checks are helpful
> during the development of nVMX FRED. It will be helpful for other VMMs
> being developed/tested on KVM.

No, remove it. It's architecturally legal for a CPU to support a feature in bare
metal but not provide virtualization support.

> > What *is* needed is for KVM to refuse to virtualize FRED if the entry/exit controls
> > aren't consistent. E.g. if at least one control is present, and at least one
> > control is missing. I.e. KVM needs a version of vmcs_entry_exit_pairs that can
> > deal with SECONDAY_VM_EXIT controls.
>
> I agree there are better ways. But maybe after or before VMX FRED.

Uh, no. This is not optional. FRED is the first feature that uses SECONDAY_VM_EXIT
controls, so FRED gets the honor of adding the necessary infrastructure support.