Skip to content

unwind, arm64: add sframe unwinder for kernel

Dylan Hatch linux-arm-kernel linux-toolchains live-patching lkml 8 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest11 patches 0 repliesNew
  2. v811 patches 1 replySuperseded
  3. v711 patches 0 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v69 patches1 replySuperseded
v58 patches27 repliesSuperseded
v48 patches7 repliesSuperseded
v38 patches21 repliesSuperseded
v26 patches20 repliesSuperseded

Patches in v9 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11arm64, unwind: build kernel with sframe V3 infoMAINTAINERS Makefile arch/Kconfig +10 more+96 -120 replies
2/11arm64/sframe: Read vmlinux .sframe headerMAINTAINERS arch/arm64/kernel/setup.c include/linux/sframe.h +3 more+201 -10 replies
3/11sframe: Add support for reading vmlinux .sframe contentsinclude/linux/sframe.h include/linux/unwind_types.h kernel/unwind/sframe.c +1 more+393 -10 replies
4/11sframe: Separate reading of FRE from reading of FRE data wordskernel/unwind/sframe.c+73 -240 replies
5/11module, sframe: Add sframe support for modulesinclude/linux/module.h include/linux/sframe.h kernel/module/main.c +1 more+146 -50 replies
6/11arm64/sframe: Validate IP addressesMAINTAINERS arch/arm64/include/asm/sections.h arch/arm64/include/asm/unwind_sframe.h +6 more+91 -60 replies
7/11sframe: Add debug helpers with object namekernel/unwind/sframe.c kernel/unwind/sframe_debug.h+45 -40 replies
8/11sframe: Add .sframe validation optionarch/Kconfig kernel/unwind/sframe.c+96 -00 replies
9/11arm64: entry: add unwind info for call_on_irq_stack()arch/arm64/kernel/entry.S+16 -10 replies
10/11arm64, crypto/lib: Annotate leaf functions with CFI infoarch/arm64/crypto/aes-ce-ccm-core.S arch/arm64/crypto/aes-neonbs-core.S arch/arm64/crypto/ghash-ce-core.S +22 more+181 -1510 replies
11/11unwind: arm64: Use sframe to unwind interrupt framesarch/arm64/kernel/stacktrace.c+198 -130 replies

Reviews trailers per patch

9 of 11 patches have a Reviewed-by or Acked-by.

PatchPrasanna Kumar T S MJens RemusIndu Bhagat
1/11R-b R-b
2/11R-b
3/11R-b
4/11R-b
5/11R-b
6/11
7/11R-b
8/11R-b
9/11R-b
10/11
11/11R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v9 thread

Cover letter [PATCH v9 00/11] unwind, arm64: add sframe unwinder for kernel

Implement a generic kernel sframe-based [1] unwinder. The main goal is to improve reliable stacktrace on arm64 by unwinding across exception boundaries.

On x86, the ORC unwinder provides reliable stacktrace through similar methodology, but arm64 lacks the necessary support from objtool to create ORC unwind tables.

Currently, there is a sframe unwinder proposed for userspace [2], along with an RFC for an .eh_frame unwinder [5]. This patch series implements a similar SFrame lookup library to [2], but with many simplifications to account for the fact that user access is not necessary. The intent here is to continue to leave the door open for common usage of definitions and algorithms between kernel and user unwind in the future, while at the same time keeping these patches strictly constrained the minimal set of features necessary for arm64 kernel unwind.

Unlike past versions of this series, these patches apply directly to v7.4-rc1 rather than depending upon [2]. To make this possible, I've adopted a number of patches from [2] with significant squashes and changes made in order to coherently suit the kernel unwind use case. I've done my best to maintain appropriate authorship on these changes, and have added 'Co-developed-by' trailers to attribute shared authorship as accurately as possible. Please let me know if you see any discrepencies in my work here.

Currently, only GNU Binutils support sframe. This series relies on the Sframe V3 format, which is supported in binutils 2.46.

