Skip to contentSkip to conversation

x86: Use default stack boundary alignment

PATCH Superseded Bin Meng 3 participants 13 messages Jul 23, 2017 – Aug 1, 2017 x86

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/2 x86: Use default stack boundary alignment

At present U-Boot x86 build is using -mpreferred-stack-boundary=2 which is 4 bytes stack boundary alignment. With 64-bit U-Boot, the minimal required stack boundary alignment is 16 bytes.

If -mpreferred-stack-boundary is not specified, the default is 4 (16 bytes). Switch to use the default one.

---

 arch/x86/config.mk | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/config.mk +1 -2
index 74b87ce..043425e 100644
@@ -10,8 +10,7 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
 PLATFORM_CPPFLAGS += -fno-strict-aliasing
 PLATFORM_CPPFLAGS += -fomit-frame-pointer
 PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
-		       $(call cc-option, -fno-unit-at-a-time)) \
-		     $(call cc-option, -mpreferred-stack-boundary=2)
+		     $(call cc-option, -fno-unit-at-a-time))
 
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
Signature · 1 line
2.9.2
author
#1 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Attempting to use a 32-bit toolchain (eg: kernel.org 4.9 i386-linux-gcc) to compile 64-bit U-Boot (qemu-x86_64_defconfig) fails with the following errors:

arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'

