Rust for Linux List
 help / color / mirror / Atom feed
From: Jens Remus <jremus@linux.ibm.com>
To: Ian Rogers <irogers@google.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org
Cc: jpoimboe@kernel.org, rostedt@goodmis.org, peterz@infradead.org,
	mingo@redhat.com, tglx@kernel.org, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org,
	catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
	linux-arm-kernel@lists.infradead.org, pjw@kernel.org,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
	linux-riscv@lists.infradead.org, acme@kernel.org,
	namhyung@kernel.org, linux-perf-users@vger.kernel.org,
	mhiramat@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, bpf@vger.kernel.org, nathan@kernel.org,
	llvm@lists.linux.dev, nsc@kernel.org,
	linux-kbuild@vger.kernel.org, ojeda@kernel.org,
	rust-for-linux@vger.kernel.org, ardb@kernel.org,
	linux-efi@vger.kernel.org, maz@kernel.org, oupton@kernel.org,
	kvmarm@lists.linux.dev, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, indu.bhagat@oracle.com,
	wnliu@google.com, dylanbhatch@google.com
Subject: Re: [RFC PATCH v2 03/30] unwind_user: Support Minimal DWARF CFI user-space unwinding
Date: Fri, 27 Nov 2026 16:45:12 +0100	[thread overview]
Message-ID: <b3e99b3a-7dd6-4e3a-97a8-3011a5f52569@linux.ibm.com> (raw)
In-Reply-To: <20261125061523.1540234-4-irogers@google.com>

Hello Ian,

some early feedback.

On 11/25/2026 7:14 AM, Ian Rogers wrote:
> Extend the generic user-space unwinder (kernel/unwind/user.c) with
> UNWIND_USER_TYPE_CFI (CONFIG_HAVE_UNWIND_USER_CFI), resolving ELF
> PT_GNU_EH_FRAME headers across executable VMAs in kernel/unwind/user_cfi.c.
> 
> Key design details:
>  - Find the executable VMA and its base ELF mapping (vm_pgoff == 0)
>    under mmap_read_lock_killable(), then drop mmap_read_lock() before
>    issuing any faultable copy_from_user() reads.
>  - Cache VMA -> PT_GNU_EH_FRAME lookups (including negative lookups for
>    anonymous/JIT VMAs so unwind_user_next() falls back per frame to FP)
>    in a 4-slot per-walk cache on struct unwind_user_state.
>  - Track stack-pointer validity (state->sp_valid and
>    unwind_user_fp_sets_sp()) across mixed CFI -> FP -> CFI walks so
>    architectures whose FP step does not recover exact caller SP reject
>    SP-based rules until an outer FP-based FDE or sigreturn restores SP,
>    and support signal-frame SP recovery from *(CFA + sp_off).
>  - Provide overridable unwind_user_frame_pointer() (guarded by
>    CONFIG_HAVE_UNWIND_USER_FP), unwind_user_fp_sets_sp(), and
>    unwind_user_sigreturn() hooks alongside unwind_user_link_register()
>    and unwind_user_strip_pac(), and allow up to UNWIND_USER_MAX_SIGNALS
>    signal frames per walk to switch stacks (SA_ONSTACK).
>  - Support link-register leaf frames, DRAP/sigframe indirect CFA rules,
>    and clean bottom-of-stack termination on DW_CFA_undefined or zero RA.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>

> diff --git a/include/linux/unwind_user_types.h b/include/linux/unwind_user_types.h

> +/**
> + * struct unwind_user_frame - Evaluated unwind rule for stepping one user frame
> + * @cfa_off: Byte offset added to FP (when @use_fp is true) or SP to form CFA.

 * @cfa_off: Byte offset added to CFA base register (SP or FP) to form CFA.

> + * @sp_off: Byte offset from CFA to saved caller SP when @sp_from_cfa is true.
> + * @ra_off: Byte offset from CFA (or SP when @ra_from_sp is true) to saved RA.
> + * @fp_off: Byte offset from CFA, FP, or SP to saved caller FP (0 if unchanged,
> + *          unless @fp_from_fp or @fp_from_sp is set).
> + * @use_fp: True if the CFA base register is FP rather than SP.
> + * @cfa_indirect: True if the computed CFA address must be dereferenced once in
> + *                user memory (DRAP or signal trampoline frame).
> + * @sp_from_cfa: True if saved SP is located at *(cfa + @sp_off) (e.g. vdso32
> + *               sigreturn frame where CFA points at sigcontext).
> + * @fp_from_fp: True if saved FP is located at *(state->fp + @fp_off).
> + * @fp_from_sp: True if saved FP is located at *(old_sp + @fp_off).
> + * @ra_from_sp: True if saved RA is located at *(old_sp + @ra_off).
> + * @ra_from_reg: True if RA is still in @state->ra rather than on the stack.

This flag soup is confusing.  For s390 support I would need to add the
following to support DW_CFA_register, which would make it even worse:

 * @sp_reg: DWARF register number containing the saved SP when if @sp_from_reg
            is true.
 * @fp_reg: DWARF register number containing the saved FP when if @fp_from_reg
            is true.
 * @ra_reg: DWARF register number containing the saved RA when if @ra_from_reg
            is true.
 * @sp_from_reg: True if saved SP is located in @sp_reg.
 * @fp_from_reg: True if saved FP is located in @fp_reg.
 * @ra_from_reg: True if saved RA is located in @ra_reg.

Wouldn't it be preferable to use something more similar to struct
dwarf_cfi_row?

  cfa_rule: UNDEFINED, SP, FP, SP_INDIRECT, FP_INDIRECT, REGISTER
  cfa_reg
  cfa_off

  {sp|fp|ra}_rule: SAME, OFFSET, SP_OFFSET, FP_OFFSET, VAL_OFFSET,
                   REGISTER, UNDEFINED
  {sp|fp|ra}_reg
  {sp|fp|ra}_off

> + * @ra_signed: True if the recovered RA carries an AArch64 PAC signature.
> + */
>  struct unwind_user_frame {
>  	s32 cfa_off;
> +	s32 sp_off;
>  	s32 ra_off;
>  	s32 fp_off;
>  	bool use_fp;
> +	bool cfa_indirect;
> +	bool sp_from_cfa;
> +	bool fp_from_fp;
> +	bool fp_from_sp;
> +	bool ra_from_sp;
> +	bool ra_from_reg;
> +	bool ra_signed;
> +};
Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com

IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/


  parent reply	other threads:[~2026-11-27 15:46 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  6:14 [RFC PATCH v2 00/30] unwind: Minimal DWARF CFI unwinding for user and kernel space Ian Rogers
2026-11-25  6:14 ` [RFC PATCH v2 01/30] unwind: Add Minimal DWARF CFI bytecode interpreter Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-27 15:37   ` Jens Remus
2026-11-25  6:14 ` [RFC PATCH v2 02/30] unwind: Add KUnit tests for Minimal DWARF CFI interpreter Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-25  6:14 ` [RFC PATCH v2 03/30] unwind_user: Support Minimal DWARF CFI user-space unwinding Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-27 15:45   ` Jens Remus [this message]
2026-11-25  6:14 ` [RFC PATCH v2 04/30] x86: unwind_user: Support Minimal DWARF CFI user unwinding Ian Rogers
2026-11-25  6:47   ` bot+bpf-ci
2026-11-25  6:14 ` [RFC PATCH v2 05/30] scripts: Add min_eh_frame build-time .eh_frame minifier Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:14 ` [RFC PATCH v2 06/30] kbuild: Wire up CONFIG_UNWINDER_DWARF_CFI_MINIFY object pass Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 07/30] objtool/ibt: Ignore .eh_frame relocations during ENDBR validation Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 08/30] vmlinux.lds.h: Allow architectures to emit custom RO_DATA sections Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 09/30] efi/libstub: Disable unwind tables in x86 and RISC-V EFI stubs Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 10/30] tracing: Skip internal ftrace frames under CONFIG_UNWINDER_DWARF_CFI Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 11/30] x86: Add DWARF CFI annotations to entry, ftrace, frame, and rethook Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 12/30] x86/unwind: Add Minimal DWARF CFI kernel unwinder Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-27 15:43   ` Jens Remus
2026-11-25  6:15 ` [RFC PATCH v2 13/30] lib/Kconfig.debug: Allow LATENCYTOP and fault-injection filter with DWARF CFI Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 14/30] arm64: unwind_user: Support Minimal DWARF CFI and FP user unwinding Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 15/30] arm64: Add DWARF CFI annotations to entry, ftrace, EFI, BPF, and KASAN Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 16/30] arm64/unwind: Add Minimal DWARF CFI kernel unwinder Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 17/30] riscv: unwind_user: Support Minimal DWARF CFI and FP user unwinding Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 18/30] riscv: Add DWARF CFI annotations to entry, ftrace, rethook, and BPF JIT Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 19/30] riscv/unwind: Add Minimal DWARF CFI kernel unwinder Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 20/30] selftests/perf_events: Add Minimal DWARF CFI deferred user unwind test Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 21/30] scripts: Add eh_frame_min.py .eh_frame coverage and size analyzer Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 22/30] tools headers: Add linux/kmsan-checks.h copy from the kernel sources Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 23/30] tools headers: Add linux/nospec.h " Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 24/30] tools headers: Add linux/unwind_dwarf_cfi.h " Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 25/30] tools include: Add linux/uaccess.h stub for userspace tools Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 26/30] tools/unwind: Add standalone libLLVM Minimal DWARF CFI verifier Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 27/30] tools/unwind: Add multi-arch symbolic instruction lifters for verify_cfi Ian Rogers
2026-11-25  7:05   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 28/30] tools/unwind: Add CFG instruction abstract execution oracle to verify_cfi Ian Rogers
2026-11-25  7:06   ` bot+bpf-ci
2026-11-25  6:15 ` [RFC PATCH v2 29/30] tools/unwind: Add x86-64 ORC cross-check " Ian Rogers
2026-11-25  6:15 ` [RFC PATCH v2 30/30] MAINTAINERS: Add DWARF CFI stack unwinding entry Ian Rogers
2026-11-25 16:28 ` [RFC PATCH v2 00/30] unwind: Minimal DWARF CFI unwinding for user and kernel space Gary Guo
2026-11-25 18:22   ` Steven Rostedt
2026-11-26  4:52     ` Ian Rogers
2026-11-27 15:37       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b3e99b3a-7dd6-4e3a-97a8-3011a5f52569@linux.ibm.com \
    --to=jremus@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=andrii@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=ardb@kernel.org \
    --cc=ast@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=dylanbhatch@google.com \
    --cc=indu.bhagat@oracle.com \
    --cc=irogers@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=oupton@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=peterz@infradead.org \
    --cc=pjw@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=wnliu@google.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox