Skip to contentSkip to conversation

x86: Use default stack boundary alignment

PATCH New Bin Meng 2 participants 6 messages Jul 27, 2017 – Aug 1, 2017 x86

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH v2 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.

---

Changes in v2: None

 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 v2 2/2 x86: Enforce toolchain to generate 64-bit codes for 64-bit U-Boot

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 to 64-bit object codes. Attempting to use a toolchain to compile 64-bit U-Boot for qemu-x86_64, like kernel.org 4.9 i386-linux-gcc, 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 because toolchain is preconfigured to generate code for the 32-bit architecture (i386), and currently '-m64' is missing in the makefile fragment. Using kernel.org 4.9 x86_64-linux-gcc works out of the box, since it is preconfigured to generate 64-bit codes.

When compiling U-Boot SPL, '-m32' is passed to the toolchain, no mater 32-bit (i386-linux-) or 64-bit (x86_64-linux) the toolchain is preconfigured to generate.

---

Changes in v2:
- reword the commit message

 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
#4 lore raw

PATCH v2 1/2 x86: Use default stack boundary alignment

In reply to Bin Meng
Quoted 7 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.

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

Quoted 7 lines

---

Changes in v2: None

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

PATCH v2 2/2 x86: Enforce toolchain to generate 64-bit codes for 64-bit U-Boot

In reply to Bin Meng
Quoted 21 lines · Bin Meng

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 to 64-bit object codes. Attempting to use a toolchain to compile 64-bit U-Boot for qemu-x86_64, like kernel.org 4.9 i386-linux-gcc, 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 because toolchain is preconfigured to generate code for the 32-bit architecture (i386), and currently '-m64' is missing in the makefile fragment. Using kernel.org 4.9 x86_64-linux-gcc works out of the box, since it is preconfigured to generate 64-bit codes.

When compiling U-Boot SPL, '-m32' is passed to the toolchain, no mater 32-bit (i386-linux-) or 64-bit (x86_64-linux) the toolchain is preconfigured to generate.

Quoted 7 lines

---

Changes in v2:
- reword the commit message

 arch/x86/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
author
#5 lore raw

PATCH v2 1/2 x86: Use default stack boundary alignment

In reply to Simon Glass
Quoted 11 lines · Simon Glass
Quoted 10 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.

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

---

Quoted 6 lines
Quoted 4 lines

Changes in v2: None

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

applied to u-boot-x86, thanks!

author
#3 lore raw

PATCH v2 2/2 x86: Enforce toolchain to generate 64-bit codes for 64-bit U-Boot

In reply to Simon Glass
Quoted 24 lines · Simon Glass
Quoted 23 lines · Bin Meng

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 to 64-bit object codes. Attempting to use a toolchain to compile 64-bit U-Boot for qemu-x86_64, like kernel.org 4.9 i386-linux-gcc, 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 because toolchain is preconfigured to generate code for the 32-bit architecture (i386), and currently '-m64' is missing in the makefile fragment. Using kernel.org 4.9 x86_64-linux-gcc works out of the box, since it is preconfigured to generate 64-bit codes.

When compiling U-Boot SPL, '-m32' is passed to the toolchain, no mater 32-bit (i386-linux-) or 64-bit (x86_64-linux) the toolchain is preconfigured to generate.

---

Quoted 7 lines
Quoted 5 lines

Changes in v2:
- reword the commit message

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

applied to u-boot-x86, thanks!