Skip to contentSkip to conversation

x86/boot/compressed/64: Define __force_order only when CONFIG_RANDOMIZE_BASE is unset

PATCH In review Khem Raj 4 participants 6 messages Dec 21, 2019 – Dec 30, 2019 x86

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 x86/boot/compressed/64: Define __force_order only when CONFIG_RANDOMIZE_BASE is unset

kaslr_64.c also defines the same variable, however when both files are included into final link, linker complains about multiple definition of `__force_order' which is coming from kaslr_64.o and pgtable_64.o, its possible that kaslr_64.o is disabled via CONFIG_RANDOMIZE_BASE config option, therefore define it conditionally only when CONFIG_RANDOMIZE_BASE is not set

Since arch/x86/boot/compressed/Makefile overrides global CFLAGS it loses -fno-common option which would have caught this

Cc Kirill A. Shutemov <[email protected]>
Cc Kees Cook <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 arch/x86/boot/compressed/pgtable_64.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/boot/compressed/pgtable_64.c +2 -0
index c8862696a47b..077d19268b0b 100644
@@ -12,7 +12,9 @@
  * It is not referenced from the code, but GCC < 5 with -fPIE would fail
  * due to an undefined symbol. Define it to make these ancient GCCs work.
  */
+#ifndef CONFIG_RANDOMIZE_BASE
 unsigned long __force_order;
+#endif
 
 #define BIOS_START_MIN		0x20000U	/* 128K, less than this is insane */
 #define BIOS_START_MAX		0x9f000U	/* 640K, absolute maximum */
Signature · 1 line
2.24.1
#1 lore raw
Quoted 2 lines · Khem Raj

Since arch/x86/boot/compressed/Makefile overrides global CFLAGS it loses -fno-common option which would have caught this

If this doesn't cause any visible problems, why bother?

Hopefully, we will be able to drop it altogether once we ditch GCC 4.X support.

Signature · 1 line
 Kirill A. Shutemov
author
#2 lore raw
Quoted 7 lines · Kirill A. Shutemov
Quoted 2 lines · Khem Raj

Since arch/x86/boot/compressed/Makefile overrides global CFLAGS it loses -fno-common option which would have caught this

If this doesn't cause any visible problems, why bother?

it does break builds with gcc trunk as of now e.g.

Quoted 3 lines

Hopefully, we will be able to drop it altogether once we ditch GCC 4.X support.

gcc10 is switching defaults to -fno-common so we need to solve this one way or other, I am not sure if gcc 4.x will be dropped before gcc10 release which would be
in mid of 2020

Quoted 2 lines

--
Kirill A. Shutemov

#3 lore raw
Quoted 11 lines · Khem Raj
Quoted 7 lines · Kirill A. Shutemov
Quoted 2 lines · Khem Raj

Since arch/x86/boot/compressed/Makefile overrides global CFLAGS it loses -fno-common option which would have caught this

If this doesn't cause any visible problems, why bother?

it does break builds with gcc trunk as of now e.g.

Quoted 8 lines
Quoted 3 lines

Hopefully, we will be able to drop it altogether once we ditch GCC 4.X support.

gcc10 is switching defaults to -fno-common so we need to solve this one way or other, I am not sure if gcc 4.x will be dropped before gcc10 release which would be
in mid of 2020

Okay, it makes sense then. Please include this info into the commit message.

Also, I wounder if it would be cleaner to define both of them as __weak?

Signature · 1 line
 Kirill A. Shutemov
#4 lore raw
Quoted 21 lines · Kirill A. Shutemov
Quoted 11 lines · Khem Raj
Quoted 7 lines · Kirill A. Shutemov
Quoted 2 lines · Khem Raj

Since arch/x86/boot/compressed/Makefile overrides global CFLAGS it loses -fno-common option which would have caught this

If this doesn't cause any visible problems, why bother?

it does break builds with gcc trunk as of now e.g.

Quoted 8 lines
Quoted 3 lines

Hopefully, we will be able to drop it altogether once we ditch GCC 4.X support.

gcc10 is switching defaults to -fno-common so we need to solve this one way or other, I am not sure if gcc 4.x will be dropped before gcc10 release which would be
in mid of 2020

Quoted 4 lines

Okay, it makes sense then. Please include this info into the commit message.

Also, I wounder if it would be cleaner to define both of them as __weak?

Or maybe make the #ifdef check for gcc < 5 instead of checking for CONFIG_RANDOMIZE_BASE? That way it will be found by whoever cleans up the code when we increase the minimum compiler version to one that doesn't require the hack.

Arnd

#5 lore raw
Quoted 26 lines · Arnd Bergmann
Quoted 24 lines · Kirill A. Shutemov
Quoted 11 lines · Khem Raj
Quoted 7 lines · Kirill A. Shutemov
Quoted 2 lines · Khem Raj

Since arch/x86/boot/compressed/Makefile overrides global CFLAGS it loses -fno-common option which would have caught this

If this doesn't cause any visible problems, why bother?

it does break builds with gcc trunk as of now e.g.

Quoted 8 lines
Quoted 3 lines

Hopefully, we will be able to drop it altogether once we ditch GCC 4.X support.

gcc10 is switching defaults to -fno-common so we need to solve this one way or other, I am not sure if gcc 4.x will be dropped before gcc10 release which would be
in mid of 2020

Okay, it makes sense then. Please include this info into the commit message.

Quoted 6 lines
Quoted 1 line

Also, I wounder if it would be cleaner to define both of them as __weak?

Or maybe make the #ifdef check for gcc < 5 instead of checking for CONFIG_RANDOMIZE_BASE? That way it will be found by whoever cleans up the code when we increase the minimum compiler version to one that doesn't require the hack.

I agree: that seems a better way to do this.

Signature · 1 line
Kees Cook