]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
x86, cpu: Expand cpufeature facility to include cpu bugs
authorBorislav Petkov <bp@suse.de>
Wed, 20 Mar 2013 14:07:23 +0000 (15:07 +0100)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 2 Apr 2013 17:12:52 +0000 (10:12 -0700)
We add another 32-bit vector at the end of the ->x86_capability
bitvector which collects bugs present in CPUs. After all, a CPU bug is a
kind of a capability, albeit a strange one.

Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1363788448-31325-2-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
arch/x86/include/asm/cpufeature.h
arch/x86/include/asm/processor.h
arch/x86/kernel/alternative.c
arch/x86/kernel/cpu/common.c

index 93fe929d1cee20ec1dc183d5c390e5d9325b26ce..16190abd89056226252ce77710cb0a5a435879bb 100644 (file)
@@ -9,6 +9,7 @@
 #endif
 
 #define NCAPINTS       10      /* N 32-bit words worth of info */
+#define NBUGINTS       1       /* N 32-bit bug flags */
 
 /*
  * Note: If the comment begins with a quoted string, that string is used
 #define X86_FEATURE_ADX                (9*32+19) /* The ADCX and ADOX instructions */
 #define X86_FEATURE_SMAP       (9*32+20) /* Supervisor Mode Access Prevention */
 
+/*
+ * BUG word(s)
+ */
+#define X86_BUG(x)             (NCAPINTS*32 + (x))
+
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 
 #include <asm/asm.h>
@@ -401,6 +407,13 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
 #define static_cpu_has(bit) boot_cpu_has(bit)
 #endif
 
+#define cpu_has_bug(c, bit)    cpu_has(c, (bit))
+#define set_cpu_bug(c, bit)    set_cpu_cap(c, (bit))
+#define clear_cpu_bug(c, bit)  clear_cpu_cap(c, (bit));
+
+#define static_cpu_has_bug(bit)        static_cpu_has((bit))
+#define boot_cpu_has_bug(bit)  cpu_has_bug(&boot_cpu_data, (bit))
+
 #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */
 
 #endif /* _ASM_X86_CPUFEATURE_H */
index 3270116b14881d861b080317dee305634f3a2356..23c8081d3870d2301c3e43c518bfef8a0e22378e 100644 (file)
@@ -107,7 +107,7 @@ struct cpuinfo_x86 {
        __u32                   extended_cpuid_level;
        /* Maximum supported CPUID level, -1=no CPUID: */
        int                     cpuid_level;
-       __u32                   x86_capability[NCAPINTS];
+       __u32                   x86_capability[NCAPINTS + NBUGINTS];
        char                    x86_vendor_id[16];
        char                    x86_model_id[64];
        /* in KB - valid for CPUS which support this call: */
index ef5ccca79a6cd2f6279086ed5ea464176d5870a1..c15cf9a25e279fc9934549a2c4a7d6faf26766fd 100644 (file)
@@ -271,7 +271,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
                replacement = (u8 *)&a->repl_offset + a->repl_offset;
                BUG_ON(a->replacementlen > a->instrlen);
                BUG_ON(a->instrlen > sizeof(insnbuf));
-               BUG_ON(a->cpuid >= NCAPINTS*32);
+               BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32);
                if (!boot_cpu_has(a->cpuid))
                        continue;
 
index d814772c5bed816cf6e463b04daaea940a7289ff..22018f70a6716e2f57012378c19df770ba607ca0 100644 (file)
@@ -920,6 +920,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
                /* AND the already accumulated flags with these */
                for (i = 0; i < NCAPINTS; i++)
                        boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
+
+               /* OR, i.e. replicate the bug flags */
+               for (i = NCAPINTS; i < NCAPINTS + NBUGINTS; i++)
+                       c->x86_capability[i] |= boot_cpu_data.x86_capability[i];
        }
 
        /* Init Machine Check Exception if available. */