Skip to contentSkip to conversation

x86: fix build failure

PATCH In review Andrey Ryabinin 3 participants 5 messages Sep 29, 2015 – Oct 1, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix build failure

With KMEMCHECK=y, KASAN=n:

arch/x86/platform/efi/efi.c:673:3: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/platform/efi/efi_64.c:139:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/include/asm/desc.h:121:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]

Don't #undef memcpy if KASAN=n.

Fixes 769a8089c1fd ("x86, efi, kasan: #undef memset/memcpy/memmove per arch")
---
 arch/x86/include/asm/efi.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/efi.h +2 -0
index ab5f1d4..ae68be9 100644
@@ -86,6 +86,7 @@ extern u64 asmlinkage efi_call(void *fp, ...);
 extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 					u32 type, u64 attribute);
 
+#ifdef CONFIG_KASAN
 /*
  * CONFIG_KASAN may redefine memset to __memset.  __memset function is present
  * only in kernel binary.  Since the EFI stub linked into a separate binary it
@@ -95,6 +96,7 @@ extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 #undef memcpy
 #undef memset
 #undef memmove
+#endif
 
 #endif /* CONFIG_X86_32 */
 
Signature · 1 line
2.4.6
#1 lore raw
Quoted 8 lines · Andrey Ryabinin

With KMEMCHECK=y, KASAN=n:

arch/x86/platform/efi/efi.c:673:3: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/platform/efi/efi_64.c:139:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/include/asm/desc.h:121:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]

Don't #undef memcpy if KASAN=n.

Good catch.
This broke my llvmlinux-patches Linux v4.3-rcN.

The subject-line is not very meaningful - to me at least ?

- Sedat -

Quoted 31 lines
Fixes 769a8089c1fd ("x86, efi, kasan: #undef memset/memcpy/memmove per arch")
---
 arch/x86/include/asm/efi.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/efi.h +2 -1
index ab5f1d4..ae68be9 100644
@@ -86,6 +86,7 @@ extern u64 asmlinkage efi_call(void *fp, ...);
 extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
                                        u32 type, u64 attribute);
 
+#ifdef CONFIG_KASAN
 /*
  * CONFIG_KASAN may redefine memset to __memset.  __memset function is present
  * only in kernel binary.  Since the EFI stub linked into a separate binary it
@@ -95,6 +96,7 @@ extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 #undef memcpy
 #undef memset
 #undef memmove
+#endif
 
 #endif /* CONFIG_X86_32 */
 
--

2.4.6

#2 lore raw
Quoted 7 lines · Sedat Dilek
Quoted 6 lines · Andrey Ryabinin

With KMEMCHECK=y, KASAN=n:

arch/x86/platform/efi/efi.c:673:3: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/platform/efi/efi_64.c:139:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/include/asm/desc.h:121:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]

Quoted 8 lines
Quoted 2 lines

Don't #undef memcpy if KASAN=n.

Good catch.
This broke my llvmlinux-patches Linux v4.3-rcN.

The subject-line is not very meaningful - to me at least ?

What about...?

"x86, efi, kasan: Fix error implicit declaration of memcpy"

"x86, efi, kasan: Add missing CONFIG_KASAN check for #undef memset/memcpy/memmove"

- Sedat -

Quoted 33 lines

- Sedat -

Quoted 31 lines
Fixes 769a8089c1fd ("x86, efi, kasan: #undef memset/memcpy/memmove per arch")
---
 arch/x86/include/asm/efi.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/efi.h +2 -1
index ab5f1d4..ae68be9 100644
@@ -86,6 +86,7 @@ extern u64 asmlinkage efi_call(void *fp, ...);
 extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
                                        u32 type, u64 attribute);
 
+#ifdef CONFIG_KASAN
 /*
  * CONFIG_KASAN may redefine memset to __memset.  __memset function is present
  * only in kernel binary.  Since the EFI stub linked into a separate binary it
@@ -95,6 +96,7 @@ extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 #undef memcpy
 #undef memset
 #undef memmove
+#endif
 
 #endif /* CONFIG_X86_32 */
 
