Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1066200imu; Sat, 15 Dec 2018 13:24:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZkaLVDFHlRn8cEtcOmyi86R1n6BMa6B0ZgDuoEpKNugsOOTFqXCX1jFH5Rom0tUhZ6JFH X-Received: by 2002:a63:6604:: with SMTP id a4mr1536229pgc.118.1544909086137; Sat, 15 Dec 2018 13:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544909086; cv=none; d=google.com; s=arc-20160816; b=YBb6peKqlh79fMARYf1QLm/rzn8cz3XBkleiCIaKxKAzULvtlENStv3R5dYM5zt210 OxEdVpCKW3T2dVuq+r7TYigr04C85C1UPeK9oXM6ku2bdgFnRArmYKQj+sRelxEEUC2Z 2U8as2yOwynNW8GNlq6ZYqjLcrxovf3KBjvXNuTrBcKcVqGDPLanI3xbnEhd9u8D+SqB 0Y43CsZgIbFNIbE1OYDHTEMnMdSC/1dOkx/6Ps49ZYpgUX0nJpkZeTVlan1qI1+3a0of KZAS4V+3OOVzc6W6rZj+AEeeYj1XIGhB/2h5VGLBt5FQ4LnSinTpt4vxpA+s59ZfV6t5 Shwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wbAhpvg6Y90F4G+K9k9yPIb45r9KUwGWnfc1MZxSrNc=; b=UAYxmE2PhzWoynkksdpF8uxl9adnKjhbZX/6Eu7EG2Z5n2CHOYcb35WdBM4fKEJazj OKg3sMSN7m4mzNismvLpRRSvuAVImtUMrgTjDZbIeDzU9wiGtMogAGLpLPIHzAgd5HaK WHN6jxMd9ewZkUerJrE/czJ2quCQPL/k67bQZmY8h7w8gK9lQKmEJ2gVkt63NdfqahL0 IUQ5D6/Sm/3nwXdBevuvmlROOgvZ0vgMnYDEowG70ThZULbBNxGl0fzOUSvVjpMFBAOj tfytCWS6qOTMBsxH6iyLwLqcwfQirbFUxYV8/sozXTwU2bKSoVTUb/U6e3HEeFyGSvU8 oTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iTFiE5ht; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n184si7531570pgn.95.2018.12.15.13.24.30; Sat, 15 Dec 2018 13:24:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iTFiE5ht; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729730AbeLOVXi (ORCPT + 99 others); Sat, 15 Dec 2018 16:23:38 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33432 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbeLOVXf (ORCPT ); Sat, 15 Dec 2018 16:23:35 -0500 Received: by mail-wm1-f68.google.com with SMTP id r24so1756759wmh.0; Sat, 15 Dec 2018 13:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wbAhpvg6Y90F4G+K9k9yPIb45r9KUwGWnfc1MZxSrNc=; b=iTFiE5httGBQlhhpliqzt6RIalaGvHQ5HnZofy8KSyfiTQ0sCCNcKYtAS8OP6HWEW8 RXOiiLyHRArYHwhh3usoK/8vHb6dk8S677sDGsb0CU/asDU/tWFYiloHE5VJQdAhyU+h 3d/ljZ3QXBl2SW5hSLWj09OfZM3PqWz5P6jusr9WLL0OQ0rB+uAQYJs+Z4U+1HJb8l3b yYeYPlkEo7djmBLTugI4OHR15zGGo9kwrAT3IYEHzrqHJc/2SmH6ecWsdmHRX4Do6f54 cbTmcQ9C2VOhFubPw/Dy6CaicGR1qZU0dRf7kWRGQZ3Yfff59miOF1WoKwfH4RGaQCUr d5Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wbAhpvg6Y90F4G+K9k9yPIb45r9KUwGWnfc1MZxSrNc=; b=h+FJhZPO1w2cHwENwolGr1UKicvNLS0ynLSAkuxNvDFhloyh8/KKMX7wpPVNat7Ytc 4/4TkLhVsFWchEVzUEvoSO+MgJH5svHy+5jPmQYjjkPE+tEjBGml8uMBPQ5N9xkxNMHL C5brxSne7P/pXxkuhhm2FjGGFt1kuqQrQbWwJeuJJaf+QNHgYXte2PidCvw80Tyl8htn TwqVY4DiQu8YjDr4vlCN7wgIf69Fupzd2KNzxPrHpojzRHCdufmuTTX7w/17mr2B+frz edIDkq1HaGpU/NyLbMLga3Bc6hfyeE4g/P4oRZWXJVVrDetw2G9P3nEjF6vAWHBWzd9V Wfvw== X-Gm-Message-State: AA+aEWYXgf5yaaP36xRcceWs7FX7QAmMJrpNLIyCJMFDgzuRuUDP+Fxw AkjlnFMnoldrRpQBsTopNGU= X-Received: by 2002:a1c:c10f:: with SMTP id r15mr7163001wmf.27.1544909011793; Sat, 15 Dec 2018 13:23:31 -0800 (PST) Received: from localhost.localdomain ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id o8sm9889931wrx.15.2018.12.15.13.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Dec 2018 13:23:31 -0800 (PST) From: Nathan Chancellor To: Russell King , Ard Biesheuvel Cc: Jonathan Corbet , Nicolas Pitre , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Tri Vo , Nathan Chancellor Subject: [PATCH] ARM: Ensure that NEON code always compiles with Clang Date: Sat, 15 Dec 2018 14:23:05 -0700 Message-Id: <20181215212304.19390-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While building arm32 allyesconfig, I ran into the following errors: arch/arm/lib/xor-neon.c:17:2: error: You should compile this file with '-mfloat-abi=softfp -mfpu=neon' In file included from lib/raid6/neon1.c:27: /home/nathan/cbl/prebuilt/lib/clang/8.0.0/include/arm_neon.h:28:2: error: "NEON support not enabled" Building V=1 showed NEON_FLAGS getting passed along to Clang but __ARM_NEON__ was not getting defined. Ultimately, it boils down to Clang only defining __ARM_NEON__ when targeting armv7, rather than armv6k, which is the '-march' value for allyesconfig. From lib/Basic/Targets/ARM.cpp in the Clang source: // This only gets set when Neon instructions are actually available, unlike // the VFP define, hence the soft float and arch check. This is subtly // different from gcc, we follow the intent which was that it should be set // when Neon instructions are actually available. if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) { Builder.defineMacro("__ARM_NEON", "1"); Builder.defineMacro("__ARM_NEON__"); // current AArch32 NEON implementations do not support double-precision // floating-point even when it is present in VFP. Builder.defineMacro("__ARM_NEON_FP", "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP)); } Ard Biesheuvel recommended explicitly adding '-march=armv7-a' at the beginning of the NEON_FLAGS definitions so that __ARM_NEON__ always gets definined by Clang. This doesn't functionally change anything because that code will only run where NEON is supported, which is implicitly armv7. Link: https://github.com/ClangBuiltLinux/linux/issues/287 Suggested-by: Ard Biesheuvel Signed-off-by: Nathan Chancellor --- Documentation/arm/kernel_mode_neon.txt | 4 ++-- arch/arm/lib/Makefile | 2 +- arch/arm/lib/xor-neon.c | 2 +- lib/raid6/Makefile | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/arm/kernel_mode_neon.txt b/Documentation/arm/kernel_mode_neon.txt index 525452726d31..b9e060c5b61e 100644 --- a/Documentation/arm/kernel_mode_neon.txt +++ b/Documentation/arm/kernel_mode_neon.txt @@ -6,7 +6,7 @@ TL;DR summary * Use only NEON instructions, or VFP instructions that don't rely on support code * Isolate your NEON code in a separate compilation unit, and compile it with - '-mfpu=neon -mfloat-abi=softfp' + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp' * Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your NEON code * Don't sleep in your NEON code, and be aware that it will be executed with @@ -87,7 +87,7 @@ instructions appearing in unexpected places if no special care is taken. Therefore, the recommended and only supported way of using NEON/VFP in the kernel is by adhering to the following rules: * isolate the NEON code in a separate compilation unit and compile it with - '-mfpu=neon -mfloat-abi=softfp'; + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'; * issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls into the unit containing the NEON code from a compilation unit which is *not* built with the GCC flag '-mfpu=neon' set. diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index ad25fd1872c7..0bff0176db2c 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -39,7 +39,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S ifeq ($(CONFIG_KERNEL_MODE_NEON),y) - NEON_FLAGS := -mfloat-abi=softfp -mfpu=neon + NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon CFLAGS_xor-neon.o += $(NEON_FLAGS) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o endif diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c index a6741a895189..4600b62d845f 100644 --- a/arch/arm/lib/xor-neon.c +++ b/arch/arm/lib/xor-neon.c @@ -14,7 +14,7 @@ MODULE_LICENSE("GPL"); #ifndef __ARM_NEON__ -#error You should compile this file with '-mfloat-abi=softfp -mfpu=neon' +#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon' #endif /* diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index 2f8b61dfd9b0..bfec7c87c61e 100644 --- a/lib/raid6/Makefile +++ b/lib/raid6/Makefile @@ -25,7 +25,7 @@ endif ifeq ($(CONFIG_KERNEL_MODE_NEON),y) NEON_FLAGS := -ffreestanding ifeq ($(ARCH),arm) -NEON_FLAGS += -mfloat-abi=softfp -mfpu=neon +NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon endif CFLAGS_recov_neon_inner.o += $(NEON_FLAGS) ifeq ($(ARCH),arm64) -- 2.20.1