diff mbox series

[v2] x86/boot/compressed/64: fix warning for 32-bit trampoline copy

Message ID 20180222112817.456380-1-arnd@arndb.de
State New
Headers show
Series [v2] x86/boot/compressed/64: fix warning for 32-bit trampoline copy | expand

Commit Message

Arnd Bergmann Feb. 22, 2018, 11:28 a.m. UTC
gcc-8 warns that we copy TRAMPOLINE_32BIT_CODE_SIZE bytes from the pointer
to the function into actual trampoline, when that pointer is only 8 bytes:

In file included from arch/x86/boot/compressed/pgtable_64.c:3:
arch/x86/boot/compressed/pgtable_64.c: In function 'paging_prepare':
arch/x86/boot/compressed/../string.h:18:23: error: '__builtin_memcpy' reading 96 bytes from a region of size 8 [-Werror=stringop-overflow=]
 #define memcpy(d,s,l) __builtin_memcpy(d,s,l)
                       ^~~~~~~~~~~~~~~~~~~~~~~
arch/x86/boot/compressed/pgtable_64.c:62:2: note: in expansion of macro 'memcpy'
  memcpy(trampoline + TRAMPOLINE_32BIT_CODE_OFFSET / sizeof(unsigned long),
  ^~~~~~

It turns out that the declaration is incorrect here: trampoline_32bit_src
is defined as a function in arch/x86/boot/compressed/head_64.S, not a
pointer to a function. Fixing the prototype to match addresses the warning.

Cc: Martin Sebor <msebor@gmail.com>
Suggested-by: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Fixes: b91993a87aff ("x86/boot/compressed/64: Prepare trampoline memory")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
v2: fix prototype rather than (incorrectly) change the user
---
 arch/x86/boot/compressed/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.9.0
diff mbox series

Patch

diff --git a/arch/x86/boot/compressed/pgtable.h b/arch/x86/boot/compressed/pgtable.h
index 6e0db2260147..5e0b1c4abef4 100644
--- a/arch/x86/boot/compressed/pgtable.h
+++ b/arch/x86/boot/compressed/pgtable.h
@@ -12,7 +12,7 @@ 
 
 #ifndef __ASSEMBLER__
 
-extern void (*trampoline_32bit_src)(void *return_ptr);
+extern void trampoline_32bit_src(void *return_ptr);
 
 #endif /* __ASSEMBLER__ */
 #endif /* BOOT_COMPRESSED_PAGETABLE_H */