Skip to content

Commit 62122fd

Browse files
suryasaimadhuH. Peter Anvin
authored andcommitted
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>
1 parent 9f84b62 commit 62122fd

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

arch/x86/include/asm/cpufeature.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,10 @@ extern bool __static_cpu_has_safe(u16 bit);
366366
*/
367367
static __always_inline __pure bool __static_cpu_has(u16 bit)
368368
{
369-
#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
369+
#ifdef CC_HAVE_ASM_GOTO
370370

371371
#ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
372+
372373
/*
373374
* Catch too early usage of this before alternatives
374375
* have run.
@@ -384,6 +385,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
384385
".previous\n"
385386
/* skipping size check since replacement size = 0 */
386387
: : "i" (X86_FEATURE_ALWAYS) : : t_warn);
388+
387389
#endif
388390

389391
asm goto("1: jmp %l[t_no]\n"
@@ -406,7 +408,9 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
406408
warn_pre_alternatives();
407409
return false;
408410
#endif
409-
#else /* GCC_VERSION >= 40500 */
411+
412+
#else /* CC_HAVE_ASM_GOTO */
413+
410414
u8 flag;
411415
/* Open-coded due to __stringify() in ALTERNATIVE() */
412416
asm volatile("1: movb $0,%0\n"
@@ -427,7 +431,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
427431
".previous\n"
428432
: "=qm" (flag) : "i" (bit));
429433
return flag;
430-
#endif
434+
435+
#endif /* CC_HAVE_ASM_GOTO */
431436
}
432437

433438
#define static_cpu_has(bit) \
@@ -441,7 +446,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
441446

442447
static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
443448
{
444-
#if __GNUC__ > 4 || __GNUC_MINOR__ >= 5
449+
#ifdef CC_HAVE_ASM_GOTO
445450
/*
446451
* We need to spell the jumps to the compiler because, depending on the offset,
447452
* 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)
475480
return false;
476481
t_dynamic:
477482
return __static_cpu_has_safe(bit);
478-
#else /* GCC_VERSION >= 40500 */
483+
#else
479484
u8 flag;
480485
/* Open-coded due to __stringify() in ALTERNATIVE() */
481486
asm volatile("1: movb $2,%0\n"
@@ -511,7 +516,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
511516
: "=qm" (flag)
512517
: "i" (bit), "i" (X86_FEATURE_ALWAYS));
513518
return (flag == 2 ? __static_cpu_has_safe(bit) : flag);
514-
#endif
519+
#endif /* CC_HAVE_ASM_GOTO */
515520
}
516521

517522
#define static_cpu_has_safe(bit) \

0 commit comments

Comments
 (0)