From: bot+bpf-ci@kernel.org
To: 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,jremus@linux.ibm.com,wnliu@google.com,dylanbhatch@google.com,irogers@google.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yongho
ng.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [RFC PATCH v2 01/30] unwind: Add Minimal DWARF CFI bytecode interpreter
Date: Wed, 25 Nov 2026 07:05:21 +0000 (UTC) [thread overview]
Message-ID: <bfa6da75b5dc0cdd6d9e9227dfa134aa117e4bb14b2a11c911506747c175ae94@mail.kernel.org> (raw)
In-Reply-To: <20261125061523.1540234-2-irogers@google.com>
[-- Attachment #1: Type: text/plain, Size: 6068 bytes --]
> unwind: Add Minimal DWARF CFI bytecode interpreter
TL;DR: Nits only: duplicated DWARF CFI parsing, register-check and CIE-lookup
code could share helpers, and the UNWIND_TABLES Kconfig move may belong in a
later patch or be explained. No bugs found.
> diff --git a/arch/Kconfig b/arch/Kconfig
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -500,6 +500,12 @@ config HAVE_HARDLOCKUP_DETECTOR_ARCH
> It uses the same command line parameters, and sysctl interface,
> as the generic hardlockup detectors.
>
> +config UNWIND_TABLES
> + bool
> +
> +config UNWIND_DWARF_CFI
> + bool
> +
> config UNWIND_USER
> bool
This isn't a bug, but could the move of UNWIND_TABLES into arch/Kconfig go
in the patch that first selects it from another architecture, or could the
changelog say why it is needed here?
[ ... ]
> diff --git a/kernel/unwind/dwarf_cfi.c b/kernel/unwind/dwarf_cfi.c
> --- /dev/null
> +++ b/kernel/unwind/dwarf_cfi.c
[ ... ]
> +static __always_inline int
> +cfi_parse_indirect_cfa_expr(struct dwarf_cfi_stream *s, u32 expr_len,
> + const struct dwarf_cfi_arch *arch,
> + struct dwarf_cfi_row *row, bool is_user)
> +{
> + struct dwarf_cfi_stream es;
> + u8 expr_buf[8], op0, op_end;
> + enum dwarf_cfi_base base;
> + s32 off;
> + int err;
> +
> + if (expr_len < 3 || expr_len > 7)
> + return -EINVAL;
> + /* Prevent Spectre v1.1 speculative stack overflow of expr_buf[8] */
> + barrier_nospec();
> +
> + err = cfi_read_bytes(s, expr_buf, expr_len, is_user);
> + if (err)
> + return err;
> +
> + cfi_stream_init_kmem(&es, expr_buf, expr_len - 1);
> + err = cfi_read_u8(&es, &op0, /*is_user=*/false);
> + if (err)
> + return err;
> +
> + if (arch->fp_reg <= 31 && op0 == (u8)(DW_OP_breg0 + arch->fp_reg))
> + base = DWARF_CFI_BASE_FP_INDIRECT;
> + else if (arch->sp_reg <= 31 && op0 == (u8)(DW_OP_breg0 + arch->sp_reg))
> + base = DWARF_CFI_BASE_SP_INDIRECT;
> + else
> + return -EINVAL;
> +
> + err = cfi_read_sleb128_s32(&es, &off, /*is_user=*/false);
> + if (err || !cfi_stream_empty(&es, /*is_user=*/false))
> + return -EINVAL;
[ ... ]
> +static __always_inline int
> +cfi_parse_reg_expr(struct dwarf_cfi_stream *s, u32 reg, u32 expr_len,
> + const struct dwarf_cfi_arch *arch, u8 ra_reg,
> + struct dwarf_cfi_row *row, bool is_user)
> +{
> + struct dwarf_cfi_stream es;
> + u8 expr_buf[8], op0;
> + enum dwarf_cfi_rule rule;
> + s32 off;
> + int err;
> +
> + if (expr_len < 2 || expr_len > 6)
> + return -EINVAL;
> + /* Prevent Spectre v1.1 speculative stack overflow of expr_buf[8] */
> + barrier_nospec();
> +
> + err = cfi_read_bytes(s, expr_buf, expr_len, is_user);
> + if (err)
> + return err;
> +
> + cfi_stream_init_kmem(&es, expr_buf, expr_len);
> + err = cfi_read_u8(&es, &op0, /*is_user=*/false);
> + if (err)
> + return err;
> +
> + if (arch->fp_reg <= 31 && op0 == (u8)(DW_OP_breg0 + arch->fp_reg))
> + rule = DWARF_CFI_RULE_FP_OFFSET;
> + else if (arch->sp_reg <= 31 && op0 == (u8)(DW_OP_breg0 + arch->sp_reg))
> + rule = DWARF_CFI_RULE_SP_OFFSET;
This isn't a bug, but cfi_parse_indirect_cfa_expr() and cfi_parse_reg_expr()
share almost the same DW_OP_breg decode sequence, including the
barrier_nospec() bounds handling.
Could they use one helper that decodes the breg operand and offset, so each
caller only adds its own trailing check?
[ ... ]
> + if (hi == 0x80) {
> + /* DW_CFA_offset */
> + err = cfi_read_uleb128_u32(s, &uval, is_user);
> + if (err)
> + return err;
> + if (lo == arch->fp_reg || lo == cie->ra_reg ||
> + lo == arch->sp_reg) {
> + err = cfi_factored_offset(uval, cie->data_align, &off);
> + if (err)
> + return err;
> + cfi_apply_reg_rule(lo, DWARF_CFI_RULE_OFFSET,
> + off, arch, cie->ra_reg, row);
> + }
> + continue;
> + }
This isn't a bug, but could the repeated fp/ra/sp check in
dwarf_cfi_exec_insns() become a small inline helper such as
cfi_reg_is_tracked(reg, arch, cie->ra_reg)?
The same three-way test appears in the DW_CFA_offset, DW_CFA_offset_extended,
DW_CFA_offset_extended_sf, DW_CFA_GNU_negative_offset_extended,
DW_CFA_register, DW_CFA_val_offset, DW_CFA_val_offset_sf, DW_CFA_expression
and DW_CFA_val_expression cases, so the set of tracked registers would be
defined in one place.
[ ... ]
> + } else {
> + while (lo < hi) {
> + u32 mid = lo + (hi - lo) / 2;
> + const u8 *ent = table + (size_t)mid * ent_sz;
> + unsigned long e_pc = (unsigned long)ent +
> + (long)(s32)get_unaligned_le32(ent);
> +
> + if (e_pc <= pc)
> + lo = mid + 1;
> + else
> + hi = mid;
> + }
> + if (!lo)
> + return -ENOENT;
> + {
> + const u8 *fent = table + (size_t)(lo - 1) * ent_sz + 4;
> +
> + fde_addr = (unsigned long)fent +
> + (long)(s32)get_unaligned_le32(fent);
> + }
> + }
This isn't a bug, but could the kernel lookup in
dwarf_cfi_unwind_eh_frame_hdr() use eh_hdr_entry_addr() in one binary-search
loop, the way dwarf_cfi_unwind_user_eh_frame_hdr() does, rather than two
hand-written loops and the bare block around fent?
[ ... ]
> + if (cie_delta < 4 ||
> + (size_t)((p + 4) - eh_start) < cie_delta)
> + return -EINVAL;
> + cie = (p + 4) - cie_delta;
> + if (cie < eh_start || cie >= eh_end ||
> + (size_t)(eh_end - cie) < 8)
> + return -EINVAL;
> + cie_len = get_unaligned_le32(cie);
> + if (cie_len <= 4 || cie_len > DWARF_CFI_MAX_CIE_LEN ||
> + (size_t)(eh_end - cie) - 4 < (size_t)cie_len ||
> + get_unaligned_le32(cie + 4) != 0)
> + return -EINVAL;
> +
> + cfi_stream_init_kmem(&cie_s, cie + 8, cie_len - 4);
This isn't a bug, but could the CIE resolution here in
dwarf_cfi_scan_eh_frame_kmem() and the one in dwarf_cfi_eval_fde_kmem() share
a small __always_inline helper?
That way the module index scan and the evaluator could not drift apart on
which CIEs they accept.
---
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
next prev parent reply other threads:[~2026-11-25 7:05 UTC|newest]
Thread overview: 47+ 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 [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-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-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
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=bfa6da75b5dc0cdd6d9e9227dfa134aa117e4bb14b2a11c911506747c175ae94@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--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=eddyz87@gmail.com \
--cc=indu.bhagat@oracle.com \
--cc=irogers@google.com \
--cc=jpoimboe@kernel.org \
--cc=jremus@linux.ibm.com \
--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=martin.lau@kernel.org \
--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
all inboxes | Powered by JetHome®