Re: [PATCH v2 40/49] KVM: x86: Initialize guest cpu_caps based on KVM support

From: Sean Christopherson
Date: Mon Jul 29 2024 - 11:35:06 EST


On Wed, Jul 24, 2024, Maxim Levitsky wrote:
> On Mon, 2024-07-08 at 17:10 -0700, Sean Christopherson wrote:
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index 0e64a6332052..dbc3f6ce9203 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -448,7 +448,7 @@ void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
> > if (!entry)
> > continue;
> >
> > - cpuid_func_emulated(&emulated, cpuid.function);
> > + cpuid_func_emulated(&emulated, cpuid.function, false);
> >
> > /*
> > * A vCPU has a feature if it's supported by KVM and is enabled
> > @@ -1034,7 +1034,8 @@ static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
> > return entry;
> > }
> >
> > -static int cpuid_func_emulated(struct kvm_cpuid_entry2 *entry, u32 func)
> > +static int cpuid_func_emulated(struct kvm_cpuid_entry2 *entry, u32 func,
> > + bool only_advertised)
>
> I'll say, lets call this boolean, 'include_partially_emulated',
> (basically features that kvm emulates but only partially,
> and thus doesn't advertise, aka mwait)
>
> and then it doesn't look that bad, assuming that comes with a comment.

Works for me. I was trying to figure out a way to say "emulated_on_ud", but I
can't get the polarity right, at least not without ridiculous verbosity. E.g.
include_not_emulated_on_ud is awful.