aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2016-01-26 16:12:05 -0500
committerIngo Molnar <mingo@kernel.org>2016-01-30 05:22:18 -0500
commitbc696ca05f5a8927329ec276a892341e006b00ba (patch)
treea8200bfe9677aa30a11b53e8fd6215aaeb3a4a96 /arch/x86/kernel
parentcd4d09ec6f6c12a2cc3db5b7d8876a325a53545b (diff)
x86/cpufeature: Replace the old static_cpu_has() with safe variant
So the old one didn't work properly before alternatives had run. And it was supposed to provide an optimized JMP because the assumption was that the offset it is jumping to is within a signed byte and thus a two-byte JMP. So I did an x86_64 allyesconfig build and dumped all possible sites where static_cpu_has() was used. The optimization amounted to all in all 12(!) places where static_cpu_has() had generated a 2-byte JMP. Which has saved us a whopping 36 bytes! This clearly is not worth the trouble so we can remove it. The only place where the optimization might count - in __switch_to() - we will handle differently. But that's not subject of this patch. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1453842730-28463-6-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/apic/apic_numachip.c4
-rw-r--r--arch/x86/kernel/cpu/common.c12
-rw-r--r--arch/x86/kernel/vm86_32.c2
3 files changed, 5 insertions, 13 deletions
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index c80c02c6ec49..ab5c2c685a3c 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -30,7 +30,7 @@ static unsigned int numachip1_get_apic_id(unsigned long x)
30 unsigned long value; 30 unsigned long value;
31 unsigned int id = (x >> 24) & 0xff; 31 unsigned int id = (x >> 24) & 0xff;
32 32
33 if (static_cpu_has_safe(X86_FEATURE_NODEID_MSR)) { 33 if (static_cpu_has(X86_FEATURE_NODEID_MSR)) {
34 rdmsrl(MSR_FAM10H_NODE_ID, value); 34 rdmsrl(MSR_FAM10H_NODE_ID, value);
35 id |= (value << 2) & 0xff00; 35 id |= (value << 2) & 0xff00;
36 } 36 }
@@ -178,7 +178,7 @@ static void fixup_cpu_id(struct cpuinfo_x86 *c, int node)
178 this_cpu_write(cpu_llc_id, node); 178 this_cpu_write(cpu_llc_id, node);
179 179
180 /* Account for nodes per socket in multi-core-module processors */ 180 /* Account for nodes per socket in multi-core-module processors */
181 if (static_cpu_has_safe(X86_FEATURE_NODEID_MSR)) { 181 if (static_cpu_has(X86_FEATURE_NODEID_MSR)) {
182 rdmsrl(MSR_FAM10H_NODE_ID, val); 182 rdmsrl(MSR_FAM10H_NODE_ID, val);
183 nodes = ((val >> 3) & 7) + 1; 183 nodes = ((val >> 3) & 7) + 1;
184 } 184 }
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 37830de8f60a..ee499817f3f5 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1475,19 +1475,11 @@ void cpu_init(void)
1475} 1475}
1476#endif 1476#endif
1477 1477
1478#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS 1478inline bool __static_cpu_has(u16 bit)
1479void warn_pre_alternatives(void)
1480{
1481 WARN(1, "You're using static_cpu_has before alternatives have run!\n");
1482}
1483EXPORT_SYMBOL_GPL(warn_pre_alternatives);
1484#endif
1485
1486inline bool __static_cpu_has_safe(u16 bit)
1487{ 1479{
1488 return boot_cpu_has(bit); 1480 return boot_cpu_has(bit);
1489} 1481}
1490EXPORT_SYMBOL_GPL(__static_cpu_has_safe); 1482EXPORT_SYMBOL_GPL(__static_cpu_has);
1491 1483
1492static void bsp_resume(void) 1484static void bsp_resume(void)
1493{ 1485{
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index e574b8546518..3dce1ca0a653 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -362,7 +362,7 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus)
362 /* make room for real-mode segments */ 362 /* make room for real-mode segments */
363 tsk->thread.sp0 += 16; 363 tsk->thread.sp0 += 16;
364 364
365 if (static_cpu_has_safe(X86_FEATURE_SEP)) 365 if (static_cpu_has(X86_FEATURE_SEP))
366 tsk->thread.sysenter_cs = 0; 366 tsk->thread.sysenter_cs = 0;
367 367
368 load_sp0(tss, &tsk->thread); 368 load_sp0(tss, &tsk->thread);