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 01/30] unwind: Add Minimal DWARF CFI bytecode interpreter
Date: Fri, 27 Nov 2026 16:37:04 +0100 [thread overview]
Message-ID: <a98fab70-48fa-4640-88d2-a7a08f523128@linux.ibm.com> (raw)
In-Reply-To: <20261125061523.1540234-2-irogers@google.com>
Hello Ian,
great work, I like it! I am working on adding s390 support on top of
your series. Some early feedback.
On 11/25/2026 7:14 AM, Ian Rogers wrote:
> Add a strictly bounded DWARF Call Frame Information (.eh_frame /
> .eh_frame_hdr) interpreter (CONFIG_UNWIND_DWARF_CFI) matching SFrame's
> stack-unwinding state model and security properties, without requiring
> new toolchain sections or duplicating user-space unwind metadata.
>
> Instead of implementing a general DWARF expression virtual machine or
> tracking arbitrary architectural register arrays, struct dwarf_cfi_row
> tracks only:
> - CFA = (SP | FP | prologue scratch reg) + cfa_off, or fixed-pattern
> indirect CFA *(FP + off) (DRAP stack realignment) / *(SP + off)
> (signal trampolines)
> - Stack pointer save rule (SAME or *(CFA + off)) for signal frames that
> save SP in sigcontext (such as 32-bit x86 vdso32 __kernel_rt_sigreturn)
> - Frame pointer save rule (SAME, *(CFA + off), *(FP + off), *(SP + off))
> - Return address save rule (SAME in link register, *(CFA + off),
> *(SP + off), or UNDEFINED for bottom-of-stack termination), plus
> AArch64 PAC-RET signing state (DW_CFA_AARCH64_negate_ra_state)
>
> Callee-saved general-purpose register spill/restore opcodes are decoded
> and ignored in O(1) space. General DW_OP_* expressions, DW_CFA_set_loc
> backward PC jumps, and DW_CFA_register rules on {SP, FP, RA} are
> rejected with -EINVAL; DW_EH_PE_indirect encodings are rejected whenever
> an encoded address is evaluated (while unused 'P'/'L' CIE augmentation
> fields are skipped by encoded width without dereferencing). CIEs
> (<= 128 B), FDEs (<= 4096 B), LEB128 operands (<= 5 B), and
> DW_CFA_remember_state nesting (<= 4 entries) execute in a single forward
> pass with zero dynamic memory allocations, zero locks, KMSAN output
> unpoisoning, noinstr kernel-memory entry points, and Spectre v1 / v1.1
> nospec hardening (array_index_nospec() and barrier_nospec()).
>
> Also provide shared RCU-safe loadable-module .eh_frame indexing helpers
> using kvmalloc()/kvfree_rcu_mightsleep() (dwarf_cfi_mod_alloc(),
> dwarf_cfi_mod_free_rcu(), dwarf_cfi_mod_eval()).
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> diff --git a/include/linux/unwind_dwarf_cfi.h b/include/linux/unwind_dwarf_cfi.h
> +/**
> + * enum dwarf_cfi_rule - Recovery rule for caller's SP, FP, or return address
> + * @DWARF_CFI_RULE_SAME: Register retains its value from the current frame
> + * (or defaults to CFA for SP).
> + * @DWARF_CFI_RULE_OFFSET: Saved on the stack at *(CFA + off).
> + * @DWARF_CFI_RULE_FP_OFFSET: Saved relative to FP at *(FP + off) (DRAP frame).
> + * @DWARF_CFI_RULE_SP_OFFSET: Saved relative to SP at *(SP + off) (sigframe).
For s390 support I plan to add the following:
For the implicit DW_CFA_val_offset(SP, -160) rule, as the CFA is defined
as SP at call site + 160:
* @DWARF_CFI_RULE_VAL_OFFSET: Value is CFA + off; only used for SP.
For DW_CFA_register (mostly used in lead functions to save FP and RA as
well as SP):
* @DWARF_CFI_RULE_REG[ISTER]: Saved in another register.
> + * @DWARF_CFI_RULE_UNDEFINED: Explicitly undefined (DW_CFA_undefined); marks
> + * the bottom of a stack (e.g. _start or clone).
> + */
> +enum dwarf_cfi_rule {
> + DWARF_CFI_RULE_SAME = 0,
> + DWARF_CFI_RULE_OFFSET,
> + DWARF_CFI_RULE_FP_OFFSET,
> + DWARF_CFI_RULE_SP_OFFSET,
> + DWARF_CFI_RULE_UNDEFINED,
> +};
> +
> +/**
> + * struct dwarf_cfi_arch - Architecture DWARF register numbers and word size
For s390 support I plan to add:
* @sp_off: Initial SP offset from the CFA unless a CIE instruction says
* otherwise, caller SP = CFA + @sp_off.
* 0 on most ABIs; -160 on s390, where CFA = caller SP + 160.
That would be used in dwarf_cfi_parse_cie() to initialize the SP rule
and offset.
> + * @ws: Target address/word size in bytes (4 or 8).
> + * @sp_reg: DWARF register number for the stack pointer.
> + * @fp_reg: DWARF register number for the frame pointer.
> + * @ra_reg: Default DWARF return-address column number.
> + */
> +struct dwarf_cfi_arch {
> + u8 ws;
> + u8 sp_reg;
> + u8 fp_reg;
> + u8 ra_reg;
> +};
> +
> +/**
> + * struct dwarf_cfi_row - Evaluated Minimal DWARF unwind state at a target PC
> + * @cfa_off: Byte offset added to the CFA base register before or as the CFA.
As a non-native speaker I have a hard time to understand that comment.
Wouldn't the following suffice?
* @cfa_off: Byte offset added to the CFA base register.
> + * @sp_off: Byte offset used to load the saved SP when @sp_rule is an offset.
> + * @fp_off: Byte offset used to load the saved FP when @fp_rule is an offset.
> + * @ra_off: Byte offset used to load the saved RA when @ra_rule is an offset.
> + * @cfa_base: CFA computation mode (&enum dwarf_cfi_base).
What about renaming to cfa_rule? That would nicely align with the
{sp|fp|ra}_rule and *_reg.
> + * @cfa_reg: DWARF register number when @cfa_base is %DWARF_CFI_BASE_REG.
For s390 support I plan to add the following to support DW_CFA_register:
* @sp_reg: DWARF register number containing the saved SP when @sp_rule is a register.
* @fp_reg: DWARF register number containing the saved FP when @fp_rule is a register.
* @ra_reg: DWARF register number containing the saved RA when @ra_rule is a register.
> + * @sp_rule: Recovery rule for the stack pointer (&enum dwarf_cfi_rule;
> + * %DWARF_CFI_RULE_SAME indicates caller SP equals CFA).
> + * @fp_rule: Recovery rule for the frame pointer (&enum dwarf_cfi_rule).
> + * @ra_rule: Recovery rule for the return address (&enum dwarf_cfi_rule).
> + * @signal: True if the CIE carries the 'S' signal/interrupt frame augmentation,
> + * indicating that the saved PC points directly to the interrupted
> + * instruction rather than after a call instruction.
> + * @ra_signed: True on AArch64 when DW_CFA_AARCH64_negate_ra_state indicates
> + * that the saved return address carries a PAC signature.
> + */
> +struct dwarf_cfi_row {
> + s32 cfa_off;
> + s32 sp_off;
> + s32 fp_off;
> + s32 ra_off;
> + u8 cfa_base;
> + u8 cfa_reg;
> + u8 sp_rule;
> + u8 fp_rule;
> + u8 ra_rule;
> + bool signal;
> + 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/
next prev parent reply other threads:[~2026-11-27 15:38 UTC|newest]
Thread overview: 61+ 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 6:32 ` sashiko-bot
2026-11-25 7:05 ` bot+bpf-ci
2026-11-27 15:37 ` Jens Remus [this message]
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
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:32 ` sashiko-bot
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 6:47 ` sashiko-bot
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 6:37 ` sashiko-bot
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 6:38 ` sashiko-bot
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:40 ` sashiko-bot
2026-11-25 6:15 ` [RFC PATCH v2 30/30] MAINTAINERS: Add DWARF CFI stack unwinding entry Ian Rogers
2026-11-25 6:48 ` [RFC PATCH v2 00/30] unwind: Minimal DWARF CFI unwinding for user and kernel space sashiko-bot
2026-11-25 16:28 ` 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=a98fab70-48fa-4640-88d2-a7a08f523128@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