lkml.org 
[lkml]   [2022]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 14/39] x86/ibt,ftrace: Make function-graph play nice
On Thu, Feb 24, 2022 at 03:51:52PM +0100, Peter Zijlstra wrote:
> @@ -316,10 +317,12 @@ SYM_FUNC_START(return_to_handler)
>
> call ftrace_return_to_handler
>
> - movq %rax, %rdi
> + movq %rax, 16(%rsp)
> movq 8(%rsp), %rdx
> movq (%rsp), %rax
> - addq $24, %rsp
> - JMP_NOSPEC rdi
> +
> + addq $16, %rsp
> + UNWIND_HINT_FUNC
> + RET
> SYM_FUNC_END(return_to_handler)
> #endif

While talking about this with Mark, an alternative solution is something
like this, that would keep the RSB balanced and only mess up the current
return.

No idea it if makes an appreciatable difference on current hardware,
therefore I went with the simpler option above.

@@ -307,7 +315,7 @@ EXPORT_SYMBOL(__fentry__)

#ifdef CONFIG_FUNCTION_GRAPH_TRACER
SYM_FUNC_START(return_to_handler)
- subq $24, %rsp
+ subq $16, %rsp

/* Save the return values */
movq %rax, (%rsp)
@@ -319,7 +327,13 @@ SYM_FUNC_START(return_to_handler)
movq %rax, %rdi
movq 8(%rsp), %rdx
movq (%rsp), %rax
- addq $24, %rsp
- JMP_NOSPEC rdi
+
+ addq $16, %rsp
+ ANNOTATE_INTRA_FUNCTION_CALL
+ call .Ldo_rop
+.Ldo_rop:
+ mov %rdi, (%rsp)
+ UNWIND_HINT_FUNC
+ RET
SYM_FUNC_END(return_to_handler)
#endif

\
 
 \ /
  Last update: 2022-02-24 16:38    [W:1.380 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site