Re: [RFC PATCH 2/3] x86/cpufeatures: Combine word 11 and 12 into new scattered features word 11

From: Borislav Petkov
Date: Fri Jun 14 2019 - 08:32:46 EST


On Fri, Jun 14, 2019 at 01:44:10PM +0200, Borislav Petkov wrote:
> On Thu, Jun 13, 2019 at 01:51:03PM -0700, Fenghua Yu wrote:
> > It's a waste for the four X86_FEATURE_CQM_* features to occupy two
> > pure feature bits words. To better utilize feature words, re-define
> > word 11 to host scattered features and move the four X86_FEATURE_CQM_*
> > features into word 11. More scattered features can be added in word 11
> > in the future.
> >
> > KVM doesn't support resctrl now. So it's safe to move the
> > X86_FEATURE_CQM_* features to scattered features word 11 for KVM.
> >
> > Signed-off-by: Fenghua Yu <fenghua.yu@xxxxxxxxx>
>
> ...
>
> > diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
> > index 9a327d5b6d1f..d78a61408243 100644
> > --- a/arch/x86/kvm/cpuid.h
> > +++ b/arch/x86/kvm/cpuid.h
> > @@ -47,8 +47,6 @@ static const struct cpuid_reg reverse_cpuid[] = {
> > [CPUID_8000_0001_ECX] = {0x80000001, 0, CPUID_ECX},
> > [CPUID_7_0_EBX] = { 7, 0, CPUID_EBX},
> > [CPUID_D_1_EAX] = { 0xd, 1, CPUID_EAX},
> > - [CPUID_F_0_EDX] = { 0xf, 0, CPUID_EDX},
> > - [CPUID_F_1_EDX] = { 0xf, 1, CPUID_EDX},
>
> I think you're going to have to change those to:
>
> [CPUID_LNX_4] = { 0, 0, 0},
> [CPUID_7_1_EAX] = { 7, 1, CPUID_EAX },
>
> instead of removing them because kvm is basically hardcoding the feature
> words and then bitches when array elements in the middle get removed:

Alternatively - and what I think is the better solution - would be to
remove those BUILD_BUG_ONs in x86_feature_cpuid and filter out the
Linux-defined leafs dynamically. This way the array won't have holes in
it.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.