]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.111/arm-8833-1-ensure-that-neon-code-always-compiles-wit.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / releases / 4.14.111 / arm-8833-1-ensure-that-neon-code-always-compiles-wit.patch
CommitLineData
04fd09d4
SL
1From d6f0e6e6811fd3971069ce2bdc581b489694859a Mon Sep 17 00:00:00 2001
2From: Nathan Chancellor <natechancellor@gmail.com>
3Date: Sat, 2 Feb 2019 03:34:36 +0100
4Subject: ARM: 8833/1: Ensure that NEON code always compiles with Clang
5
6[ Upstream commit de9c0d49d85dc563549972edc5589d195cd5e859 ]
7
8While building arm32 allyesconfig, I ran into the following errors:
9
10 arch/arm/lib/xor-neon.c:17:2: error: You should compile this file with
11 '-mfloat-abi=softfp -mfpu=neon'
12
13 In file included from lib/raid6/neon1.c:27:
14 /home/nathan/cbl/prebuilt/lib/clang/8.0.0/include/arm_neon.h:28:2:
15 error: "NEON support not enabled"
16
17Building V=1 showed NEON_FLAGS getting passed along to Clang but
18__ARM_NEON__ was not getting defined. Ultimately, it boils down to Clang
19only defining __ARM_NEON__ when targeting armv7, rather than armv6k,
20which is the '-march' value for allyesconfig.
21
22>From lib/Basic/Targets/ARM.cpp in the Clang source:
23
24 // This only gets set when Neon instructions are actually available, unlike
25 // the VFP define, hence the soft float and arch check. This is subtly
26 // different from gcc, we follow the intent which was that it should be set
27 // when Neon instructions are actually available.
28 if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
29 Builder.defineMacro("__ARM_NEON", "1");
30 Builder.defineMacro("__ARM_NEON__");
31 // current AArch32 NEON implementations do not support double-precision
32 // floating-point even when it is present in VFP.
33 Builder.defineMacro("__ARM_NEON_FP",
34 "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
35 }
36
37Ard Biesheuvel recommended explicitly adding '-march=armv7-a' at the
38beginning of the NEON_FLAGS definitions so that __ARM_NEON__ always gets
39definined by Clang. This doesn't functionally change anything because
40that code will only run where NEON is supported, which is implicitly
41armv7.
42
43Link: https://github.com/ClangBuiltLinux/linux/issues/287
44
45Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
46Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
47Acked-by: Nicolas Pitre <nico@linaro.org>
48Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
49Reviewed-by: Stefan Agner <stefan@agner.ch>
50Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
51Signed-off-by: Sasha Levin <sashal@kernel.org>
52---
53 Documentation/arm/kernel_mode_neon.txt | 4 ++--
54 arch/arm/lib/Makefile | 2 +-
55 arch/arm/lib/xor-neon.c | 2 +-
56 lib/raid6/Makefile | 2 +-
57 4 files changed, 5 insertions(+), 5 deletions(-)
58
59diff --git a/Documentation/arm/kernel_mode_neon.txt b/Documentation/arm/kernel_mode_neon.txt
60index 525452726d31..b9e060c5b61e 100644
61--- a/Documentation/arm/kernel_mode_neon.txt
62+++ b/Documentation/arm/kernel_mode_neon.txt
63@@ -6,7 +6,7 @@ TL;DR summary
64 * Use only NEON instructions, or VFP instructions that don't rely on support
65 code
66 * Isolate your NEON code in a separate compilation unit, and compile it with
67- '-mfpu=neon -mfloat-abi=softfp'
68+ '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'
69 * Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your
70 NEON code
71 * Don't sleep in your NEON code, and be aware that it will be executed with
72@@ -87,7 +87,7 @@ instructions appearing in unexpected places if no special care is taken.
73 Therefore, the recommended and only supported way of using NEON/VFP in the
74 kernel is by adhering to the following rules:
75 * isolate the NEON code in a separate compilation unit and compile it with
76- '-mfpu=neon -mfloat-abi=softfp';
77+ '-march=armv7-a -mfpu=neon -mfloat-abi=softfp';
78 * issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls
79 into the unit containing the NEON code from a compilation unit which is *not*
80 built with the GCC flag '-mfpu=neon' set.
81diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
82index 4cb0b9624d8f..4cf026f3f00d 100644
83--- a/arch/arm/lib/Makefile
84+++ b/arch/arm/lib/Makefile
85@@ -39,7 +39,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S
86 $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S
87
88 ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
89- NEON_FLAGS := -mfloat-abi=softfp -mfpu=neon
90+ NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon
91 CFLAGS_xor-neon.o += $(NEON_FLAGS)
92 obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o
93 endif
94diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c
95index 2c40aeab3eaa..c691b901092f 100644
96--- a/arch/arm/lib/xor-neon.c
97+++ b/arch/arm/lib/xor-neon.c
98@@ -14,7 +14,7 @@
99 MODULE_LICENSE("GPL");
100
101 #ifndef __ARM_NEON__
102-#error You should compile this file with '-mfloat-abi=softfp -mfpu=neon'
103+#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
104 #endif
105
106 /*
107diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
108index ad523be0313b..e0f3b38d6dcb 100644
109--- a/lib/raid6/Makefile
110+++ b/lib/raid6/Makefile
111@@ -40,7 +40,7 @@ endif
112 ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
113 NEON_FLAGS := -ffreestanding
114 ifeq ($(ARCH),arm)
115-NEON_FLAGS += -mfloat-abi=softfp -mfpu=neon
116+NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon
117 endif
118 CFLAGS_recov_neon_inner.o += $(NEON_FLAGS)
119 ifeq ($(ARCH),arm64)
120--
1212.19.1
122