linux/scripts
Wang Han 57ad674d03 scripts/sorttable: Handle RISC-V patchable ftrace entries
RISC-V uses -fpatchable-function-entry=8,4 when the compressed ISA is
enabled and -fpatchable-function-entry=4,2 otherwise. In both cases, the
patchable NOP area starts 8 bytes before the function symbol address.
The __mcount_loc entries therefore point at the patchable NOP area
associated with a function, while nm reports the function symbol at the
entry address used for the function range check.

After RISC-V selected HAVE_BUILDTIME_MCOUNT_SORT, sorttable started
applying that range check at build time. Without allowing entries just
before the reported function address, the mcount sorter treats valid
RISC-V ftrace callsites as invalid weak-function entries and writes
them back as zero. The resulting kernel boots with no ftrace entries,
breaking dynamic ftrace and users such as livepatch.

The failure is silent during the final link because zeroing weak-function
entries is an expected sorttable operation. At boot, those zero entries
are skipped by ftrace_process_locs(), so the only obvious symptom is that
the vmlinux ftrace table has lost valid callsites and ftrace users cannot
attach to them.

CONFIG_FTRACE_SORT_STARTUP_TEST also reports the table as sorted in this
state: it only checks that the __mcount_loc entries are in ascending
order, which a fully zeroed table trivially satisfies. The original
commit relied on this check and did not see the regression.

On an affected RISC-V QEMU boot with both CONFIG_FTRACE_SORT_STARTUP_TEST
and CONFIG_FTRACE_STARTUP_TEST enabled, the sort check still passes
while ftrace reports zero usable entries and the early selftests fail:

  [    0.000000] ftrace section at ffffffff8101da98 sorted properly
  [    0.000000] ftrace: allocating 0 entries in 128 pages
  [    0.054999] Testing tracer function: .. no entries found ..FAILED!
  [    0.172407] tracer: function failed selftest, disabling
  [    0.178186] Failed to init function_graph tracer, init returned -19

Handle RISC-V like arm64 for the function-range check and allow
patchable entries up to 8 bytes before the function address.

With this fix, a RISC-V QEMU smoke boot with ftrace startup tests shows
the vmlinux ftrace table is populated and dynamic ftrace still works:

  [    0.000000] ftrace: allocating 46749 entries in 184 pages
  [    0.051115] Testing tracer function: PASSED
  [    1.283782] Testing dynamic ftrace: PASSED
  [    6.275456] Testing tracer function_graph: PASSED

