From nobody Sat Apr 18 21:04:03 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAC1CC43334 for ; Sun, 10 Jul 2022 17:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbiGJRhT (ORCPT ); Sun, 10 Jul 2022 13:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiGJRhR (ORCPT ); Sun, 10 Jul 2022 13:37:17 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB8F4B491 for ; Sun, 10 Jul 2022 10:37:15 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4LgvN975d3z9tBg; Sun, 10 Jul 2022 19:37:13 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IFYdHpefMfcf; Sun, 10 Jul 2022 19:37:13 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4LgvN95wHnz9sky; Sun, 10 Jul 2022 19:37:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A96FF8B766; Sun, 10 Jul 2022 19:37:13 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 5X18vOPkBfUb; Sun, 10 Jul 2022 19:37:13 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (po17996.idsi0.si.c-s.fr [192.168.232.32]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 69EA38B763; Sun, 10 Jul 2022 19:37:13 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 26AHb6DB1332607 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 10 Jul 2022 19:37:06 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 26AHb5PA1332606; Sun, 10 Jul 2022 19:37:05 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Arnd Bergmann , Segher Boessenkool Subject: [PATCH] powerpc/32: Don't always pass -mcpu=powerpc to the compiler Date: Sun, 10 Jul 2022 19:36:58 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Developer-Signature: v=1; a=ed25519-sha256; t=1657474617; l=4811; s=20211009; h=from:subject:message-id; bh=jPmbUdTK5z1F0Gw1GHFmot5SHRgU7RzNPyx4IiXi7EA=; b=ga5mDMQu9QMVLt+x1Mj8z5lvoroxU6AQ0inO+LQSV9y8xlNx00/KJ60bZkep8K0tYrcQUap7x97Y 5CAwaNmQCsK/u45he3/iwnlt4WXaP1xUP45xp9rE6C/1shFD4q0P X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 4bf4f42a2feb ("powerpc/kbuild: Set default generic machine type for 32-bit compile"), when building a 32 bits kernel with a bi-arch version of GCC, or when building a book3s/32 kernel, the option -mcpu=3Dpowerpc is passed to GCC at all time, relying on it being eventually overriden by a subsequent -mcpu=3Dxxxx. But when building the same kernel with a 32 bits only version of GCC, that is not done, relying on gcc being built with the expected default CPU. This logic has two problems. First, it is a bit fragile to rely on whether the GCC version is bi-arch or not, because today we can have bi-arch versions of GCC configured with a 32 bits default. Second, there are some versions of GCC which don't support -mcpu=3Dpowerpc, for instance for e500 SPE-only versions. So, stop relying on this approximative logic and allow the user to decide whether he/she wants to use the toolchain's default CPU or if he/she wants to set one, and allow only possible CPUs based on the selected target. Reported-by: Pali Roh=C3=A1r Cc: Arnd Bergmann Cc: Segher Boessenkool Signed-off-by: Christophe Leroy Reviewed-by: Arnd Bergmann Tested-by: Pali Roh=C3=A1r --- arch/powerpc/Makefile | 26 +------------------------- arch/powerpc/platforms/Kconfig.cputype | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index a0cd70712061..d54e1fe03551 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -15,23 +15,6 @@ HAS_BIARCH :=3D $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper CROSS32_COMPILE ?=3D =20 -ifeq ($(HAS_BIARCH),y) -ifeq ($(CROSS32_COMPILE),) -ifdef CONFIG_PPC32 -# These options will be overridden by any -mcpu option that the CPU -# or platform code sets later on the command line, but they are needed -# to set a sane 32-bit cpu target for the 64-bit cross compiler which -# may default to the wrong ISA. -KBUILD_CFLAGS +=3D -mcpu=3Dpowerpc -KBUILD_AFLAGS +=3D -mcpu=3Dpowerpc -endif -endif -endif - -ifdef CONFIG_PPC_BOOK3S_32 -KBUILD_CFLAGS +=3D -mcpu=3Dpowerpc -endif - # If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise ju= st use # ppc64_defconfig because we have nothing better to go on. uname :=3D $(shell uname -m) @@ -183,6 +166,7 @@ endif endif =20 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) +=3D $(call cc-option,-mcpu=3D$(CONFIG_TA= RGET_CPU)) +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) +=3D $(call cc-option,-mcpu=3D$(CONFIG_TA= RGET_CPU)) =20 # Altivec option not allowed with e500mc64 in GCC. ifdef CONFIG_ALTIVEC @@ -193,14 +177,6 @@ endif CFLAGS-$(CONFIG_E5500_CPU) +=3D $(E5500_CPU) CFLAGS-$(CONFIG_E6500_CPU) +=3D $(call cc-option,-mcpu=3De6500,$(E5500_CPU= )) =20 -ifdef CONFIG_PPC32 -ifdef CONFIG_PPC_E500MC -CFLAGS-y +=3D $(call cc-option,-mcpu=3De500mc,-mcpu=3Dpowerpc) -else -CFLAGS-$(CONFIG_E500) +=3D $(call cc-option,-mcpu=3D8540 -msoft-float,-mcp= u=3Dpowerpc) -endif -endif - asinstr :=3D $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=3D1) =20 KBUILD_CPPFLAGS +=3D -I $(srctree)/arch/$(ARCH) $(asinstr) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platform= s/Kconfig.cputype index 383ed4fe6013..197653442d9f 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -117,7 +117,8 @@ endchoice =20 choice prompt "CPU selection" - default GENERIC_CPU + default GENERIC_CPU if PPC64 + default POWERPC_CPU if PPC32 help This will create a kernel which is optimised for a particular CPU. The resulting kernel may not run on other CPUs, so use this with care. @@ -135,9 +136,13 @@ config GENERIC_CPU select ARCH_HAS_FAST_MULTIPLIER select PPC_64S_HASH_MMU =20 -config GENERIC_CPU +config POWERPC_CPU bool "Generic 32 bits powerpc" - depends on PPC32 && !PPC_8xx + depends on PPC32 && !PPC_8xx && !E500 + +config TOOLCHAIN_DEFAULT_CPU + bool "Rely on the toolchain's implicit default CPU" + depends on PPC32 =20 config CELL_CPU bool "Cell Broadband Engine" @@ -196,11 +201,19 @@ config G4_CPU depends on PPC_BOOK3S_32 select ALTIVEC =20 +config 8540_CPU + bool "8540" + depends on PPC_85xx && !PPC_E500MC + +config E500MC_CPU + bool "e500mc" + depends on PPC_85xx && PPC_E500MC + endchoice =20 config TARGET_CPU_BOOL bool - default !GENERIC_CPU + default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU =20 config TARGET_CPU string @@ -215,6 +228,9 @@ config TARGET_CPU default "e300c2" if E300C2_CPU default "e300c3" if E300C3_CPU default "G4" if G4_CPU + default "8540" if 8540_CPU + default "e500mc" if E500MC_CPU + default "powerpc" if POWERPC_CPU =20 config PPC_BOOK3S def_bool y --=20 2.36.1