This full series is available on github: [4].

Ref:
[1]: https://sourceware.org/binutils/docs/sframe-spec.html
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git/log/?h=sframe/core
[4]: https://github.com/dylanbhatch/linux/tree/sframe-v9
[5]: https://lore.kernel.org/all/[email protected]/

---

Summary of changes since v8:
- Rebase onto v7.4-rc1, resolving merge conflicts in Makefile and arch/arm64/lib/strncmp.S and dropping arch/arm64/lib/clear_page.S (removed upstream).
- (sashiko) Add 'depends on !RUST' to HAVE_UNWIND_KERNEL_SFRAME and keep KBUILD_RUSTFLAGS conditioned only on CONFIG_UNWIND_TABLES.
- (sashiko) Move STACK UNWINDING entry in MAINTAINERS to alphabetical order and add unwind_sframe.h patterns in the patch introducing them.
- (sashiko) Filter out $(CC_FLAGS_SFRAME) in efi/libstub, arm64 pi, and arm64 kvm/hyp/nvhe Makefiles where unwind tables are disabled.
- (sashiko) Guard SFrame header, FDE, and FRE bounds calculations against integer overflow.
- (sashiko) Preserve KASAN, KCSAN, and ftrace exclusions on sframe.o in kernel/unwind/Makefile, and clean up header includes across sframe.h, sframe_debug.h, module.h, and kernel/module/main.c.
- (sashiko) Mark is_kernel_inittext(), __is_kernel_text(), and within_module_mem_type() as __always_inline for noinstr sframe_find().
- (sashiko) Provide generic include/asm-generic/unwind_sframe.h fallback and move <asm/unwind_sframe.h> include to the IP validation patch.
- (sashiko) Update CONFIG_SFRAME_VALIDATION help text and commit log for in-kernel vmlinux and module .sframe validation.
- (sashiko) Place .cfi_startproc before 'bti c' in call_on_irq_stack() using SYM_START().
- (sashiko) Move out-of-line blocks in pmull_gcm_ghash_4x() and pmull_gcm_enc_4x() out of '.subsection 1' and annotate __pi_strrchr with SYM_LEAF_FUNC_START / SYM_LEAF_FUNC_END.
- (sashiko) Restrict SFrame unwinding at KUNWIND_SOURCE_REGS_PC to real on-stack FRAME_META_TYPE_PT_REGS exception frames, drop invalid cross-stack 'fp < sp' check in UNWIND_CFA_RULE_FP_OFFSET, enforce 8-byte alignment in get_word(), and propagate state->unreliable on -ENOENT in do_kunwind().