--

2.4.6

Tested-by
#3 lore raw
Quoted 17 lines · Sedat Dilek
Quoted 7 lines · Sedat Dilek
Quoted 6 lines · Andrey Ryabinin

With KMEMCHECK=y, KASAN=n:

arch/x86/platform/efi/efi.c:673:3: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/platform/efi/efi_64.c:139:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration] arch/x86/include/asm/desc.h:121:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]

Quoted 8 lines
Quoted 2 lines

Don't #undef memcpy if KASAN=n.

Good catch.
This broke my llvmlinux-patches Linux v4.3-rcN.

The subject-line is not very meaningful - to me at least ?

Quoted 7 lines

What about...?

"x86, efi, kasan: Fix error implicit declaration of memcpy"

"x86, efi, kasan: Add missing CONFIG_KASAN check for #undef memset/memcpy/memmove"

I tested this with latest llvmlinux kernel and it looks good...

$ grep 'kernel/setup.o' build-log_4.3.0-rc3-10-llvmlinux-amd64.txt
  CC      arch/x86/kernel/setup.o

Feel free to add my...

...when you do a v2.

Thanks.

- Sedat -

Quoted 35 lines

- Sedat -

Quoted 33 lines

- Sedat -

Quoted 31 lines
Fixes 769a8089c1fd ("x86, efi, kasan: #undef memset/memcpy/memmove per arch")
---
 arch/x86/include/asm/efi.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/efi.h +2 -1
index ab5f1d4..ae68be9 100644
@@ -86,6 +86,7 @@ extern u64 asmlinkage efi_call(void *fp, ...);
 extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
                                        u32 type, u64 attribute);
 
+#ifdef CONFIG_KASAN
 /*
  * CONFIG_KASAN may redefine memset to __memset.  __memset function is present
  * only in kernel binary.  Since the EFI stub linked into a separate binary it
@@ -95,6 +96,7 @@ extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 #undef memcpy
 #undef memset
 #undef memmove
+#endif
 
 #endif /* CONFIG_X86_32 */
 
--

2.4.6

#4 lore raw

[tip:x86/urgent] x86, efi, kasan: Fix build failure on !KASAN && KMEMCHECK=y kernels

In reply to Andrey Ryabinin
x86, efi, kasan: Fix build failure on !KASAN && KMEMCHECK=y kernels
Commit-ID:  4ac86a6dcec1c3878de9747bf5a2aa4455be69e3
Gitweb:     http://git.kernel.org/tip/4ac86a6dcec1c3878de9747bf5a2aa4455be69e3
Author:     Andrey Ryabinin <[email protected]>
AuthorDate: Tue, 29 Sep 2015 19:40:14 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 30 Sep 2015 09:29:53 +0200

x86, efi, kasan: Fix build failure on !KASAN && KMEMCHECK=y kernels

With KMEMCHECK=y, KASAN=n we get this build failure:

arch/x86/platform/efi/efi.c:673:3: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]
arch/x86/platform/efi/efi_64.c:139:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]
arch/x86/include/asm/desc.h:121:2: error: implicit declaration of function ‘memcpy’ [-Werror=implicit-function-declaration]

Don't #undef memcpy if KASAN=n.

Cc Linus Torvalds <[email protected]>
Cc Matt Fleming <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Fixes 769a8089c1fd ("x86, efi, kasan: #undef memset/memcpy/memmove per arch")
---
 arch/x86/include/asm/efi.h | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/include/asm/efi.h +2 -0
index ab5f1d4..ae68be9 100644
@@ -86,6 +86,7 @@ extern u64 asmlinkage efi_call(void *fp, ...);
 extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 					u32 type, u64 attribute);
 
+#ifdef CONFIG_KASAN
 /*
  * CONFIG_KASAN may redefine memset to __memset.  __memset function is present
  * only in kernel binary.  Since the EFI stub linked into a separate binary it
@@ -95,6 +96,7 @@ extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 #undef memcpy
 #undef memset
 #undef memmove
+#endif
 
 #endif /* CONFIG_X86_32 */