Skip to content

s390: Add kCFI support

Heiko Carstens bpf linux-s390 lkml llvm 2 versions – Applied

Status from this message: Applied, thank you!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 7 repliesApplied
  2. v16 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Select ARCH_USES_CFI_GENERIC_LLVM_PASS [Nathan Chancellor]
- Add CONFIG_FUNCTION_GRAPH_TRACER guard to ftrace stub [bot+bpf-ci]
- Add additional CFI offset adjustments to bpf code [sashiko-bot]
- Move bpf patch before ARCH_SUPPORTS_CFI is selected, since there are functions with missing __bpfcall atttribute [sashiko-bot]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/6s390/tools: Pass symbol name to do_relocs()arch/s390/tools/relocs.c+139 -30 replies
2/6s390/tools/relocs: Ignore __kcfi_typeid_ relocationsarch/s390/tools/relocs.c+16 -00 replies
3/6s390: Add ftrace_stub_grapharch/s390/kernel/mcount.S+8 -10 replies
4/6s390/diag: Generate CFI type information for assembly functionsarch/s390/kernel/text_amode31.S+7 -60 replies
5/6s390/bpf: Add kCFI supportarch/s390/include/asm/cfi.h arch/s390/net/bpf_jit_comp.c+31 -42 replies
6/6s390/Kconfig: Select ARCH_SUPPORTS_CFIarch/s390/Kconfig+2 -00 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchJens RemusIlya LeoshkevichNathan Chancellor
SeriesT-b
1/6R-b
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-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 v2 thread

Cover letter [PATCH v2 0/6] s390: Add kCFI support

v2:
- Select ARCH_USES_CFI_GENERIC_LLVM_PASS [Nathan Chancellor]
- Add CONFIG_FUNCTION_GRAPH_TRACER guard to ftrace stub [bot+bpf-ci]
- Add additional CFI offset adjustments to bpf code [sashiko-bot]
- Move bpf patch before ARCH_SUPPORTS_CFI is selected, since there are functions with missing __bpfcall atttribute [sashiko-bot]

v1:
Add s390 kCFI support using the generic support provided by clang. This comes with a couple of limitations:

The generic kCFI implementation does not generate a .kcfi_traps section, nor is a special instruction used in case a checksum mismatch is detected.

This means in case of a checksum mismatch the kernel just crashes. It should be quite easy to tell by the surrounding code that a crash happened because of a checksum mismatch.

If clang and/or gcc provide a .kcfi_traps section it will be possible to print proper CFI messages instead of just crashing the kernel (enable ARCH_USES_CFI_TRAPS).

In addition this also means that CFI_PERMISSIVE does not work. Even if the option is selected the kernel will crash in case of a checksum mismatch.

However it seems to be acceptable to enable kCFI support to the kernel now even if it is not perfect. Later s390 specific clang and gcc extensions are required to improve this.

This passes all ftrace selftests. It also passes the kernel bpf selftests (vmtest.sh), except those using the task work scheduling kfuncs. However that appears to be a real bug and has been reported [1]. (Update: fix for [1] is available [2]).

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Thanks,
Heiko

Heiko Carstens (6):
s390/tools: Pass symbol name to do_relocs() s390/tools/relocs: Ignore __kcfi_typeid_ relocations
s390: Add ftrace_stub_graph
s390/diag: Generate CFI type information for assembly functions s390/bpf: Add kCFI support
s390/Kconfig: Select ARCH_SUPPORTS_CFI

 arch/s390/Kconfig               |   2 +
 arch/s390/include/asm/cfi.h     |   7 ++
 arch/s390/kernel/mcount.S       |   9 +-
 arch/s390/kernel/text_amode31.S |  13 +--
 arch/s390/net/bpf_jit_comp.c    |  28 +++++-
 arch/s390/tools/relocs.c        | 158 +++++++++++++++++++++++++++++++-
 6 files changed, 203 insertions(+), 14 deletions(-)
 create mode 100644 arch/s390/include/asm/cfi.h
Signature · 1 line
2.53.0