ftrace: Fix compile error when CONFIG_GENDWARFKSYMS is enabled
PATCH 1/1 ftrace: Fix compile error when CONFIG_GENDWARFKSYMS is enabled
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);) ; }--- arch/x86/include/asm/ftrace.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/include/asm/ftrace.h +4 -0
@@ -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
Signature · 1 line
2.48.1
Hi,
Quoted 35 lines · Haiyue Wang
When switching from
CONFIG_GENKSYMStoCONFIG_GENDWARFKSYMSenabled, 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 toentry.Sby '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")Signed-off-by Haiyue Wang <[email protected]>--- arch/x86/include/asm/ftrace.h | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/include/asm/ftrace.h +0
-0
arch/x86/include/asm/ftrace.h static inline unsigned long ftrace_call_adjust(unsigned long addr) · line 43
Quoted 10 lines
arch/x86/include/asm/ftrace.h +4
-0@@ -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
Thanks for the patch! This looks correct to me, and I confirmed that it fixes the build issue. Feel free to add:
Sami
Quoted 15 lines · On Thu, 6 Feb 2025 02:00:42 +0800 Haiyue Wang <[email protected]> wrote:
When switching from
CONFIG_GENKSYMStoCONFIG_GENDWARFKSYMSenabled, 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 toentry.Sby 'scripts/Makefile.build', adding the missed declaration header file can also fix the error:
Quoted 8 lines
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.
Thank you,
Quoted 25 lines
Signed-off-by Haiyue Wang <[email protected]>--- arch/x86/include/asm/ftrace.h | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/include/asm/ftrace.h +4
-0@@ -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 Signature · 1 line
2.48.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Steven Rostedt
maintainerQuoted 5 lines · On Thu, 6 Feb 2025 09:38:53 +0900 Masami Hiramatsu (Google)…
Thanks for the fix. And this fixes one of problems.
Another one is thatis_endbr()is defined in <asm/ibt.h> but that also depend onCONFIG_HAVE_FENTRY.Let's pick this and fix above issue.
OK, I'll pull this into my urgent tree and start testing it.
-- Steve
Masami Hiramatsu (Google)
maintainerQuoted 10 lines · On Wed, 5 Feb 2025 19:53:00 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 5 lines · On Thu, 6 Feb 2025 09:38:53 +0900 Masami Hiramatsu (Google)…
Thanks for the fix. And this fixes one of problems.
Another one is thatis_endbr()is defined in <asm/ibt.h> but that also depend onCONFIG_HAVE_FENTRY.Let's pick this and fix above issue.
OK, I'll pull this into my urgent tree and start testing it.
Sorry, Gabriel found another issue.
Let me fix this instead of this patch.
https://lore.kernel.org/all/CAFEugPfFykYsHqS-J36CNWDn+d34bSQg-e5hJ=AaJPC8=6Ej-g@mail.gmail.com/
Quoted 2 lines
-- Steve
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 10 lines · Masami Hiramatsu (Google)
Quoted 7 lines · On Wed, 5 Feb 2025 19:53:00 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 4 lines · On Thu, 6 Feb 2025 09:38:53 +0900 Masami Hiramatsu (Google)…
Thanks for the fix. And this fixes one of problems.
Another one is thatis_endbr()is defined in <asm/ibt.h> but that also depend onCONFIG_HAVE_FENTRY.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Let's pick this and fix above issue.
OK, I'll pull this into my urgent tree and start testing it.
Sorry, Gabriel found another issue.
Let me fix this instead of this patch.https://lore.kernel.org/all/CAFEugPfFykYsHqS-J36CNWDn+d34bSQg-e5hJ=AaJPC8=6Ej-g@mail.gmail.com/
If I put the fix above '#ifndef __ASSEMBLY__', then I can reproduce Gabriel's founding:
+#ifdef CONFIG_X86_KERNEL_IBT
+#include <linux/uaccess.h>
+#endif
+
#ifndef __ASSEMBLY__
In file included from ./include/linux/kcsan-checks.h:13,
from ./include/linux/instrumented.h:12,
from ./include/linux/uaccess.h:6,
from ./arch/x86/include/asm/ftrace.h:26,
from arch/x86/kernel/ftrace_64.S:11:./include/linux/compiler_attributes.h:91:20: error: missing binary operator before token "("
91 | #if __has_attribute(__copy__)
| ^./include/linux/compiler_attributes.h:103:20: error: missing binary operator before token "("
103 | #if __has_attribute(__diagnose_as_builtin__)
| ^./include/linux/compiler_attributes.h:126:20: error: missing binary operator before token "("
126 | #if __has_attribute(__designated_init__)
| ^./include/linux/compiler_attributes.h:137:20: error: missing binary operator before token "("
137 | #if __has_attribute(__error__)
| ^
Quoted 4 lines
Quoted 2 lines
-- Steve
Masami Hiramatsu (Google)
maintainerQuoted 17 lines · On Thu, 6 Feb 2025 11:23:02 +0800 Haiyue Wang <[email protected]> wrote:
Quoted 14 lines · Masami Hiramatsu (Google)
Quoted 10 lines · On Wed, 5 Feb 2025 19:53:00 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 5 lines · On Thu, 6 Feb 2025 09:38:53 +0900 Masami Hiramatsu (Google)…
Thanks for the fix. And this fixes one of problems.
Another one is thatis_endbr()is defined in <asm/ibt.h> but that also depend onCONFIG_HAVE_FENTRY.Let's pick this and fix above issue.
OK, I'll pull this into my urgent tree and start testing it.
Quoted 9 lines
Quoted 5 lines
Sorry, Gabriel found another issue.
Let me fix this instead of this patch.https://lore.kernel.org/all/CAFEugPfFykYsHqS-J36CNWDn+d34bSQg-e5hJ=AaJPC8=6Ej-g@mail.gmail.com/
If I put the fix above '#ifndef
__ASSEMBLY__', then I can reproduce Gabriel's founding:
Yeah, thanks. Anyway, I would not like introduce header file dependency too much, especially header files under asm.
Please check below my fix;
https://lore.kernel.org/all/173881156244.211648.1242168038709680511.stgit@devnote2/
Thank you,
Quoted 35 lines
arch/x86/include/asm/ftrace.h +4
-0+#ifdef CONFIG_X86_KERNEL_IBT +#include <linux/uaccess.h> +#endif +#ifndef __ASSEMBLY__In file included from
./include/linux/kcsan-checks.h:13,from ./include/linux/instrumented.h:12, from ./include/linux/uaccess.h:6, from ./arch/x86/include/asm/ftrace.h:26, from arch/x86/kernel/ftrace_64.S:11: ./include/linux/compiler_attributes.h:91:20: error: missing binary operator before token "(" 91 | #if __has_attribute(__copy__) | ^
./include/linux/compiler_attributes.h:103:20: error: missing binary operator before token "("
103 | #if__has_attribute(__diagnose_as_builtin__)
| ^./include/linux/compiler_attributes.h:126:20: error: missing binary operator before token "("
126 | #if__has_attribute(__designated_init__)
| ^./include/linux/compiler_attributes.h:137:20: error: missing binary operator before token "("
137 | #if__has_attribute(__error__)
| ^Quoted 4 lines
Quoted 2 lines
-- Steve
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>