Skip to content

Commit cfec846

Browse files
committed
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: eec3796 ("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
1 parent f3ef7db commit cfec846

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/powerpc/tools/ftrace-gen-ool-stubs.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ if [ -z "$is_64bit" ]; then
1515
RELOCATION=R_PPC_ADDR32
1616
fi
1717

18-
num_ool_stubs_text=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
19-
grep -v ".init.text" | grep -c "$RELOCATION")
18+
num_ool_stubs_total=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
19+
grep -c "$RELOCATION")
2020
num_ool_stubs_inittext=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
21-
grep ".init.text" | grep -c "$RELOCATION")
21+
grep -e ".init.text" -e ".text.startup" | grep -c "$RELOCATION")
22+
num_ool_stubs_text=$((num_ool_stubs_total - num_ool_stubs_inittext))
2223

2324
if [ "$num_ool_stubs_text" -gt "$num_ool_stubs_text_builtin" ]; then
2425
num_ool_stubs_text_end=$((num_ool_stubs_text - num_ool_stubs_text_builtin))

0 commit comments

Comments
 (0)