Re: [for-next][PATCH 4/6] scripts/sorttable: Zero out weak functions in mcount_loc table

From: Nathan Chancellor
Date: Mon Feb 24 2025 - 13:10:02 EST


Hi Steve,

On Wed, Feb 19, 2025 at 10:18:19AM -0500, Steven Rostedt wrote:
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 728ecda6e8d4..e3f89924f603 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -7004,6 +7004,7 @@ static int ftrace_process_locs(struct module *mod,
> unsigned long count;
> unsigned long *p;
> unsigned long addr;
> + unsigned long kaslr;
> unsigned long flags = 0; /* Shut up gcc */
> int ret = -ENOMEM;
>
> @@ -7052,6 +7053,9 @@ static int ftrace_process_locs(struct module *mod,
> ftrace_pages->next = start_pg;
> }
>
> + /* For zeroed locations that were shifted for core kernel */
> + kaslr = !mod ? kaslr_offset() : 0;
> +
> p = start;
> pg = start_pg;
> while (p < end) {
> @@ -7063,7 +7067,7 @@ static int ftrace_process_locs(struct module *mod,
> * object files to satisfy alignments.
> * Skip any NULL pointers.
> */
> - if (!addr) {
> + if (!addr || addr == kaslr) {
> skipped++;
> continue;
> }

Our CI and KernelCI reports that this change as commit ef378c3b8233
("scripts/sorttable: Zero out weak functions in mcount_loc table") in
next-20250224 breaks when an architecture does not have kaslr_offset()
defined:

$ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- mrproper allmodconfig kernel/trace/ftrace.o
kernel/trace/ftrace.c: In function 'ftrace_process_locs':
kernel/trace/ftrace.c:7074:24: error: implicit declaration of function 'kaslr_offset' [-Wimplicit-function-declaration]
7074 | kaslr = !mod ? kaslr_offset() : 0;
| ^~~~~~~~~~~~

https://lore.kernel.org/CACo-S-0GeJjWWcrGvos_Avg2FwGU2tj2QZpgoHOvPT+YbyknSg@xxxxxxxxxxxxxx/

Cheers,
Nathan