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
bash-completion
basic
clang-tools linux_kselftest-kunit-7.2-rc1 2026-06-16 16:33:57 +05:30
coccinelle
crypto
dtc dt-bindings: add self-test fixtures for style checker 2026-06-10 13:37:06 -05:00
dummy-tools
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
genksyms
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
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
build-version
cc-can-link.sh
cc-version.sh
check_extable.sh
check-function-names.sh
check-git
check-sysctl-docs
check-uapi.sh
checkdeclares.pl
checker-valid.sh
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
config
const_structs.checkpatch
container
context-analysis-suppression.txt
decode_stacktrace.sh
decodecode
depmod.sh
dev-needs.sh
diffconfig
elf-parse.c
elf-parse.h
extract_xc3028.pl
extract-fwblobs
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
faddr2line
file-size.sh
gen_packed_field_checks.c
gen-btf.sh
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
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
Kbuild.include
Kconfig.include
kernel-doc
ld-version.sh
leaking_addresses.pl
Lindent
link-vmlinux.sh
macro_checker.py
make_fit.py
Makefile
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
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
Makefile.debug
Makefile.defconf
Makefile.dtbinst
Makefile.dtbs
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
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
Makefile.vmlinux_a kbuild: Remove unnecessary 'T' modifier in cmd_ar_builtin_fixup 2026-06-02 18:41:50 -07:00
Makefile.vmlinux_o
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
setlocalversion
show_delta
sign-file.c
sorttable.c scripts/sorttable: Handle RISC-V patchable ftrace entries 2026-06-25 13:15:03 -06:00
spdxcheck-test.sh
spdxcheck.py
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
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh
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
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