linux-stable/arch/powerpc/tools
Michael Ellerman cfec8463d9 powerpc/ftrace: Fix ftrace bug with KASAN=y
Booting a KASAN=y kernel with the recently added ftrace out-of-line
support causes a warning at boot:

  ------------[ cut here ]------------
  Stub index overflow (1729 > 1728)
  WARNING: CPU: 0 PID: 0 at arch/powerpc/kernel/trace/ftrace.c:209 ftrace_init_nop+0x408/0x444
  ...
  NIP ftrace_init_nop+0x408/0x444
  LR  ftrace_init_nop+0x404/0x444
  Call Trace:
    ftrace_init_nop+0x404/0x444 (unreliable)
    ftrace_process_locs+0x544/0x8a0
    ftrace_init+0xb4/0x22c
    start_kernel+0x1dc/0x4d4
    start_here_common+0x1c/0x20
  ...
  ftrace failed to modify
  [<c0000000030beddc>] _sub_I_65535_1+0x8/0x3c
   actual:   00:00:00:60
  Initializing ftrace call sites
  ftrace record flags: 0
   (0)
   expected tramp: c00000000008b418
  ------------[ cut here ]------------

The function in question, _sub_I_65535_1 is some sort of trampoline
generated for KASAN, and is in the .text.startup section. That section
is part of INIT_TEXT, meaning is_kernel_inittext() returns true for it.

But the script that determines how many out-of-line ftrace stubs are
needed isn't doesn't consider .text.startup as inittext, leading to
there not being enough space for the init stubs.

Conversely the logic to calculate how many stubs are needed for the text
section isn't filtering out the symbols in .text.startup and so ends up
over counting.

Fix both problems by calculating the total number of stubs first, then
the number that count as inittext, and then subtract the latter from the
former to get the count for the text section.

Fixes: eec37961a5 ("powerpc64/ftrace: Move ftrace sequence out of line")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20241107111630.31068-1-mpe@ellerman.id.au
2024-11-10 22:33:51 +11:00
..
.gitignore powerpc64/ftrace: Move ftrace sequence out of line 2024-10-31 11:00:54 +11:00
checkpatch.sh powerpc/tools: Remove 90 line limit in checkpatch script 2020-09-08 22:57:11 +10:00
ftrace_check.sh powerpc/ftrace: Add a postlink script to validate function tracer 2024-10-31 11:00:54 +11:00
ftrace-gen-ool-stubs.sh powerpc/ftrace: Fix ftrace bug with KASAN=y 2024-11-10 22:33:51 +11:00
gcc-check-fpatchable-function-entry.sh powerpc/ftrace: Add support for -fpatchable-function-entry 2023-08-22 00:09:06 +10:00
gcc-check-mprofile-kernel.sh powerpc/tools: Pass -mabi=elfv2 to gcc-check-mprofile-kernel.sh 2023-10-20 17:46:33 +11:00
head_check.sh powerpc/head_check: Fix shellcheck errors 2021-08-17 22:52:02 +10:00
Makefile powerpc64/ftrace: Support .text larger than 32MB with out-of-line stubs 2024-10-31 11:00:55 +11:00
relocs_check.sh powerpc: Move script to check relocations at compile time in scripts/ 2023-04-19 07:46:31 -07:00
unrel_branch_check.sh powerpc: unrel_branch_check.sh: enable the use of llvm-objdump v9, 10 or 11 2020-09-02 11:00:22 +10:00