Summary of changes since v7:
- (sashiko): Put .cfi_startproc right after SYM_START to account for potential alignment bytes ahead of the actual function symbol.
- (sashiko) Use __always_inline for IP validation helper.
- (sashiko) Move .sframe module init and sframe section fields to arch generic code.
- (sashiko) Make sframe_find() noinstr.
- (sashiko) Add preempt_notrace and instrumentation to __sframe_module_find() code path.
- (sashiko) Block tracing and kprobe on the sframe_find code path.
- (shashiko) remove KCOV, KCSAN, and KASAN instrumentation from sframe.o (copying over ORC's shoulder).

Dylan Hatch (6):
arm64, unwind: build kernel with sframe V3 info module, sframe: Add sframe support for modules arm64/sframe: Validate IP addresses
sframe: Add debug helpers with object name arm64, crypto/lib: Annotate leaf functions with CFI info
unwind: arm64: Use sframe to unwind interrupt frames

Jens Remus (1):
sframe: Separate reading of FRE from reading of FRE data words

Josh Poimboeuf (3):
arm64/sframe: Read vmlinux .sframe header
sframe: Add support for reading vmlinux .sframe contents
sframe: Add .sframe validation option

Weinan Liu (1):
arm64: entry: add unwind info for call_on_irq_stack()

 MAINTAINERS                            |  17 +-
 Makefile                               |   8 +
 arch/Kconfig                           |  51 ++
 arch/arm64/Kconfig                     |   1 +
 arch/arm64/Makefile                    |   8 +-
 arch/arm64/crypto/aes-ce-ccm-core.S    |  12 +-
 arch/arm64/crypto/aes-neonbs-core.S    |  16 +-
 arch/arm64/crypto/ghash-ce-core.S      |  76 ++-
 arch/arm64/crypto/sm4-ce-ccm-core.S    |  16 +-
 arch/arm64/crypto/sm4-ce-cipher-core.S |   4 +-
 arch/arm64/crypto/sm4-ce-core.S        |  44 +-
 arch/arm64/crypto/sm4-ce-gcm-core.S    |  16 +-
 arch/arm64/crypto/sm4-neon-core.S      |  12 +-
 arch/arm64/include/asm/linkage.h       |  32 ++
 arch/arm64/include/asm/module.lds.h    |   2 +
 arch/arm64/include/asm/sections.h      |   1 +
 arch/arm64/include/asm/unwind_sframe.h |  32 ++
 arch/arm64/kernel/entry.S              |  17 +-
 arch/arm64/kernel/pi/Makefile          |   3 +
 arch/arm64/kernel/setup.c              |   2 +
 arch/arm64/kernel/stacktrace.c         | 211 +++++++-
 arch/arm64/kernel/vdso/Makefile        |   2 +-
 arch/arm64/kernel/vmlinux.lds.S        |  14 +
 arch/arm64/kvm/hyp/nvhe/Makefile       |   5 +-
 arch/arm64/lib/clear_user.S            |   4 +-
 arch/arm64/lib/copy_from_user.S        |   4 +-
 arch/arm64/lib/copy_page.S             |   4 +-
 arch/arm64/lib/copy_to_user.S          |   4 +-
 arch/arm64/lib/memchr.S                |   4 +-
 arch/arm64/lib/memcmp.S                |   4 +-
 arch/arm64/lib/memcpy.S                |   8 +-
 arch/arm64/lib/memset.S                |   8 +-
 arch/arm64/lib/mte.S                   |  28 +-
 arch/arm64/lib/strchr.S                |   4 +-
 arch/arm64/lib/strcmp.S                |   4 +-
 arch/arm64/lib/strlen.S                |   4 +-
 arch/arm64/lib/strncmp.S               |   4 +-
 arch/arm64/lib/strnlen.S               |   4 +-
 arch/arm64/lib/strrchr.S               |   4 +-
 arch/arm64/lib/tishift.S               |  12 +-
 drivers/firmware/efi/libstub/Makefile  |   2 +
 include/asm-generic/Kbuild             |   1 +
 include/asm-generic/sections.h         |   8 +-
 include/asm-generic/unwind_sframe.h    |   5 +
 include/asm-generic/vmlinux.lds.h      |  15 +
 include/linux/module.h                 |  11 +-
 include/linux/sframe.h                 |  42 ++
 include/linux/unwind_types.h           |  34 ++
 kernel/module/main.c                   |  20 +
 kernel/unwind/Makefile                 |   9 +-
 kernel/unwind/sframe.c                 | 714 +++++++++++++++++++++++++
 kernel/unwind/sframe.h                 |  79 +++
 kernel/unwind/sframe_debug.h           |  38 ++
 53 files changed, 1501 insertions(+), 183 deletions(-)
 create mode 100644 arch/arm64/include/asm/unwind_sframe.h
 create mode 100644 include/asm-generic/unwind_sframe.h
 create mode 100644 include/linux/sframe.h
 create mode 100644 include/linux/unwind_types.h
 create mode 100644 kernel/unwind/sframe.c
 create mode 100644 kernel/unwind/sframe.h
 create mode 100644 kernel/unwind/sframe_debug.h
Signature · 1 line
2.56.0.679.gc527c65306-goog