aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2017-11-02 08:22:35 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-11-02 09:56:43 -0400
commit06dd688ddda5819025e014b79aea9af6ab475fa2 (patch)
tree911df8b12caae00654eb039db69a55d3ee21067f
parentc128dbfa0f879f8ce7b79054037889b0b2240728 (diff)
x86/cpuid: Replace set/clear_bit32()
Peter pointed out that the set/clear_bit32() variants are broken in various aspects. Replace them with open coded set/clear_bit() and type cast cpu_info::x86_capability as it's done in all other places throughout x86. Fixes: 0b00de857a64 ("x86/cpuid: Add generic table for CPUID dependencies") Reported-by: Peter Ziljstra <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andi Kleen <ak@linux.intel.com>
-rw-r--r--arch/x86/kernel/cpu/cpuid-deps.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index c21f22d836ad..904b0a3c4e53 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -62,23 +62,19 @@ const static struct cpuid_dep cpuid_deps[] = {
62 {} 62 {}
63}; 63};
64 64
65static inline void __clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit)
66{
67 clear_bit32(bit, c->x86_capability);
68}
69
70static inline void __setup_clear_cpu_cap(unsigned int bit)
71{
72 clear_cpu_cap(&boot_cpu_data, bit);
73 set_bit32(bit, cpu_caps_cleared);
74}
75
76static inline void clear_feature(struct cpuinfo_x86 *c, unsigned int feature) 65static inline void clear_feature(struct cpuinfo_x86 *c, unsigned int feature)
77{ 66{
78 if (!c) 67 /*
79 __setup_clear_cpu_cap(feature); 68 * Note: This could use the non atomic __*_bit() variants, but the
80 else 69 * rest of the cpufeature code uses atomics as well, so keep it for
81 __clear_cpu_cap(c, feature); 70 * consistency. Cleanup all of it separately.
71 */
72 if (!c) {
73 clear_cpu_cap(&boot_cpu_data, feature);
74 set_bit(feature, (unsigned long *)cpu_caps_cleared);
75 } else {
76 clear_bit(feature, (unsigned long *)c->x86_capability);
77 }
82} 78}
83 79
84/* Take the capabilities and the BUG bits into account */ 80/* Take the capabilities and the BUG bits into account */