Re: [PATCH] ftrace: x86: Fix a compile error about get_kernel_nofault()

From: Haiyue Wang
Date: Thu Feb 13 2025 - 05:52:07 EST




On 2025/2/13 18:40, Peter Zijlstra wrote:
On Thu, Feb 13, 2025 at 06:25:41PM +0800, Haiyue Wang wrote:

It is header file include indirect :-)

https://lore.kernel.org/linux-trace-kernel/20250206131711.ea536f165d5b5980b3909acd@xxxxxxxxxx/T/#t

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);) ; }


So this is simple enough; but the thread you link to also has another
hunk, which makes the whole thing unfortunate.

I'm not entirely sure what this GENDWARFKSYMS nonsense is about, but it
should not clutter the code like that.

By my understanding, the GENDWARFKSYMS design triggers the missing
header file, even this is inline function, but it will call another
function. It needs to "see" the header file firstly:

So this also fix the error:

--- a/arch/x86/include/asm/asm-prototypes.h
+++ b/arch/x86/include/asm/asm-prototypes.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
-#include <asm/ftrace.h>
#include <linux/uaccess.h>
#include <linux/pgtable.h>
+#include <asm/ftrace.h>