Skip to content

Commit 9351803

Browse files
dwmw2KAGA-KOKO
authored andcommitted
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
1 parent 2641f08 commit 9351803

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

arch/x86/kernel/ftrace_32.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <asm/segment.h>
99
#include <asm/export.h>
1010
#include <asm/ftrace.h>
11+
#include <asm/nospec-branch.h>
1112

1213
#ifdef CC_USING_FENTRY
1314
# define function_hook __fentry__
@@ -197,7 +198,8 @@ ftrace_stub:
197198
movl 0x4(%ebp), %edx
198199
subl $MCOUNT_INSN_SIZE, %eax
199200

200-
call *ftrace_trace_function
201+
movl ftrace_trace_function, %ecx
202+
CALL_NOSPEC %ecx
201203

202204
popl %edx
203205
popl %ecx
@@ -241,5 +243,5 @@ return_to_handler:
241243
movl %eax, %ecx
242244
popl %edx
243245
popl %eax
244-
jmp *%ecx
246+
JMP_NOSPEC %ecx
245247
#endif

arch/x86/kernel/ftrace_64.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <asm/ptrace.h>
88
#include <asm/ftrace.h>
99
#include <asm/export.h>
10-
10+
#include <asm/nospec-branch.h>
1111

1212
.code64
1313
.section .entry.text, "ax"
@@ -286,8 +286,8 @@ trace:
286286
* ip and parent ip are used and the list function is called when
287287
* function tracing is enabled.
288288
*/
289-
call *ftrace_trace_function
290-
289+
movq ftrace_trace_function, %r8
290+
CALL_NOSPEC %r8
291291
restore_mcount_regs
292292

293293
jmp fgraph_trace
@@ -329,5 +329,5 @@ GLOBAL(return_to_handler)
329329
movq 8(%rsp), %rdx
330330
movq (%rsp), %rax
331331
addq $24, %rsp
332-
jmp *%rdi
332+
JMP_NOSPEC %rdi
333333
#endif

0 commit comments

Comments
 (0)