The issue is with 32-bit toolchain compiling sources for 64-bit. Using a 64-bit toolchain (eg: kernel.org 4.9 x86_64-linux-gcc) works out of the box. When compiling sources for 32-bit, '-m32' is passed to the toolchain (no matter it's 32-bit or 64-bit).

Now do the same thing, passing '-m64' to the toolchain for 64-bit sources build.

---

 arch/x86/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/config.mk +1 -1
index 043425e..8835dcf 100644
@@ -26,7 +26,7 @@ endif
 ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
 else
-PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common
+PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
 endif
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
Signature · 1 line
2.9.2
#2 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Quoted 7 lines · Bin Meng

Attempting to use a 32-bit toolchain (eg: kernel.org 4.9 i386-linux-gcc) to compile 64-bit U-Boot (qemu-x86_64_defconfig) fails with the following errors:

arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'

Quoted 8 lines

The issue is with 32-bit toolchain compiling sources for 64-bit. Using a 64-bit toolchain (eg: kernel.org 4.9 x86_64-linux-gcc) works out of the box. When compiling sources for 32-bit, '-m32' is passed to the toolchain (no matter it's 32-bit or 64-bit).

Now do the same thing, passing '-m64' to the toolchain for 64-bit sources build.

The subject is a bit cofusing. As I read (and as I understand) we need to have 64-bit toolchain available (multilib package and so on). Basically what you do is "enforcing 64-bit toolchain to be used". Right?

Quoted 26 lines

---

 arch/x86/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/config.mk +1 -2
index 043425e..8835dcf 100644
@@ -26,7 +26,7 @@ endif
 ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
 else
-PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common
+PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64
 endif
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
--

2.9.2

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#3 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Hi Andy,

Quoted 13 lines · Andy Shevchenko
Quoted 12 lines · Bin Meng

Attempting to use a 32-bit toolchain (eg: kernel.org 4.9 i386-linux-gcc) to compile 64-bit U-Boot (qemu-x86_64_defconfig) fails with the following errors:

arch/x86/cpu/intel_common/microcode.c:79:2: error: PIC register clobbered by 'ebx' in 'asm'

The issue is with 32-bit toolchain compiling sources for 64-bit. Using a 64-bit toolchain (eg: kernel.org 4.9 x86_64-linux-gcc) works out of the box. When compiling sources for 32-bit, '-m32' is passed to the toolchain (no matter it's 32-bit or 64-bit).

Quoted 8 lines
Quoted 3 lines

Now do the same thing, passing '-m64' to the toolchain for 64-bit sources build.

The subject is a bit cofusing. As I read (and as I understand) we need to have 64-bit toolchain available (multilib package and so on). Basically what you do is "enforcing 64-bit toolchain to be used". Right?

Yes, multilib package is required for 64-bit toolchain to build 32-bit U-Boot. Maybe the confusion comes from what we call 32-bit/64-bit toolchains. Or maybe we should call it pre-configured toolchain for building 32-bit/64-bit codes? The issue is when using kernel.org i386-linux-gcc to build qemu-x86_64_defconfig (64-bit U-Boot), the issue is seen. It's because the i386-linux-gcc is pre-configured with '-m32' which is for building 32-bit codes.

Quoted 6 lines
Quoted 6 lines

---

 arch/x86/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Regards,
Bin

#4 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Quoted 9 lines · Bin Meng
Quoted 6 lines · Andy Shevchenko

On Sun, Jul 23, 2017 at 12:37 PM, Bin Meng <[email protected]> wrote:

The subject is a bit cofusing. As I read (and as I understand) we need to have 64-bit toolchain available (multilib package and so on). Basically what you do is "enforcing 64-bit toolchain to be used". Right?

Quoted 7 lines

Yes, multilib package is required for 64-bit toolchain to build 32-bit U-Boot. Maybe the confusion comes from what we call 32-bit/64-bit toolchains. Or maybe we should call it pre-configured toolchain for building 32-bit/64-bit codes? The issue is when using kernel.org i386-linux-gcc to build qemu-x86_64_defconfig (64-bit U-Boot), the issue is seen. It's because the i386-linux-gcc is pre-configured with '-m32' which is for building 32-bit codes.

My point is that subject (and maybe commit message) should be massaged a bit to avoid confusion.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#5 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Hi Andy,

Quoted 18 lines · Andy Shevchenko
Quoted 9 lines · Bin Meng
Quoted 6 lines · Andy Shevchenko

On Sun, Jul 23, 2017 at 12:37 PM, Bin Meng <[email protected]> wrote:

The subject is a bit cofusing. As I read (and as I understand) we need to have 64-bit toolchain available (multilib package and so on). Basically what you do is "enforcing 64-bit toolchain to be used". Right?

Quoted 7 lines

Yes, multilib package is required for 64-bit toolchain to build 32-bit U-Boot. Maybe the confusion comes from what we call 32-bit/64-bit toolchains. Or maybe we should call it pre-configured toolchain for building 32-bit/64-bit codes? The issue is when using kernel.org i386-linux-gcc to build qemu-x86_64_defconfig (64-bit U-Boot), the issue is seen. It's because the i386-linux-gcc is pre-configured with '-m32' which is for building 32-bit codes.

Quoted 3 lines

My point is that subject (and maybe commit message) should be massaged a bit to avoid confusion.

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Regards,
Bin

#6 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Quoted 20 lines · Bin Meng
Quoted 18 lines · Andy Shevchenko
Quoted 16 lines · Bin Meng
Quoted 6 lines · Andy Shevchenko

On Sun, Jul 23, 2017 at 12:37 PM, Bin Meng <[email protected]> wrote:

The subject is a bit cofusing. As I read (and as I understand) we need to have 64-bit toolchain available (multilib package and so on). Basically what you do is "enforcing 64-bit toolchain to be used". Right?

Yes, multilib package is required for 64-bit toolchain to build 32-bit U-Boot. Maybe the confusion comes from what we call 32-bit/64-bit toolchains. Or maybe we should call it pre-configured toolchain for building 32-bit/64-bit codes? The issue is when using kernel.org i386-linux-gcc to build qemu-x86_64_defconfig (64-bit U-Boot), the issue is seen. It's because the i386-linux-gcc is pre-configured with '-m32' which is for building 32-bit codes.

Quoted 6 lines
Quoted 3 lines

My point is that subject (and maybe commit message) should be massaged a bit to avoid confusion.

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Hmm... The flag you are adding does enforce or allow? So, if -m64 will still allow to compile 32-bit code, then it's allowing, otherwise it's enforcing.
Or I miss something?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#7 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Hi Andy,

Quoted 25 lines · Andy Shevchenko
Quoted 24 lines · Bin Meng
Quoted 21 lines · Andy Shevchenko
Quoted 9 lines · Bin Meng
Quoted 6 lines · Andy Shevchenko

On Sun, Jul 23, 2017 at 12:37 PM, Bin Meng <[email protected]> wrote:

The subject is a bit cofusing. As I read (and as I understand) we need to have 64-bit toolchain available (multilib package and so on). Basically what you do is "enforcing 64-bit toolchain to be used". Right?

Quoted 7 lines

Yes, multilib package is required for 64-bit toolchain to build 32-bit U-Boot. Maybe the confusion comes from what we call 32-bit/64-bit toolchains. Or maybe we should call it pre-configured toolchain for building 32-bit/64-bit codes? The issue is when using kernel.org i386-linux-gcc to build qemu-x86_64_defconfig (64-bit U-Boot), the issue is seen. It's because the i386-linux-gcc is pre-configured with '-m32' which is for building 32-bit codes.

My point is that subject (and maybe commit message) should be massaged a bit to avoid confusion.

Quoted 7 lines
Quoted 2 lines

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Hmm... The flag you are adding does enforce or allow? So, if -m64 will still allow to compile 32-bit code, then it's allowing, otherwise it's enforcing.
Or I miss something?

-m64 will only be passed to compiler when building source files that are part of 64-bit U-Boot. For 32-bit U-Boot, it is still -m32.

Regards,
Bin

#8 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Quoted 9 lines · Bin Meng
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Bin Meng

On Sun, Jul 23, 2017 at 6:07 PM, Andy Shevchenko
<[email protected]> wrote:

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Quoted 7 lines
Quoted 4 lines

Hmm... The flag you are adding does enforce or allow? So, if -m64 will still allow to compile 32-bit code, then it's allowing, otherwise it's enforcing.
Or I miss something?

-m64 will only be passed to compiler when building source files that are part of 64-bit U-Boot. For 32-bit U-Boot, it is still -m32.

Yes, what I'm trying to understand is
1. U-Boot is compiled _either_ 64-bit, _or_ 32-bit binary -- correct?
2. If above is correct then -m64 _enforces_ to compile it as 64-bit -- correct?

Or I'm mistaken with the last and -m64 just adds a _preference_ to compile as 64-bit?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#9 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Hi Andy,

Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Bin Meng
Quoted 11 lines · Andy Shevchenko
Quoted 5 lines · Bin Meng

On Sun, Jul 23, 2017 at 6:07 PM, Andy Shevchenko
<[email protected]> wrote:

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Hmm... The flag you are adding does enforce or allow? So, if -m64 will still allow to compile 32-bit code, then it's allowing, otherwise it's enforcing.
Or I miss something?

Quoted 5 lines
Quoted 2 lines

-m64 will only be passed to compiler when building source files that are part of 64-bit U-Boot. For 32-bit U-Boot, it is still -m32.

Yes, what I'm trying to understand is
1. U-Boot is compiled _either_ 64-bit, _or_ 32-bit binary -- correct?

64-bit U-Boot image is a combination of 32-bit U-Boot (SPL) plus 64-bit U-Boot (proper). For the U-Boot proper, it has be compiled with 64-bit and currently -m64 is missing, primary due to the toolchain we previously used has implicitly -m64 configured.

Quoted 2 lines

2. If above is correct then -m64 _enforces_ to compile it as 64-bit -- correct?

Correct.

Quoted 3 lines

Or I'm mistaken with the last and -m64 just adds a _preference_ to compile as 64-bit?

Regards,
Bin

#10 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Quoted 18 lines · Bin Meng
Quoted 16 lines · Andy Shevchenko
Quoted 14 lines · Bin Meng
Quoted 9 lines · Andy Shevchenko
Quoted 2 lines · Bin Meng

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Hmm... The flag you are adding does enforce or allow? So, if -m64 will still allow to compile 32-bit code, then it's allowing, otherwise it's enforcing.
Or I miss something?

-m64 will only be passed to compiler when building source files that are part of 64-bit U-Boot. For 32-bit U-Boot, it is still -m32.

Quoted 7 lines
Quoted 2 lines

Yes, what I'm trying to understand is
1. U-Boot is compiled _either_ 64-bit, _or_ 32-bit binary -- correct?

64-bit U-Boot image is a combination of 32-bit U-Boot (SPL) plus 64-bit U-Boot (proper). For the U-Boot proper, it has be compiled with 64-bit and currently -m64 is missing, primary due to the toolchain we previously used has implicitly -m64 configured.

Okay, thanks for patience and explanation.

Can you somehow (partially) inject this into initial subject + commit message?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#11 lore raw

PATCH 2/2 x86: Allow 32-bit toolchain to compile 64-bit U-Boot

Hi Andy,

Quoted 22 lines · Andy Shevchenko
Quoted 21 lines · Bin Meng
Quoted 18 lines · Andy Shevchenko
Quoted 7 lines · Bin Meng
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Bin Meng

Sure. Reword it as "Allow toolchains that are pre-configured to build 32-bit codes to compile 64-bit U-Boot"?

Quoted 7 lines
Quoted 4 lines

Hmm... The flag you are adding does enforce or allow? So, if -m64 will still allow to compile 32-bit code, then it's allowing, otherwise it's enforcing.
Or I miss something?

-m64 will only be passed to compiler when building source files that are part of 64-bit U-Boot. For 32-bit U-Boot, it is still -m32.

Yes, what I'm trying to understand is
1. U-Boot is compiled _either_ 64-bit, _or_ 32-bit binary -- correct?

Quoted 8 lines
Quoted 4 lines

64-bit U-Boot image is a combination of 32-bit U-Boot (SPL) plus 64-bit U-Boot (proper). For the U-Boot proper, it has be compiled with 64-bit and currently -m64 is missing, primary due to the toolchain we previously used has implicitly -m64 configured.

Okay, thanks for patience and explanation.

Can you somehow (partially) inject this into initial subject + commit message?

Yes, will do in v2.

Regards,
Bin

#12 lore raw

PATCH 1/2 x86: Use default stack boundary alignment

In reply to Bin Meng
Quoted 5 lines · Bin Meng

At present U-Boot x86 build is using -mpreferred-stack-boundary=2 which is 4 bytes stack boundary alignment. With 64-bit U-Boot, the minimal required stack boundary alignment is 16 bytes.

Quoted 8 lines

If -mpreferred-stack-boundary is not specified, the default is 4 (16 bytes). Switch to use the default one.

---

 arch/x86/config.mk | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)