Re: [RFC PATCH v2 18/30] riscv: Add DWARF CFI annotations to entry, ftrace, rethook, and BPF JIT
From: bot+bpf-ci
Date: Wed Nov 25 2026 - 02:06:27 EST
> riscv: Add DWARF CFI annotations to entry, ftrace, rethook, and BPF JIT
TL;DR: Commit message only: it says the return_to_handler() rewrite in riscv
mcount.S is under CONFIG_UNWINDER_DWARF_CFI, but part of it is unconditional.
The code looks functionally correct.
> riscv: Add DWARF CFI annotations to entry, ftrace, rethook, and BPF JIT
>
> Prepare RISC-V assembly, probe trampolines, and RV64 BPF JIT prologues
> for runtime Minimal DWARF CFI kernel unwinding:
> - Export end labels for ret_from_fork_user_asm, call_on_irq_stack, and
> ftrace_caller save/restore boundaries, and save s0 in ftrace_caller
> under CONFIG_UNWINDER_DWARF_CFI.
> - Annotate return_to_handler() and arch_rethook_trampoline() with
> .cfi_* directives and key rethook shadow stacks on entry SP (CFA)
> under CONFIG_UNWINDER_DWARF_CFI.
> - Save RV_REG_RA unconditionally in RV64 BPF JIT prologues under
> CONFIG_UNWINDER_DWARF_CFI so leaf BPF programs unwind into frameless C
> callers.
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
The commit message describes the return_to_handler() changes as being
under CONFIG_UNWINDER_DWARF_CFI, but part of that rewrite is not config
gated:
arch/riscv/kernel/mcount.S:
call ftrace_return_to_handler
- mv a2, a0
+ mv ra, a0
...
- jalr a2
+ ret
and RESTORE_RET_ABI_STATE no longer does:
- REG_L ra, FREGS_RA(sp)
This applies to every riscv kernel with CONFIG_FUNCTION_GRAPH_TRACER,
including builds that never enable the new unwinder. On return, ra now
holds the real return address instead of a value inside return_to_handler,
a2 is no longer written, and ret replaces an indirect jalr.
The new sequence looks functionally correct, but should the commit message
say that this part is unconditional and explain why it is needed (the
.cfi_same_value ra over the final instructions), so riscv and ftrace
maintainers can review it as such?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45561209846