Messages in this thread | | | Date | Wed, 13 Feb 2013 15:23:42 -0800 | From | "H. Peter Anvin" <> | Subject | Re: [RFC PATCH 1/4] x86, cpu: Expand cpufeature facility to include cpu bugs |
| |
On 02/11/2013 03:18 AM, Borislav Petkov wrote: > > +#define __BUG_CHECK_BIT(bit) \ > +({ \ > + WARN_ON(bit >> 5 < NCAPINTS); \ > + bit; \ > +}) > +
Do we need this? Either way, if we do, I would suggest doing something like:
if (__builtin_constant_p(bit)) bad_bug_number();
... and flag bad_bug_number as a compile time error, since the vast majority of the time the bit number will be constant.
However, I don't think it is necessary. In order for this to ever trigger someone must have known they were testing for a bug, and yet not used the X86_BUG_ macros, which seems very unlikely.
> #define X86_BUG_F00F (NCAPINTS*32+ 0) /* Intel F00F bug */ > #define X86_BUG_FDIV (NCAPINTS*32+ 1) /* FPU FDIV bug */ > +#define X86_BUG_COMA (NCAPINTS*32+ 2) /* Cyrix 6x86 coma */
Just to make it a bit cleaner once we have more than one word of bug tests, I would suggest macroizing this:
#define X86_BUG(x) (NCAPINTS*32 + (x))
... and then just ...
#define X86_BUG_F00F X86_BUG(0) #define X86_BUG_FDIV X86_BUG(1)
... and so on.
The only reason we *don't* do that with the features is that they tend to come chunkwise in the form of CPUID words.
-hpa
| |