[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57ef4cd4-dfb8-256b-dc88-3f57c43dfe89@intel.com>
Date: Tue, 27 Aug 2019 09:33:11 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Borislav Petkov <bp@...en8.de>, Cao jin <caoj.fnst@...fujitsu.com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, tglx@...utronix.de,
mingo@...hat.com, hpa@...or.com
Subject: Re: [PATCH] x86/cpufeature: drop *_MASK_CEHCK
On 8/27/19 12:41 AM, Borislav Petkov wrote:
>> #define DISABLED_MASK_BIT_SET(feature_bit) \
>> @@ -104,7 +103,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
>> CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \
>> CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \
>> CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \
>> - DISABLED_MASK_CHECK || \
>> BUILD_BUG_ON_ZERO(NCAPINTS != 19))
>>
>> #define cpu_has(c, bit) \
> If you do a little bit of git archeology:
>
> $ git annotate arch/x86/include/asm/cpufeature.h
>
> after a while, you'll see that this was added in:
>
> 1e61f78baf89 ("x86/cpufeature: Make sure DISABLED/REQUIRED macros are updated")
>
> and then you could Cc Dave and ask what he was thinking then?
>
> Leaving in the rest for reference.
The point was that there are 5 files in the code that need to be changed
if you change NCAPINTS:
1. arch/x86/include/asm/required-features.h
2. arch/x86/include/asm/disabled-features.h
3. tools/arch/x86/include/asm/disabled-features.h
4. tools/arch/x86/include/asm/required-features.h
5. arch/x86/include/asm/cpufeature.h (2 sites)
Each of those sites has a compile-time check for NCAPINTS. The problem
is that the *-features.h code doesn't get compiled directly so a
BUILD_BUG_ON() doesn't work by itself. So, for the sites there, we put
it somewhere that *will* get compiled: the macros that actually check
the bits.
It looks weird, but the end effect is good: If you change NCAPINTS, you
get compile errors in 5 files and have to go edit those 5 files to fix
it. Your patch makes it easier to introduce errors and miss one of
those sites.
Powered by blists - more mailing lists