Re: [PATCH v2 01/66] KVM: x86: Return -E2BIG when KVM_GET_SUPPORTED_CPUID hits max entries

Sean Christopherson
2020-03-03T15:17:25Z

On Tue, Mar 03, 2020 at 03:16:16PM +0100, Paolo Bonzini wrote:
> On 03/03/20 00:56, Sean Christopherson wrote:
> > (KVM hard caps CPUID 0xD at a single sub-leaf).
>
> Hmm... no it doesn't?
>
> for (idx = 1, i = 1; idx < 64; ++idx) {
> u64 mask = ((u64)1 << idx);
> if (*nent >= maxnent)
> goto out;
>
> do_host_cpuid(&entry[i], function, idx);
> if (idx == 1) {
> entry[i].eax &= kvm_cpuid_D_1_eax_x86_features;
> cpuid_mask(&entry[i].eax, CPUID_D_1_EAX);
> entry[i].ebx = 0;
> if (entry[i].eax & (F(XSAVES)|F(XSAVEC)))
> entry[i].ebx =
> xstate_required_size(supported,
> true);
> } else {
> if (entry[i].eax == 0 || !(supported & mask))
> continue;
> if (WARN_ON_ONCE(entry[i].ecx & 1))
> continue;
> }
> entry[i].ecx = 0;
> entry[i].edx = 0;
> ++*nent;
> ++i;
> }

Ah rats, I was thinking of CPUID 0x7 when I wrote that. Maybe just reword
it to "(KVM hard caps the number of CPUID 0xD sub-leafs)."?

> I still think the patch is correct, what matters is that no KVM in
> existence supports enough processor features to reach 100 or so subleaves.