lkml.org 
[lkml]   [2023]   [Apr]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH RFC 21/43] x86/ftrace: Adapt assembly for PIE support
Date
Change the assembly code to use only relative references of symbols for
the kernel to be PIE compatible.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
Cc: Thomas Garnier <thgarnie@chromium.org>
Cc: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Cc: Kees Cook <keescook@chromium.org>
---
arch/x86/kernel/ftrace_64.S | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
index eddb4fabc16f..411fa4148e18 100644
--- a/arch/x86/kernel/ftrace_64.S
+++ b/arch/x86/kernel/ftrace_64.S
@@ -315,7 +315,14 @@ STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller)
SYM_FUNC_START(__fentry__)
CALL_DEPTH_ACCOUNT

+#ifdef CONFIG_X86_PIE
+ pushq %r8
+ leaq ftrace_stub(%rip), %r8
+ cmpq %r8, ftrace_trace_function(%rip)
+ popq %r8
+#else
cmpq $ftrace_stub, ftrace_trace_function
+#endif
jnz trace
RET

@@ -329,7 +336,7 @@ trace:
* ip and parent ip are used and the list function is called when
* function tracing is enabled.
*/
- movq ftrace_trace_function, %r8
+ movq ftrace_trace_function(%rip), %r8
CALL_NOSPEC r8
restore_mcount_regs

--
2.31.1
\
 
 \ /
  Last update: 2023-04-28 11:55    [W:0.288 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site