aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2013-06-28 12:41:41 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2013-06-28 18:26:48 -0400
commit62122fd7dadac09704782d8bc051fb898a0272bd (patch)
tree587c059270c340289a3789edc4a2fc6a2a1100c8 /arch/x86
parent9f84b6267ccde1bebe3f9cd40a91716b5ece5e20 (diff)
x86, cpufeature: Use new CC_HAVE_ASM_GOTO
... for checking for "asm goto" compiler support. It is more explicit this way and we cover the cases where distros have backported that support even to gcc versions < 4.5. Signed-off-by: Borislav Petkov <bp@suse.de> Link: http://lkml.kernel.org/r/1372437701-13351-1-git-send-email-bp@alien8.de Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/cpufeature.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 47538a61c91b..d3f5c63078d8 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -366,9 +366,10 @@ extern bool __static_cpu_has_safe(u16 bit);
366 */ 366 */
367static __always_inline __pure bool __static_cpu_has(u16 bit) 367static __always_inline __pure bool __static_cpu_has(u16 bit)
368{ 368{
369#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5 369#ifdef CC_HAVE_ASM_GOTO
370 370
371#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS 371#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
372
372 /* 373 /*
373 * Catch too early usage of this before alternatives 374 * Catch too early usage of this before alternatives
374 * have run. 375 * have run.
@@ -384,6 +385,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
384 ".previous\n" 385 ".previous\n"
385 /* skipping size check since replacement size = 0 */ 386 /* skipping size check since replacement size = 0 */
386 : : "i" (X86_FEATURE_ALWAYS) : : t_warn); 387 : : "i" (X86_FEATURE_ALWAYS) : : t_warn);
388
387#endif 389#endif
388 390
389 asm goto("1: jmp %l[t_no]\n" 391 asm goto("1: jmp %l[t_no]\n"
@@ -406,7 +408,9 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
406 warn_pre_alternatives(); 408 warn_pre_alternatives();
407 return false; 409 return false;
408#endif 410#endif
409#else /* GCC_VERSION >= 40500 */ 411
412#else /* CC_HAVE_ASM_GOTO */
413
410 u8 flag; 414 u8 flag;
411 /* Open-coded due to __stringify() in ALTERNATIVE() */ 415 /* Open-coded due to __stringify() in ALTERNATIVE() */
412 asm volatile("1: movb $0,%0\n" 416 asm volatile("1: movb $0,%0\n"
@@ -427,7 +431,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
427 ".previous\n" 431 ".previous\n"
428 : "=qm" (flag) : "i" (bit)); 432 : "=qm" (flag) : "i" (bit));
429 return flag; 433 return flag;
430#endif 434
435#endif /* CC_HAVE_ASM_GOTO */
431} 436}
432 437
433#define static_cpu_has(bit) \ 438#define static_cpu_has(bit) \
@@ -441,7 +446,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
441 446
442static __always_inline __pure bool _static_cpu_has_safe(u16 bit) 447static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
443{ 448{
444#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5 449#ifdef CC_HAVE_ASM_GOTO
445/* 450/*
446 * We need to spell the jumps to the compiler because, depending on the offset, 451 * We need to spell the jumps to the compiler because, depending on the offset,
447 * the replacement jump can be bigger than the original jump, and this we cannot 452 * the replacement jump can be bigger than the original jump, and this we cannot
@@ -475,7 +480,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
475 return false; 480 return false;
476 t_dynamic: 481 t_dynamic:
477 return __static_cpu_has_safe(bit); 482 return __static_cpu_has_safe(bit);
478#else /* GCC_VERSION >= 40500 */ 483#else
479 u8 flag; 484 u8 flag;
480 /* Open-coded due to __stringify() in ALTERNATIVE() */ 485 /* Open-coded due to __stringify() in ALTERNATIVE() */
481 asm volatile("1: movb $2,%0\n" 486 asm volatile("1: movb $2,%0\n"
@@ -511,7 +516,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
511 : "=qm" (flag) 516 : "=qm" (flag)
512 : "i" (bit), "i" (X86_FEATURE_ALWAYS)); 517 : "i" (bit), "i" (X86_FEATURE_ALWAYS));
513 return (flag == 2 ? __static_cpu_has_safe(bit) : flag); 518 return (flag == 2 ? __static_cpu_has_safe(bit) : flag);
514#endif 519#endif /* CC_HAVE_ASM_GOTO */
515} 520}
516 521
517#define static_cpu_has_safe(bit) \ 522#define static_cpu_has_safe(bit) \