From: Heinrich Schuchardt Date: Thu, 11 Oct 2018 17:25:49 +0200 Subject: [U-Boot] [PATCH 1/4] x86: Specify -march=core2 to build 64-bit U-Boot proper In-Reply-To: <1539222787-27208-1-git-send-email-bmeng.cn@gmail.com> References: <1539222787-27208-1-git-send-email-bmeng.cn@gmail.com> Message-ID: <8ddf80a4-89ff-b4be-3919-6de9eba9674d@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 10/11/2018 03:53 AM, Bin Meng wrote: > With newer kernel.org GCC (7.3.0 or 8.1.0), the u-boot.rom image > built for qemu-x86_64 target does not boot. It keeps resetting > soon after the 32-bit SPL jumps to 64-bit proper. Debugging shows > that the reset happens inside env_callback_init(). > > 000000000113dd85 : > 113dd85: 41 54 push %r12 > 113dd87: 55 push %rbp > 113dd88: 31 c0 xor %eax,%eax > 113dd8a: 53 push %rbx > 113dd8b: 0f 57 c0 xorps %xmm0,%xmm0 > > Executing "xorps %xmm0,%xmm0" causes CPU to immediately reset. > However older GCC like 5.4.0 (the one shipped by Ubuntu 16.04) > does not generate such instructions that utilizes SSE for this > function - env_callback_init() and U-Boot boots without any issue. > Explicitly specifying -march=core2 for newer GCC allows U-Boot > proper to boot again. Examine assembly codes of env_callback_init > and there is no SSE instruction in that function hence U-Boot > continues to boot. > > core2 seems to be the oldest arch in GCC that supports 64-bit. > Like 32-bit U-Boot build we use -march=i386 which is the most > conservative cpu type so that the image can run on any x86 > processor, let's do the same for the 64-bit U-Boot build. > > Signed-off-by: Bin Meng Reviewed-by: Heinrich Schuchardt > --- > > arch/x86/config.mk | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/config.mk b/arch/x86/config.mk > index cc94071..576501e 100644 > --- a/arch/x86/config.mk > +++ b/arch/x86/config.mk > @@ -23,7 +23,7 @@ endif > ifeq ($(IS_32BIT),y) > PLATFORM_CPPFLAGS += -march=i386 -m32 > else > -PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64 > +PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64 > endif > > PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden >