diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-01-26 18:06:45 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-08-06 21:16:33 -0400 |
commit | c3c7f14a116c24d6fba185c95cd7454f3764f8a9 (patch) | |
tree | 1766dcc9afbc1a1417c2783a601c7c7973b71eef /arch | |
parent | ad81f0545ef01ea651886dddac4bef6cec930092 (diff) |
x86/jump-label: Use best default nops for inital jump label calls
As specified by H. Peter Anvin, the best nops for x86 without knowing
the running computer is:
32bit:
0x3e, 0x8d, 0x74, 0x26, 0x00 also known as GENERIC_NOP5_ATOMIC
64bit:
0x0f, 0x1f, 0x44, 0x00, 0x00 also known as P6_NOP5_ATOMIC
Currently the default nop that is used by jump label is:
0xe9 0x00 0x00 0x00 0x00
Which is really a 5byte jump to the next position.
It's better to use a real nop than a jmp.
Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/jump_label.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index 3a16c1483b45..64507f35800c 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h | |||
@@ -3,18 +3,23 @@ | |||
3 | 3 | ||
4 | #ifdef __KERNEL__ | 4 | #ifdef __KERNEL__ |
5 | 5 | ||
6 | #include <linux/stringify.h> | ||
6 | #include <linux/types.h> | 7 | #include <linux/types.h> |
7 | #include <asm/nops.h> | 8 | #include <asm/nops.h> |
8 | #include <asm/asm.h> | 9 | #include <asm/asm.h> |
9 | 10 | ||
10 | #define JUMP_LABEL_NOP_SIZE 5 | 11 | #define JUMP_LABEL_NOP_SIZE 5 |
11 | 12 | ||
12 | #define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t" | 13 | #ifdef CONFIG_X86_64 |
14 | # define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC | ||
15 | #else | ||
16 | # define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC | ||
17 | #endif | ||
13 | 18 | ||
14 | static __always_inline bool arch_static_branch(struct static_key *key) | 19 | static __always_inline bool arch_static_branch(struct static_key *key) |
15 | { | 20 | { |
16 | asm goto("1:" | 21 | asm goto("1:" |
17 | STATIC_KEY_INITIAL_NOP | 22 | ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" |
18 | ".pushsection __jump_table, \"aw\" \n\t" | 23 | ".pushsection __jump_table, \"aw\" \n\t" |
19 | _ASM_ALIGN "\n\t" | 24 | _ASM_ALIGN "\n\t" |
20 | _ASM_PTR "1b, %l[l_yes], %c0 \n\t" | 25 | _ASM_PTR "1b, %l[l_yes], %c0 \n\t" |