Re: [PATCH RFC 0/2] KVM: x86: allow for more CPUID entries

From: Dr. David Alan Gilbert
Date: Wed Sep 16 2020 - 04:34:14 EST


* Wei Huang (wei.huang2@xxxxxxx) wrote:
> On 09/15 05:51, Dr. David Alan Gilbert wrote:
> > * Vitaly Kuznetsov (vkuznets@xxxxxxxxxx) wrote:
> > > With QEMU and newer AMD CPUs (namely: Epyc 'Rome') the current limit for
>
> Could you elaborate on this limit? On Rome, I counted ~35 CPUID functions which
> include Fn0000_xxxx, Fn4000_xxxx and Fn8000_xxxx.

On my 7302P the output of:
cpuid -1 -r | wc -l

is 61, there is one line of header in there.

However in a guest I see more; and I think that's because KVM tends to
list the CPUID entries for a lot of disabled Intel features, even on
AMD, e.g. 0x11-0x1f which AMD doesn't have, are listed in a KVM guest.
Then you add the KVM CPUIDs at 4...0 and 4....1.

IMHO we should be filtering those out for at least two reasons:
a) They're wrong
b) We're probably not keeping the set of visible CPUID fields the same
when we move between host kernels, and that can't be good for
migration.

Still, those are separate problems.

Dave

> > > KVM_MAX_CPUID_ENTRIES(80) is reported to be hit. Last time it was raised
> > > from '40' in 2010. We can, of course, just bump it a little bit to fix
> > > the immediate issue but the report made me wonder why we need to pre-
> > > allocate vcpu->arch.cpuid_entries array instead of sizing it dynamically.
> > > This RFC is intended to feed my curiosity.
> > >
> > > Very mildly tested with selftests/kvm-unit-tests and nothing seems to
> > > break. I also don't have access to the system where the original issue
> > > was reported but chances we're fixing it are very good IMO as just the
> > > second patch alone was reported to be sufficient.
> > >
> > > Reported-by: Dr. David Alan Gilbert <dgilbert@xxxxxxxxxx>
> >
> > Oh nice, I was just going to bump the magic number :-)
> >
> > Anyway, this seems to work for me, so:
> >
> > Tested-by: Dr. David Alan Gilbert <dgilbert@xxxxxxxxxx>
> >
>
> I tested on two platforms and the patches worked fine. So no objection on the
> design.
>
> Tested-by: Wei Huang <wei.huang2@xxxxxxx>
>
> > > Vitaly Kuznetsov (2):
> > > KVM: x86: allocate vcpu->arch.cpuid_entries dynamically
> > > KVM: x86: bump KVM_MAX_CPUID_ENTRIES
> > >
> > > arch/x86/include/asm/kvm_host.h | 4 +--
> > > arch/x86/kvm/cpuid.c | 55 ++++++++++++++++++++++++---------
> > > arch/x86/kvm/x86.c | 1 +
> > > 3 files changed, 43 insertions(+), 17 deletions(-)
> > >
> > > --
> > > 2.25.4
> > >
> > --
> > Dr. David Alan Gilbert / dgilbert@xxxxxxxxxx / Manchester, UK
> >
>
--
Dr. David Alan Gilbert / dgilbert@xxxxxxxxxx / Manchester, UK