From patchwork Wed Dec 20 13:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 122466 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5537453qgn; Wed, 20 Dec 2017 05:00:54 -0800 (PST) X-Google-Smtp-Source: ACJfBovQ1ffx7XxYUA8csKFFEI5XAdGks3XYZq5W87W4tqiBgCMOk8eAVDStsEgvEmATzCQ1L2i3 X-Received: by 10.99.112.89 with SMTP id a25mr5244973pgn.431.1513774854748; Wed, 20 Dec 2017 05:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513774854; cv=none; d=google.com; s=arc-20160816; b=NaNuMKsJ4OCwvnlRP1Pix0fbnZID2LTROV7QNjoHothIZi7Fez9tkne+m9qV6Enopn TW58P2XyRJTWzt9aOKDej3dlgguGZnUg1P3ya6+/j34H3znHu+HsqCrQHFc55v+9+OjT Cx6NZA1NZapzxF+Kvlbm/dldQa+C3D9tuOXKvldvHY9jJSCh4ItNSJHaG4IiG+LPAPkC ALOEH4q5KMPnTnX+w0lX8yedzYY/oJbqDrAVwo+xY5fEAQdLIRwSCXperMJFalNc1kXC kewi2DKJr+jIH8gjLGxlnq42MHSk7DcqPF/BKkjRu6vpiYwXFkJDl+hv4BRTGjaJdYiA HJeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9hUeuNcpg0iW9lt8BS6MHm2E299MMqF5uaNB1XiPJDk=; b=RTn/ILG2XSluIhTcxHaeW7GABnOhszT/2oee6KhHeWNlouQ5y2HDNFmWptVLox36WO Owa+GXlgUWLqadVCigOXGgbTvi/8mrTSK8ZcAZk1nTBEC02GrKux8meS0Hx4NMpQNWbh yoc0W2eP1Fl5YRb1OXaHAWEZHchSU3+IsKHqy678GxW1ZmcAuQJ/QFNZy5PyRCMMBTO1 nK2uPmQHGFzCldvxZTiCdSTrzyeRFZYRCgSFTxb7cFLELDKQVmcDv0eG6Mf9Bw/lmqlR GD9rKAgNtEgm36XliSU2jnQSE9jlkSAbZRmKUhHCRKy1D/N6o96gBef6AZp4X6MKX/0S tjwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si13086109pfx.6.2017.12.20.05.00.54; Wed, 20 Dec 2017 05:00:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755302AbdLTNAu (ORCPT + 28 others); Wed, 20 Dec 2017 08:00:50 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:56856 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755285AbdLTNAp (ORCPT ); Wed, 20 Dec 2017 08:00:45 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MazIw-1egPg81ygs-00KPu6; Wed, 20 Dec 2017 14:00:18 +0100 From: Arnd Bergmann To: Linus Walleij Cc: Arnd Bergmann , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH, RFT] ARM: use --fix-v4bx to allow building ARMv4 with future gcc Date: Wed, 20 Dec 2017 14:00:05 +0100 Message-Id: <20171220130016.3156090-1-arnd@arndb.de>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kh0W/kA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc-6.0 and later marks support for ARMv3 and ARMv4 as 'deprecated', meaning that this is expected to be removed at some point in the future, with gcc-8.0 as the earliest. When building the kernel, the difference between ARMv4 and ARMv4T is relatively small because the kernel never runs THUMB instructions on ARMv4T and does not need any support for interworking. For any future compiler that does not support -march=armv4, we now fall back to -march=armv4t as the architecture level selection, but keep using -march=armv4 by default as long as that is supported by the compiler. Similarly, the -mtune=strongarm110 and -mtune=strongarm1100 options will go away at the same time as -march=armv4, so this adds a check to see if the compiler supports them, falling back to no -mtune option otherwise. Compiling with -march=armv4t leads the compiler to using 'bx reg' instructions instead of 'mov pc,reg'. This is not supported on ARMv4 based CPUs, but the linker can work around this by rewriting those instructions to the ARMv4 version if we pass --fix-v4bx to the linker. This should work with binutils-2.15 (released May 2004) or higher, and we can probably assume that anyone using gcc-7.x will have a much more recent binutils version as well. However, in order to still allow users of old toolchains to link the kernel, we only pass the option to linkers that support it, based on a $(ld-option ...) call. I'm intentionally passing the flag to all linker versions here regardless of whether it's needed or not, so we can more easily spot any regressions if something goes wrong. For consistency, I'm passing the --fix-v4bx flag for both the vmlinux final link and the individual loadable modules. The module loader code already interprets the R_ARM_V4BX relocations in loadable modules and converts bx instructions into mov even when running on ARMv4T or ARMv5 processors. This is now redundant when we pass --fix-v4bx to the linker for building modules, but I see no harm in leaving the current implementation and doing both. Signed-off-by: Arnd Bergmann --- Please test by making the -march=armv4t switch unconditional and see if that results in a working kernel arch/arm/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.9.0 Tested-by: Linus Walleij for FA526 diff --git a/arch/arm/Makefile b/arch/arm/Makefile index e83f5161fdd8..33b7eb4502aa 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -19,6 +19,11 @@ LDFLAGS_vmlinux += --be8 KBUILD_LDFLAGS_MODULE += --be8 endif +ifeq ($(CONFIG_CPU_32v4),y) +LDFLAGS_vmlinux += $(call ld-option,--fix-v4bx) +LDFLAGS_MODULE += $(call ld-option,--fix-v4bx) +endif + ifeq ($(CONFIG_ARM_MODULE_PLTS),y) KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm/kernel/module.lds endif @@ -76,7 +81,7 @@ arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6k, endif arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t) arch-$(CONFIG_CPU_32v4T) =-D__LINUX_ARM_ARCH__=4 -march=armv4t -arch-$(CONFIG_CPU_32v4) =-D__LINUX_ARM_ARCH__=4 -march=armv4 +arch-$(CONFIG_CPU_32v4) =-D__LINUX_ARM_ARCH__=4 $(call cc-option,-march=armv4,-march=armv4t) arch-$(CONFIG_CPU_32v3) =-D__LINUX_ARM_ARCH__=3 -march=armv3 # Evaluate arch cc-option calls now @@ -94,8 +99,8 @@ tune-$(CONFIG_CPU_ARM922T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM925T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_ARM926T) =-mtune=arm9tdmi tune-$(CONFIG_CPU_FA526) =-mtune=arm9tdmi -tune-$(CONFIG_CPU_SA110) =-mtune=strongarm110 -tune-$(CONFIG_CPU_SA1100) =-mtune=strongarm1100 +tune-$(CONFIG_CPU_SA110) =$(call cc-option,-mtune=strongarm110) +tune-$(CONFIG_CPU_SA1100) =$(call cc-option,-mtune=strongarm1100) tune-$(CONFIG_CPU_XSCALE) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale tune-$(CONFIG_CPU_XSC3) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale tune-$(CONFIG_CPU_FEROCEON) =$(call cc-option,-mtune=marvell-f,-mtune=xscale)