* [PATCH] x86/boot/compressed/64: fix warning for 32-bit trampoline copy
@ 2018-02-22 10:40 Arnd Bergmann
2018-02-22 11:02 ` Kirill A. Shutemov
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-02-22 10:40 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, x86, Kirill A. Shutemov
Cc: Arnd Bergmann, Martin Sebor, H. Peter Anvin, linux-kernel
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),
^~~~~~
I assume what was intended here is to copy the trampoline itself rather than
the pointer to the trampoline.
Cc: Martin Sebor <msebor@gmail.com>
Fixes: b91993a87aff ("x86/boot/compressed/64: Prepare trampoline memory")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
This is a fairly new warning in gcc, it's possible that the code is
correct and the warning message got it wrong, please double-check this.
Was the 32-bit trampoline code in the 64-bit decompressor tested successfully?
---
arch/x86/boot/compressed/pgtable_64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
index dad5da7b4c1a..35a0542fe397 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -60,7 +60,7 @@ struct paging_config paging_prepare(void)
/* Copy trampoline code in place */
memcpy(trampoline + TRAMPOLINE_32BIT_CODE_OFFSET / sizeof(unsigned long),
- &trampoline_32bit_src, TRAMPOLINE_32BIT_CODE_SIZE);
+ trampoline_32bit_src, TRAMPOLINE_32BIT_CODE_SIZE);
/*
* Set up a new page table that will be used for switching from 4-
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/boot/compressed/64: fix warning for 32-bit trampoline copy
2018-02-22 10:40 [PATCH] x86/boot/compressed/64: fix warning for 32-bit trampoline copy Arnd Bergmann
@ 2018-02-22 11:02 ` Kirill A. Shutemov
2018-02-22 11:24 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Kirill A. Shutemov @ 2018-02-22 11:02 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Thomas Gleixner, Ingo Molnar, x86, Kirill A. Shutemov,
Martin Sebor, H. Peter Anvin, linux-kernel
On Thu, Feb 22, 2018 at 11:40:41AM +0100, Arnd Bergmann wrote:
> 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),
> ^~~~~~
>
> I assume what was intended here is to copy the trampoline itself rather than
> the pointer to the trampoline.
>
> Cc: Martin Sebor <msebor@gmail.com>
> Fixes: b91993a87aff ("x86/boot/compressed/64: Prepare trampoline memory")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> This is a fairly new warning in gcc, it's possible that the code is
> correct and the warning message got it wrong, please double-check this.
>
> Was the 32-bit trampoline code in the 64-bit decompressor tested successfully?
Yes, it was. Actually it tested on every boot of any 64-bit machine.
The fix is wrong and it breaks boot. The bug is in trampoline_32bit_src
declaration. Could you check if this helps with the warning:
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 */
--
Kirill A. Shutemov
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/boot/compressed/64: fix warning for 32-bit trampoline copy
2018-02-22 11:02 ` Kirill A. Shutemov
@ 2018-02-22 11:24 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-02-22 11:24 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Thomas Gleixner, Ingo Molnar, the arch/x86 maintainers,
Kirill A. Shutemov, Martin Sebor, H. Peter Anvin,
Linux Kernel Mailing List
On Thu, Feb 22, 2018 at 12:02 PM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
> On Thu, Feb 22, 2018 at 11:40:41AM +0100, Arnd Bergmann wrote:
>> 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),
>> ^~~~~~
>>
>> I assume what was intended here is to copy the trampoline itself rather than
>> the pointer to the trampoline.
>>
>> Cc: Martin Sebor <msebor@gmail.com>
>> Fixes: b91993a87aff ("x86/boot/compressed/64: Prepare trampoline memory")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>> This is a fairly new warning in gcc, it's possible that the code is
>> correct and the warning message got it wrong, please double-check this.
>>
>> Was the 32-bit trampoline code in the 64-bit decompressor tested successfully?
>
> Yes, it was. Actually it tested on every boot of any 64-bit machine.
>
> The fix is wrong and it breaks boot. The bug is in trampoline_32bit_src
> declaration. Could you check if this helps with the warning:
Got it, yes that definitely explains the problem. Your patch fixes it
and I'll follow up with a new submission using this change, unless you
want to send it as a patch yourself.
Arnd
> 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 */
> --
> Kirill A. Shutemov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-22 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 10:40 [PATCH] x86/boot/compressed/64: fix warning for 32-bit trampoline copy Arnd Bergmann
2018-02-22 11:02 ` Kirill A. Shutemov
2018-02-22 11:24 ` Arnd Bergmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.