Skip to content

Commit 8bc1170

Browse files
olsajirianakryiko
authored andcommitted
x86/fgraph: Fix return_to_handler regs.rsp value
The previous change (Fixes commit) messed up the rsp register value, which is wrong because it's already adjusted with FRAME_SIZE, we need the original rsp value. This change does not affect fprobe current kernel unwind, the !perf_hw_regs path perf_callchain_kernel: if (perf_hw_regs(regs)) { if (perf_callchain_store(entry, regs->ip)) return; unwind_start(&state, current, regs, NULL); } else { unwind_start(&state, current, NULL, (void *)regs->sp); } which uses pt_regs.sp as first_frame boundary (FRAME_SIZE shift makes no difference, unwind stil stops at the right frame). This change fixes the other path when we want to unwind directly from pt_regs sp/fp/ip state, which is coming in following change. Fixes: 20a0bc1 ("x86/fgraph,bpf: Fix stack ORC unwind from kprobe_multi return probe") Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Link: https://lore.kernel.org/bpf/20260126211837.472802-2-jolsa@kernel.org
1 parent cd77618 commit 8bc1170

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

arch/x86/kernel/ftrace_64.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ SYM_CODE_START(return_to_handler)
364364
UNWIND_HINT_UNDEFINED
365365
ANNOTATE_NOENDBR
366366

367+
/* Store original rsp for pt_regs.sp value. */
368+
movq %rsp, %rdi
369+
367370
/* Restore return_to_handler value that got eaten by previous ret instruction. */
368371
subq $8, %rsp
369372
UNWIND_HINT_FUNC
@@ -374,7 +377,7 @@ SYM_CODE_START(return_to_handler)
374377
movq %rax, RAX(%rsp)
375378
movq %rdx, RDX(%rsp)
376379
movq %rbp, RBP(%rsp)
377-
movq %rsp, RSP(%rsp)
380+
movq %rdi, RSP(%rsp)
378381
movq %rsp, %rdi
379382

380383
call ftrace_return_to_handler

0 commit comments

Comments
 (0)