Fixes: 0ca1724b56af ("riscv: ftrace: select HAVE_BUILDTIME_MCOUNT_SORT")
Suggested-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>
Reviewed-by: Chen Pei <cp0613@linux.alibaba.com>
Link: https://lore.kernel.org/all/20260527113028.4b21a5de@fedora/
Signed-off-by: Wang Han <wanghan@linux.alibaba.com>
Reviewed-by: Martin Kaiser <martin@kaiser.cx>
Link: https://patch.msgid.link/20260609063002.3943001-1-wanghan@linux.alibaba.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-06-25 13:15:03 -06:00
..
atomic rust: helpers: Move #define __rust_helper out of atomic.c 2026-01-09 19:01:42 +08:00
bash-completion
basic
clang-tools linux_kselftest-kunit-7.2-rc1 2026-06-16 16:33:57 +05:30
coccinelle coccinelle: kmalloc_obj: Remove default GFP_KERNEL arg 2026-03-20 10:52:52 -07:00
crypto lib/crypto: tests: Add KUnit tests for SM3 2026-03-23 17:50:59 -07:00
dtc dt-bindings: add self-test fixtures for style checker 2026-06-10 13:37:06 -05:00
dummy-tools kbuild: dummy-tools: Add python3 2026-01-29 17:12:13 -07:00
gcc-plugins gcc-plugins: Always define CONST_CAST_GIMPLE and CONST_CAST_TREE 2026-05-14 09:24:32 -07:00
gdb Updates for the NOHZ subsystem: 2026-06-15 13:48:52 +05:30
gendwarfksyms gendwarfksyms: Fix build on 32-bit hosts 2025-12-22 16:35:54 +00:00
genksyms genksyms: Fix parsing a declarator with a preceding attribute 2026-02-26 11:53:05 -07:00
include
ipe
kconfig Second round of Kbuild changes for 7.2 2026-06-25 09:06:12 -07:00
ksymoops
livepatch klp-build: Validate short-circuit prerequisites 2026-05-04 21:16:06 -07:00
mod Second round of Kbuild changes for 7.2 2026-06-25 09:06:12 -07:00
package Kbuild / Kconfig changes for 7.2 2026-06-15 05:01:15 +05:30
sbom scripts/sbom: add unit tests for SPDX-License-Identifier parsing 2026-05-22 13:14:41 +02:00
selinux
tracing
.gitignore scripts: add tracepoint-update to the list of ignores files 2025-10-29 08:46:05 -04:00
as-version.sh
asn1_compiler.c
bloat-o-meter scripts/bloat-o-meter: ignore _sdata 2026-05-28 21:24:48 -07:00
bootgraph.pl
bpf_doc.py bpf: Finish constification of 1st parameter of bpf_d_path() 2025-10-04 09:05:23 -07:00
build-version
cc-can-link.sh kbuild: Fix CC_CAN_LINK detection 2026-02-13 14:23:06 -05:00
cc-version.sh
check_extable.sh
check-function-names.sh kbuild: prefer ${NM} in check-function-names.sh 2026-01-14 14:13:41 +01:00
check-git
check-sysctl-docs
check-uapi.sh check-uapi: use dummy libc includes 2026-03-20 21:43:56 +01:00
checkdeclares.pl
checker-valid.sh compiler: Use __typeof_unqual__() for __unqual_scalar_typeof() 2026-01-18 10:32:03 +01:00
checkincludes.pl
checkkconfigsymbols.py
checkpatch.pl mm.git review status for mm-hotfixes-stable..mm-nonmm-stable 2026-06-21 13:20:19 -07:00
checkstack.pl
checksyscalls.sh checksyscalls: only run when necessary 2026-04-05 09:21:31 +02:00
checkversion.pl
cleanfile
cleanpatch
coccicheck scripts: coccicheck: warn on unset debug file 2026-02-21 17:22:30 +01:00
config
const_structs.checkpatch
container scripts: add tool to run containerized builds 2026-01-22 15:30:48 -07:00
context-analysis-suppression.txt locking/rtmutex: Add context analysis 2026-03-08 11:06:53 +01:00
decode_stacktrace.sh decode_stacktrace: decode caller address 2026-03-27 21:19:45 -07:00
decodecode scripts/decodecode: return 0 on success 2026-03-27 21:19:48 -07:00
depmod.sh
dev-needs.sh
diffconfig
elf-parse.c sorttable: Move ELF parsing into scripts/elf-parse.[ch] 2025-10-24 16:43:14 -04:00
elf-parse.h sorttable: Move ELF parsing into scripts/elf-parse.[ch] 2025-10-24 16:43:14 -04:00
extract_xc3028.pl
extract-fwblobs
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
faddr2line scripts/faddr2line: Fix "Argument list too long" error 2025-10-14 14:45:20 -07:00
file-size.sh
gen_packed_field_checks.c
gen-btf.sh scripts/gen-btf.sh: Use CONFIG_SHELL for execution 2026-01-21 12:36:32 -08:00
gen-crc-consts.py
gen-randstruct-seed.sh
generate_builtin_ranges.awk
generate_initcall_order.pl
generate_rust_analyzer.py rust: zerocopy-derive: enable support in kbuild 2026-06-09 04:13:23 +02:00
generate_rust_target.rs s390 updates for 7.2 merge window 2026-06-16 05:08:13 +05:30
get_dvb_firmware
get_maintainer.pl get_maintainer: add --json output mode 2026-05-28 21:24:42 -07:00
gfp-translate
git-resolve.sh
git.orderFile
head-object-list.txt
headerdep.pl
headers_install.sh scripts: headers_install.sh: Remove config leak ignore machinery 2026-01-30 16:46:17 +01:00
insert-sys-cert.c
install.sh
integer-wrap-ignore.scl
jobserver-exec scripts/jobserver-exec: propagate child exit status 2026-06-10 13:37:05 -05:00
kallsyms.c kallsyms: Get rid of kallsyms relative base 2026-01-22 15:58:22 -07:00
Kbuild.include
Kconfig.include rust: kconfig: Don't require RUST_IS_AVAILABLE for rustc-option 2026-02-03 15:29:17 -07:00
kernel-doc docs: add a scripts/kernel-doc symbolic link 2026-01-20 15:57:06 -07:00
ld-version.sh
leaking_addresses.pl
Lindent
link-vmlinux.sh Kbuild/Kconfig updates for 7.0 2026-02-11 13:40:35 -08:00
macro_checker.py
make_fit.py scripts/make_fit.py: Drop explicit LZMA parallel compression 2026-02-13 14:24:01 -05:00
Makefile sign-file: use 'struct module_signature' from the UAPI headers 2026-03-24 21:42:37 +00:00
Makefile.asm-headers
Makefile.autofdo kbuild: rust: rename flag to -Zdebuginfo-for-profiling for Rust >= 1.98 2026-06-04 09:26:57 +02:00
Makefile.btf kbuild, bpf: Specify "layout" optional feature 2026-03-26 13:53:57 -07:00
Makefile.build rust: zerocopy-derive: enable support in kbuild 2026-06-09 04:13:23 +02:00
Makefile.clang
Makefile.clean
Makefile.compiler rust: kasan/kbuild: fix rustc-option when cross-compiling 2026-05-26 09:44:54 +02:00
Makefile.context-analysis compiler-context-analysis: Introduce header suppressions 2026-01-05 16:43:33 +01:00
Makefile.debug
Makefile.defconf
Makefile.dtbinst
Makefile.dtbs scripts/dtc: Update to upstream version v1.7.2-62-ga26ef6400bd8 2026-02-03 20:58:12 -06:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.host
Makefile.kasan rust: kasan: add support for Software Tag-Based KASAN 2026-05-27 01:54:22 +02:00
Makefile.kcov
Makefile.kcsan
Makefile.kmsan
Makefile.kstack_erase
Makefile.lib Objtool updates for v7.2: 2026-06-15 14:31:58 +05:30
Makefile.modfinal kbuild/btf: Remove broken module relinking exclusion 2026-04-29 18:03:49 -07:00
Makefile.modinst kbuild: Use objtree for module signing key path 2025-11-08 12:17:58 +01:00
Makefile.modpost
Makefile.package kbuild: modules-cpio-pkg: Respect INSTALL_MOD_PATH 2026-03-30 07:38:26 +02:00
Makefile.propeller
Makefile.randstruct
Makefile.thinlto kbuild: distributed build support for Clang ThinLTO 2026-05-29 13:44:29 -07:00
Makefile.ubsan
Makefile.userprogs
Makefile.vdsoinst kbuild: vdso_install: drop build ID architecture allow-list 2026-04-02 17:50:40 +02:00
Makefile.vmlinux bpf-next-7.0 2026-02-10 11:26:21 -08:00
Makefile.vmlinux_a kbuild: Remove unnecessary 'T' modifier in cmd_ar_builtin_fixup 2026-06-02 18:41:50 -07:00
Makefile.vmlinux_o kbuild: Check for functions with ambiguous -ffunction-sections section names 2025-11-21 10:04:10 +01:00
Makefile.warn scripts/Makefile.warn: Drop -Wformat handling for clang < 16 2026-05-27 15:20:05 -07:00
makelst
markup_oops.pl
min-tool-version.sh s390 updates for 7.2 merge window 2026-06-16 05:08:13 +05:30
misc-check
mkcompile_h
mksysmap
mkuboot.sh
module-common.c
module.lds.S module.lds.S: Fix modules on 32-bit parisc architecture 2026-04-17 15:46:46 +02:00
modules-check.sh
nsdeps
objdiff
objdump-func
orc_hash.sh
pahole-version.sh
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c
recordmcount.h
recordmcount.pl
relocs_check.sh
remove-stale-files
rust_is_available_bindgen_libclang.h
rust_is_available_test.py rust: rust_is_available: remove warning for bindgen < 0.69.5 && libclang >= 19.1 2026-04-07 10:00:24 +02:00
rust_is_available.sh rust: kbuild: remove "dummy parameter" workaround for bindgen < 0.71.1 2026-04-07 10:00:24 +02:00
rustc-llvm-version.sh
rustc-version.sh
rustdoc_test_builder.rs rust: doctest: fix incorrect pattern in replacement 2026-06-19 09:39:50 +02:00
rustdoc_test_gen.rs Rust changes for v6.20 / v7.0 2026-02-10 11:53:01 -08:00
setlocalversion
show_delta
sign-file.c sign-file: use 'struct module_signature' from the UAPI headers 2026-03-24 21:42:37 +00:00
sorttable.c scripts/sorttable: Handle RISC-V patchable ftrace entries 2026-06-25 13:15:03 -06:00
spdxcheck-test.sh
spdxcheck.py treewide: Update email address 2026-01-11 06:09:11 -10:00
spdxexclude
spelling.txt treewide: fix transposed "sign" typos and update spelling.txt 2026-06-17 15:37:47 -07:00
ssl-common.h
stackdelta
stackusage
subarch.include
syscall.tbl rseq: Implement sys_rseq_slice_yield() 2026-01-22 11:11:17 +01:00
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh tags: Add regex for context_lock_struct 2026-01-05 16:43:37 +01:00
timer_migration_tree.py scripts/timers: Add timer_migration_tree.py 2026-05-06 08:33:07 +02:00
tools-support-relr.sh
tracepoint-update.c scripts/tracepoint-update: Fix memory leak in add_string() on failure 2026-01-23 13:34:45 -05:00
unifdef.c
update-intel-ucode-defs.py scripts/x86/intel: Add a script to update the old microcode list 2026-04-29 15:53:19 -07:00
ver_linux docs: changes.rst and ver_linux: sort the lists 2026-03-30 10:36:11 -06:00
verify_builtin_ranges.awk
xen-hypercalls.sh
xz_wrap.sh