From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76FD2C4332F for ; Sun, 11 Dec 2022 14:12:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2146C85369; Sun, 11 Dec 2022 15:12:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FKe8HrTm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2570585376; Sun, 11 Dec 2022 15:12:25 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BB88D852B0 for ; Sun, 11 Dec 2022 15:12:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C562860DEE; Sun, 11 Dec 2022 14:12:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D94C7C433D2; Sun, 11 Dec 2022 14:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670767939; bh=XuQO5Fe8CnPMRWjTD+dTtKxLgJ9AGvPhx1qzqC8Xj3c=; h=From:To:Cc:Subject:Date:From; b=FKe8HrTm5NMTwDGiqOHyASqosT3/PyIiIaU8C6sHv+Ig4tg6R0quMeeHUrO6m+bPd qDPcTo+JwON5rsKVlOHdeR7EkyrJaoLY7wfKICdZQzSRP39HgkUfLNNt1udCuTWjUd nSbRJIpooveiLiE8YPWzb176RDl6z2g+9E1qyV3Vniwna9wrHsgkWLLjoxOHbya+Ss eutbynuVWd1PclE080E0mLEcQ21L1aq2A8VVy/VQHlKVVGzYRVetXrTREVaunFj3B2 k655XzdPGc5Dl+/g8gUjrFVQ66Ea2M+WwYlOKuBWqIgCd5MRxl1mWnnEzrPMs6Uc3c wdEe8Bax0VO0w== Received: by pali.im (Postfix) id D8A49872; Sun, 11 Dec 2022 15:12:15 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Vagrant Cascadian Cc: u-boot@lists.denx.de Subject: [PATCH u-boot] powerpc/mpc85xx: Pass correct cpu compiler flags Date: Sun, 11 Dec 2022 15:12:04 +0100 Message-Id: <20221211141204.8153-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 -mpcu=8540 then it pass -me500 flag to GNU AS. So it is needed to 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 flag name, for other cores -mcpu matches core name. Older gcc versions (up to gcc 8) had also -mcpu=8548 flag for specifying e500v2 cores but the only difference between -mcpu=8540 and -mcpu=8548 was HW support of double precision floating point. So it is fine to use -mcpu=8540 for both e500v1 and e500v2 cores as u-boot does not use floating point arithmetic. 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(-) diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk index 7a1d81cf2d76..b6b5d2053aea 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 -- 2.20.1