lkml.org 
[lkml]   [2020]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 16/61] KVM: x86: Encapsulate CPUID entries and metadata in struct
On Fri, Feb 21, 2020 at 03:58:47PM +0100, Vitaly Kuznetsov wrote:
> Sean Christopherson <sean.j.christopherson@intel.com> writes:
>
> > @@ -539,7 +549,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
> > entry->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT;
> >
> > for (i = 1, max_idx = entry->eax & 0xff; i < max_idx; ++i) {
> > - if (!do_host_cpuid(&entry[i], nent, maxnent, function, 0))
> > + entry = do_host_cpuid(array, 2, 0);
>
> I'd change this to
> entry = do_host_cpuid(array, function, 0);
>
> to match other call sites.

Done. That did look weird, no idea why I decided to hardcode only this one.

> > + if (!entry)
> > goto out;
> > }
> > break;
> > @@ -802,22 +814,22 @@ static inline int __do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 function,
> > return r;
> > }
> >
> > -static int do_cpuid_func(struct kvm_cpuid_entry2 *entry, u32 func,
> > - int *nent, int maxnent, unsigned int type)
> > +static int do_cpuid_func(struct kvm_cpuid_array *array, u32 func,
> > + unsigned int type)
> > {
> > - if (*nent >= maxnent)
> > + if (array->nent >= array->maxnent)
> > return -E2BIG;
> >
> > if (type == KVM_GET_EMULATED_CPUID)
> > - return __do_cpuid_func_emulated(entry, func, nent, maxnent);
> > + return __do_cpuid_func_emulated(array, func);
>
> Would it make sense to move 'if (array->nent >= array->maxnent)' check
> to __do_cpuid_func_emulated() to match do_host_cpuid()?

I considered doing exactly that. IIRC, I opted not to because at this
point in the series, the initial call to do_host_cpuid() is something like
halfway down the massive __do_cpuid_func(), and eliminating the early check
didn't feel quite right, e.g. there is a fair amount of unnecessary code
that runs before hitting the first do_host_cpuid().

What if I add a patch towards the end of the series to move this check into
__do_cpuid_func_emulated(), i.e. after __do_cpuid_func() has been trimmed
down to size and the early check really is superfluous.

\
 
 \ /
  Last update: 2020-02-24 22:57    [W:0.110 / U:2.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site