Re: [PATCH v1] ftrace: Fix compile error when CONFIG_GENDWARFKSYMS is enabled

From: Google
Date: Wed Feb 05 2025 - 19:39:07 EST


On Thu, 6 Feb 2025 02:00:42 +0800
Haiyue Wang <haiyuewa@xxxxxxx> wrote:

> When switching from CONFIG_GENKSYMS to CONFIG_GENDWARFKSYMS enabled, the
> build is failed:
>
> AS arch/x86/entry/entry.o
> In file included from ./arch/x86/include/asm/asm-prototypes.h:2,
> from <stdin>:3:
> ./arch/x86/include/asm/ftrace.h: In function ‘arch_ftrace_get_symaddr’:
> ./arch/x86/include/asm/ftrace.h:46:21: error: implicit declaration of function ‘get_kernel_nofault’ [-Werror=implicit-function-declaration]
> 46 | if (get_kernel_nofault(instr, (u32 *)(fentry_ip - ENDBR_INSN_SIZE)))
> | ^~~~~~~~~~~~~~~~~~
> cc1: some warnings being treated as errors
>
> File "asm-prototypes.h" is added to entry.S by 'scripts/Makefile.build',
> adding the missed declaration header file can also fix the error:
>
> getasmexports = \
> { echo "\#include <linux/kernel.h>" ; \
> echo "\#include <linux/string.h>" ; \
> + echo "\#include <linux/uaccess.h>"; \
> echo "\#include <asm/asm-prototypes.h>" ; \
> $(call getexportsymbols,EXPORT_SYMBOL(\1);) ; }
>
> Fixes: 2bc56fdae1ba ("ftrace: Add ftrace_get_symaddr to convert fentry_ip to symaddr")

Thanks for the fix. And this fixes one of problems.
Another one is that `is_endbr()` is defined in <asm/ibt.h> but that also depend
on CONFIG_HAVE_FENTRY.

Let's pick this and fix above issue.

Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

Thank you,

>
> Signed-off-by: Haiyue Wang <haiyuewa@xxxxxxx>
> ---
> arch/x86/include/asm/ftrace.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> index f9cb4d07df58..063ce70837bb 100644
> --- a/arch/x86/include/asm/ftrace.h
> +++ b/arch/x86/include/asm/ftrace.h
> @@ -34,6 +34,10 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
> return addr;
> }
>
> +#ifdef CONFIG_X86_KERNEL_IBT
> +#include <linux/uaccess.h>
> +#endif
> +
> static inline unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)
> {
> #ifdef CONFIG_X86_KERNEL_IBT
> --
> 2.48.1
>
>


--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>