Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3390419imw; Mon, 11 Jul 2022 07:49:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sCFn1fCZBI6oQHwGySAs0c1HyI0r+E7skKPBq03Ia+v6mWDE3RhvZtp49/rFC8UZu1FldE X-Received: by 2002:a17:903:32c1:b0:16c:35b2:18c3 with SMTP id i1-20020a17090332c100b0016c35b218c3mr11639361plr.126.1657550957963; Mon, 11 Jul 2022 07:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657550957; cv=none; d=google.com; s=arc-20160816; b=rH+E7teiDOVV/CPWd2ykHTTzwlpC2aAd4zdnTGdVNVGdHFRIQuDtPECGWB+w2FANhk d8SkiiuoYFjqJ38ow0nrIu9kCkZeIVto61BFHttVn1i5WH87Z/y7irIuF4PDIGDtK8DD RlC25XV4cS2YyWLbd5mQTJ0pNpREb1lDtzZPGh5s76/SvF465j966qX58CGMmXyDow1W 7zzSOJkoGtF7oxTw8M05XTwqN8okHD4/Ff3h90XEGNHy0LTm2GITDBPKPw56HvOQMxbn ryJpnuSFzkuXNn2pmKEL6JqxL1cLJROEhtie83mTygSq/XvNEitpB3x1cRIpkvPAk6WC jZsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EYEcjIQ/lEODdY/cVMGipABLrOcypkuVMtzxZx4x4MI=; b=gFdsKo8/836cc+C4jkul6Hf4JM5lvUQBUwET6Z6Y90o2RxxoicunV6kDztCXdHYBN3 L66kytuSE5/ZjaFlskxiZSiPqKNIvZGzHfBPrjg74YzZPDgomf6cKu35ZeVyiS0UaTg0 BXt2IRaLQsWQpShCpiMJC15QWbpExblAHgcml3aUq1bRBdb2aKadPlOXpYwwF06ksTxi 3zNlvXhy9wk47rLqagPZXALNWLvi9ePwtfF8Id8/RVJb8fI6GPIqcX2wY9dgWzwu0fV/ kc9JzPXtmYzNeBCc0hyc0T7Uh+DdRfK0YeI7PmVUDFKW8gy/PR5M32RbFDmAzHsq8LIg Xo+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r5-20020a632b05000000b0041603075b9asi3841575pgr.309.2022.07.11.07.49.04; Mon, 11 Jul 2022 07:49:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbiGKOUH (ORCPT + 99 others); Mon, 11 Jul 2022 10:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiGKOUD (ORCPT ); Mon, 11 Jul 2022 10:20:03 -0400 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3CC8643DF for ; Mon, 11 Jul 2022 07:20:01 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4LhQy829sLz9sy3; Mon, 11 Jul 2022 16:20:00 +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 GRYAX19yix03; Mon, 11 Jul 2022 16:20:00 +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 4LhQy819wnz9sy2; Mon, 11 Jul 2022 16:20:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 164E78B767; Mon, 11 Jul 2022 16:20:00 +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 Id-bOtBsgPRj; Mon, 11 Jul 2022 16:19:59 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [172.25.230.108]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E75818B763; Mon, 11 Jul 2022 16:19:59 +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 26BEJpYj1585431 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 11 Jul 2022 16:19:51 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 26BEJZjV1585425; Mon, 11 Jul 2022 16:19:35 +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 v1 2/5] powerpc/32: Don't always pass -mcpu=powerpc to the compiler Date: Mon, 11 Jul 2022 16:19:30 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 In-Reply-To: <8abab4888da69ff78b73a56f64d9678a7bf684e9.1657549153.git.christophe.leroy@csgroup.eu> References: <8abab4888da69ff78b73a56f64d9678a7bf684e9.1657549153.git.christophe.leroy@csgroup.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1657549171; l=4557; s=20211009; h=from:subject:message-id; bh=vRZ3QmX/uLX704c6+sclR5HFfArws2qliIqPSPVah7s=; b=/6mBctgd305jQDPNoY7uf76FTWPB7bs20t673S0C+O7BG/gSHcNsGKu0Mwb0FHhfvRsGDGIU/saT G8EqYkVgBN8fa8k6+zgXp6A5JbMphhomxoNCAXgF5ZkGl3ivpun4 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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=powerpc is passed to GCC at all time, relying on it being eventually overriden by a subsequent -mcpu=xxxx. 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=powerpc, 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ár Tested-by: Pali Rohár Reviewed-by: Arnd Bergmann Cc: Segher Boessenkool Signed-off-by: Christophe Leroy --- arch/powerpc/Makefile | 26 +------------------------- arch/powerpc/platforms/Kconfig.cputype | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 28 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 := $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper CROSS32_COMPILE ?= -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 += -mcpu=powerpc -KBUILD_AFLAGS += -mcpu=powerpc -endif -endif -endif - -ifdef CONFIG_PPC_BOOK3S_32 -KBUILD_CFLAGS += -mcpu=powerpc -endif - # If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use # ppc64_defconfig because we have nothing better to go on. uname := $(shell uname -m) @@ -183,6 +166,7 @@ endif endif CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU)) +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU)) # Altivec option not allowed with e500mc64 in GCC. ifdef CONFIG_ALTIVEC @@ -193,14 +177,6 @@ endif CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU) CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU)) -ifdef CONFIG_PPC32 -ifdef CONFIG_PPC_E500MC -CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc) -else -CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc) -endif -endif - asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 9805a2c717b9..bfea5d8452f8 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -135,9 +135,9 @@ config GENERIC_CPU select ARCH_HAS_FAST_MULTIPLIER select PPC_64S_HASH_MMU -config GENERIC_CPU +config POWERPC_CPU bool "Generic 32 bits powerpc" - depends on PPC32 && !PPC_8xx + depends on PPC32 && !PPC_8xx && !PPC_85xx config CELL_CPU bool "Cell Broadband Engine" @@ -196,11 +196,23 @@ config G4_CPU depends on PPC_BOOK3S_32 select ALTIVEC +config E500_CPU + bool "e500 (8540)" + depends on PPC_85xx && !PPC_E500MC + +config E500MC_CPU + bool "e500mc" + depends on PPC_85xx && PPC_E500MC + +config TOOLCHAIN_DEFAULT_CPU + bool "Rely on the toolchain's implicit default CPU" + depends on PPC32 + endchoice config TARGET_CPU_BOOL bool - default !GENERIC_CPU + default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU config TARGET_CPU string @@ -215,6 +227,9 @@ config TARGET_CPU default "e300c2" if E300C2_CPU default "e300c3" if E300C3_CPU default "G4" if G4_CPU + default "8540" if E500_CPU + default "e500mc" if E500MC_CPU + default "powerpc" if POWERPC_CPU config PPC_BOOK3S def_bool y -- 2.36.1