diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2018-01-11 16:46:29 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-01-11 18:14:30 -0500 |
commit | 9351803bd803cdbeb9b5a7850b7b6f464806e3db (patch) | |
tree | eeeee62b01c063bf2c21846f4bff7960d5abb1df | |
parent | 2641f08bb7fc63a636a2b18173221d7040a3512e (diff) |
x86/retpoline/ftrace: Convert ftrace assembler indirect jumps
Convert all indirect jumps in ftrace assembler code to use non-speculative
sequences when CONFIG_RETPOLINE is enabled.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: gnomes@lxorguk.ukuu.org.uk
Cc: Rik van Riel <riel@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: thomas.lendacky@amd.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kees Cook <keescook@google.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: https://lkml.kernel.org/r/1515707194-20531-8-git-send-email-dwmw@amazon.co.uk
-rw-r--r-- | arch/x86/kernel/ftrace_32.S | 6 | ||||
-rw-r--r-- | arch/x86/kernel/ftrace_64.S | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S index b6c6468e10bc..4c8440de3355 100644 --- a/arch/x86/kernel/ftrace_32.S +++ b/arch/x86/kernel/ftrace_32.S | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <asm/segment.h> | 8 | #include <asm/segment.h> |
9 | #include <asm/export.h> | 9 | #include <asm/export.h> |
10 | #include <asm/ftrace.h> | 10 | #include <asm/ftrace.h> |
11 | #include <asm/nospec-branch.h> | ||
11 | 12 | ||
12 | #ifdef CC_USING_FENTRY | 13 | #ifdef CC_USING_FENTRY |
13 | # define function_hook __fentry__ | 14 | # define function_hook __fentry__ |
@@ -197,7 +198,8 @@ ftrace_stub: | |||
197 | movl 0x4(%ebp), %edx | 198 | movl 0x4(%ebp), %edx |
198 | subl $MCOUNT_INSN_SIZE, %eax | 199 | subl $MCOUNT_INSN_SIZE, %eax |
199 | 200 | ||
200 | call *ftrace_trace_function | 201 | movl ftrace_trace_function, %ecx |
202 | CALL_NOSPEC %ecx | ||
201 | 203 | ||
202 | popl %edx | 204 | popl %edx |
203 | popl %ecx | 205 | popl %ecx |
@@ -241,5 +243,5 @@ return_to_handler: | |||
241 | movl %eax, %ecx | 243 | movl %eax, %ecx |
242 | popl %edx | 244 | popl %edx |
243 | popl %eax | 245 | popl %eax |
244 | jmp *%ecx | 246 | JMP_NOSPEC %ecx |
245 | #endif | 247 | #endif |
diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S index c832291d948a..7cb8ba08beb9 100644 --- a/arch/x86/kernel/ftrace_64.S +++ b/arch/x86/kernel/ftrace_64.S | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <asm/ptrace.h> | 7 | #include <asm/ptrace.h> |
8 | #include <asm/ftrace.h> | 8 | #include <asm/ftrace.h> |
9 | #include <asm/export.h> | 9 | #include <asm/export.h> |
10 | 10 | #include <asm/nospec-branch.h> | |
11 | 11 | ||
12 | .code64 | 12 | .code64 |
13 | .section .entry.text, "ax" | 13 | .section .entry.text, "ax" |
@@ -286,8 +286,8 @@ trace: | |||
286 | * ip and parent ip are used and the list function is called when | 286 | * ip and parent ip are used and the list function is called when |
287 | * function tracing is enabled. | 287 | * function tracing is enabled. |
288 | */ | 288 | */ |
289 | call *ftrace_trace_function | 289 | movq ftrace_trace_function, %r8 |
290 | 290 | CALL_NOSPEC %r8 | |
291 | restore_mcount_regs | 291 | restore_mcount_regs |
292 | 292 | ||
293 | jmp fgraph_trace | 293 | jmp fgraph_trace |
@@ -329,5 +329,5 @@ GLOBAL(return_to_handler) | |||
329 | movq 8(%rsp), %rdx | 329 | movq 8(%rsp), %rdx |
330 | movq (%rsp), %rax | 330 | movq (%rsp), %rax |
331 | addq $24, %rsp | 331 | addq $24, %rsp |
332 | jmp *%rdi | 332 | JMP_NOSPEC %rdi |
333 | #endif | 333 | #endif |