diff options
author | Ingo Molnar <mingo@kernel.org> | 2013-10-10 04:16:30 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2013-10-11 01:39:14 -0400 |
commit | 3f0116c3238a96bc18ad4b4acefe4e7be32fa861 (patch) | |
tree | b30e1fd03f2ab222051d8d1eb776bd1895416497 /arch/x86/include/asm | |
parent | 2fe80d3bbf1c8bd9efc5b8154207c8dd104e7306 (diff) |
compiler/gcc4: Add quirk for 'asm goto' miscompilation bug
Fengguang Wu, Oleg Nesterov and Peter Zijlstra tracked down
a kernel crash to a GCC bug: GCC miscompiles certain 'asm goto'
constructs, as outlined here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
Implement a workaround suggested by Jakub Jelinek.
Reported-and-tested-by: Fengguang Wu <fengguang.wu@intel.com>
Reported-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Suggested-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/include/asm')
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 6 | ||||
-rw-r--r-- | arch/x86/include/asm/jump_label.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mutex_64.h | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index d3f5c63078d8..89270b4318db 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
@@ -374,7 +374,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) | |||
374 | * Catch too early usage of this before alternatives | 374 | * Catch too early usage of this before alternatives |
375 | * have run. | 375 | * have run. |
376 | */ | 376 | */ |
377 | asm goto("1: jmp %l[t_warn]\n" | 377 | asm_volatile_goto("1: jmp %l[t_warn]\n" |
378 | "2:\n" | 378 | "2:\n" |
379 | ".section .altinstructions,\"a\"\n" | 379 | ".section .altinstructions,\"a\"\n" |
380 | " .long 1b - .\n" | 380 | " .long 1b - .\n" |
@@ -388,7 +388,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) | |||
388 | 388 | ||
389 | #endif | 389 | #endif |
390 | 390 | ||
391 | asm goto("1: jmp %l[t_no]\n" | 391 | asm_volatile_goto("1: jmp %l[t_no]\n" |
392 | "2:\n" | 392 | "2:\n" |
393 | ".section .altinstructions,\"a\"\n" | 393 | ".section .altinstructions,\"a\"\n" |
394 | " .long 1b - .\n" | 394 | " .long 1b - .\n" |
@@ -453,7 +453,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit) | |||
453 | * have. Thus, we force the jump to the widest, 4-byte, signed relative | 453 | * have. Thus, we force the jump to the widest, 4-byte, signed relative |
454 | * offset even though the last would often fit in less bytes. | 454 | * offset even though the last would often fit in less bytes. |
455 | */ | 455 | */ |
456 | asm goto("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n" | 456 | asm_volatile_goto("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n" |
457 | "2:\n" | 457 | "2:\n" |
458 | ".section .altinstructions,\"a\"\n" | 458 | ".section .altinstructions,\"a\"\n" |
459 | " .long 1b - .\n" /* src offset */ | 459 | " .long 1b - .\n" /* src offset */ |
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index 64507f35800c..6a2cefb4395a 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | static __always_inline bool arch_static_branch(struct static_key *key) | 19 | static __always_inline bool arch_static_branch(struct static_key *key) |
20 | { | 20 | { |
21 | asm goto("1:" | 21 | asm_volatile_goto("1:" |
22 | ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" | 22 | ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" |
23 | ".pushsection __jump_table, \"aw\" \n\t" | 23 | ".pushsection __jump_table, \"aw\" \n\t" |
24 | _ASM_ALIGN "\n\t" | 24 | _ASM_ALIGN "\n\t" |
diff --git a/arch/x86/include/asm/mutex_64.h b/arch/x86/include/asm/mutex_64.h index e7e6751648ed..07537a44216e 100644 --- a/arch/x86/include/asm/mutex_64.h +++ b/arch/x86/include/asm/mutex_64.h | |||
@@ -20,7 +20,7 @@ | |||
20 | static inline void __mutex_fastpath_lock(atomic_t *v, | 20 | static inline void __mutex_fastpath_lock(atomic_t *v, |
21 | void (*fail_fn)(atomic_t *)) | 21 | void (*fail_fn)(atomic_t *)) |
22 | { | 22 | { |
23 | asm volatile goto(LOCK_PREFIX " decl %0\n" | 23 | asm_volatile_goto(LOCK_PREFIX " decl %0\n" |
24 | " jns %l[exit]\n" | 24 | " jns %l[exit]\n" |
25 | : : "m" (v->counter) | 25 | : : "m" (v->counter) |
26 | : "memory", "cc" | 26 | : "memory", "cc" |
@@ -75,7 +75,7 @@ static inline int __mutex_fastpath_lock_retval(atomic_t *count) | |||
75 | static inline void __mutex_fastpath_unlock(atomic_t *v, | 75 | static inline void __mutex_fastpath_unlock(atomic_t *v, |
76 | void (*fail_fn)(atomic_t *)) | 76 | void (*fail_fn)(atomic_t *)) |
77 | { | 77 | { |
78 | asm volatile goto(LOCK_PREFIX " incl %0\n" | 78 | asm_volatile_goto(LOCK_PREFIX " incl %0\n" |
79 | " jg %l[exit]\n" | 79 | " jg %l[exit]\n" |
80 | : : "m" (v->counter) | 80 | : : "m" (v->counter) |
81 | : "memory", "cc" | 81 | : "memory", "cc" |