From c0d0569cf6f7d818cb1bbf5222c5e777bfea4d8c Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Mon, 19 Dec 2022 22:41:52 +0100 Subject: powerpc/mpc85xx: Pass correct cpu compiler flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When gcc's default cpu (selected by --with-cpu= during gcc's configure phase) does not match target U-Boot board cpu then U-Boot binary does not have to be compiled correctly. Lot of distributions sets gcc's default cpu to generic powerpc variant which works fine. U-Boot already pass -Wa,-me500 flag to gcc which instructs GNU AS to accept e500 specific instructions when processing assembler source files (.S). This affects also assembly files generated by gcc from C source files. And because gcc for generic powerpc cpu puts '.machine ppc' at the beginning of the generated assembly file, it basically overwrites -me500 flag by which was GNU AS invoked (from U-boot build system). It started to be an issue since binutils 2.38 which does not keep enabled extra functional units selected by previous cpu. Hence issuing directive '.machine ppc' (generated by gcc for generic powerpc) after '.machine e500' (specifying at command line) disables usage of e500 specific instructions. And compiling arch/powerpc/cpu/mpc85xx/tlb.c code throws following assembler errors: {standard input}: Assembler messages: {standard input}:127: Error: unrecognized opcode: `tlbre' {standard input}:418: Error: unrecognized opcode: `tlbre' {standard input}:821: Error: unrecognized opcode: `msync' {standard input}:821: Error: unrecognized opcode: `tlbwe' {standard input}:884: Error: unrecognized opcode: `tlbsx' This issue was already hit by Debian people and is reported in bug tracker: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003490 Calling gcc with -mcpu=8540 flag fixes this issue because -mcpu=8540 tells gcc to compile code for e500 core/cpu (overwriting gcc's default cpu) and does not put '.machine ppc' directive into assembly anymore. Also if gcc is invoked with -mcpu=8540 then it pass -me500 flag to GNU AS. So it is unnecessary to manually specify -Wa,-me500 flag because it is implicitly added. Fix this issue properly by specifying correct -mcpu compiler flag for all supported powerpc cores in U-Boot mpc85xx platform, which are: e500v1, e500v2, e500mc, e5500 and e6500. For specifying e500v1 and e500v2 cores, gcc has unintuitive -mcpu=8540 and -mcpu=8548 flag names, for other cores -mcpu matches core name. The only difference between gcc's -mcpu=8540 and -mcpu=8548 flags is support for double precision floating point SPE instructions. As U-Boot does not use floating point, it is fine to use -mcpu=8540 for both e500v1 and e500v2 cores. Moreover gcc 9 completely removed e500 floating point support, so since gcc 9 -mcpu=8548 is just alias to -mcpu=8540. Note that U-Boot's CONFIG_E500 option is set also for other cpus, not only for e500v1 and e500v2. So do not check for CONFIG_E500 and rather set e500 as last fallback value when no other mpc85xx cpu matches. Signed-off-by: Pali Rohár --- arch/powerpc/cpu/mpc85xx/config.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk index 7a1d81cf2d7..b6b5d2053ae 100644 --- a/arch/powerpc/cpu/mpc85xx/config.mk +++ b/arch/powerpc/cpu/mpc85xx/config.mk @@ -3,7 +3,7 @@ # (C) Copyright 2002,2003 Motorola Inc. # Xianghua Xiao, X.Xiao@motorola.com -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string +PLATFORM_CPPFLAGS += -msoft-float -mno-string PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC; @@ -11,3 +11,13 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \ $(call cc-option,-mno-spe) + +ifdef CONFIG_E6500 +PLATFORM_CPPFLAGS += -mcpu=e6500 +else ifdef CONFIG_E5500 +PLATFORM_CPPFLAGS += -mcpu=e5500 +else ifdef CONFIG_E500MC +PLATFORM_CPPFLAGS += -mcpu=e500mc +else +PLATFORM_CPPFLAGS += -mcpu=8540 +endif -- cgit v1.3.1 From 138b6061a100f149e9249d09ef3e6db2437ff147 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 11 Dec 2022 15:14:59 +0100 Subject: powerpc/mpc85xx: Improve disabling of SPE instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifying -mspe=no also disables usage of SPE instructions. It is documented in "[PATCH,rs6000] make -mno-spe work as expected" email: http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html So replace -mspe=yes by -mspe=no, so make it clear that u-boot has to be compiled without SPE instructions. Linux kernel contains following Makefile code to achieve it: # No SPE instruction when building kernel # (We use all available options to help semi-broken compilers) KBUILD_CFLAGS += $(call cc-option,-mno-spe) KBUILD_CFLAGS += $(call cc-option,-mspe=no) Do same for U-Boot. Signed-off-by: Pali Rohár --- arch/powerpc/cpu/mpc85xx/config.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'arch') diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk index b6b5d2053ae..482bb90cb12 100644 --- a/arch/powerpc/cpu/mpc85xx/config.mk +++ b/arch/powerpc/cpu/mpc85xx/config.mk @@ -6,11 +6,12 @@ PLATFORM_CPPFLAGS += -msoft-float -mno-string PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables -# -mspe=yes is needed to have -mno-spe accepted by a buggy GCC; +# No SPE instruction when building u-boot +# (We use all available options to help semi-broken compilers) # see "[PATCH,rs6000] make -mno-spe work as expected" on # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html -PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \ - $(call cc-option,-mno-spe) +PLATFORM_CPPFLAGS += $(call cc-option,-mno-spe) \ + $(call cc-option,-mspe=no) ifdef CONFIG_E6500 PLATFORM_CPPFLAGS += -mcpu=e6500 -- cgit v1.3.1 From 1db706edcd72724a6f18228d42b26e6b8e9e51ba Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Mon, 19 Dec 2022 22:46:22 +0100 Subject: powerpc/mpc85xx: Disable AltiVec and VSX instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All vector instructions on powerpc mpc85xx must not be used because U-Boot does not enable them. Usage cause random crashes. SPE vector instructions are already disabled by compiler flags, so disable also AltiVec and VSX vector instructions. Linux kernel disables AltiVec and VSX instructions too. Signed-off-by: Pali Rohár --- arch/powerpc/cpu/mpc85xx/config.mk | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch') diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk index 482bb90cb12..71a98f05c90 100644 --- a/arch/powerpc/cpu/mpc85xx/config.mk +++ b/arch/powerpc/cpu/mpc85xx/config.mk @@ -13,6 +13,10 @@ PLATFORM_RELFLAGS += -msingle-pic-base -fno-jump-tables PLATFORM_CPPFLAGS += $(call cc-option,-mno-spe) \ $(call cc-option,-mspe=no) +# No AltiVec or VSX instructions when building u-boot +PLATFORM_CPPFLAGS += $(call cc-option,-mno-altivec) +PLATFORM_CPPFLAGS += $(call cc-option,-mno-vsx) + ifdef CONFIG_E6500 PLATFORM_CPPFLAGS += -mcpu=e6500 else ifdef CONFIG_E5500 -- cgit v1.3.1