Skip to contentSkip to conversation

arm64 build failure with CONFIG_ARM64_LSE_ATOMICS=y

DISCUSSION Artem Savkov 4 participants 6 messages Nov 2, 2016 – Nov 4, 2016 arm64

lore
Share & tools
lore
#0 lore raw

Hello Catalin,

Looks like your patch "efd9e03 arm64: Use static keys for CPU features" breaks arm64 build with "CONFIG_ARM64_LSE_ATOMICS=y" because it creates a circular dependency for asm/lse.h through jump_label.h:

CC arch/arm64/kernel/asm-offsets.s
In file included from ./arch/arm64/include/asm/atomic.h:34:0,

                 from ./include/linux/atomic.h:4,
                 from ./include/linux/jump_label.h:169,
                 from ./arch/arm64/include/asm/cpufeature.h:12,
                 from ./arch/arm64/include/asm/alternative.h:4,
                 from ./arch/arm64/include/asm/lse.h:7,
                 from ./arch/arm64/include/asm/spinlock.h:19,
                 from ./include/linux/spinlock.h:87,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/uapi/linux/timex.h:56,
                 from ./include/linux/timex.h:56,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:

./arch/arm64/include/asm/atomic_lse.h: In function ?atomic_andnot?:
./arch/arm64/include/asm/atomic_lse.h:35:15: error: expected string literal before ?ARM64_LSE_ATOMIC_INSN?
asm volatile(ARM64_LSE_ATOMIC_INSN(__LL_SC_ATOMIC(op), \

...

./arch/arm64/include/asm/cmpxchg.h: In function ?__xchg_case_1?:
./arch/arm64/include/asm/cmpxchg.h:38:15: error: expected string literal before ?ARM64_LSE_ATOMIC_INSN?
asm volatile(ARM64_LSE_ATOMIC_INSN( \

Signature · 2 lines
Regards,
  Artem
#1 lore raw

Hi Artem,

Quoted 25 lines · Artem Savkov

Hello Catalin,

Looks like your patch "efd9e03 arm64: Use static keys for CPU features" breaks arm64 build with "CONFIG_ARM64_LSE_ATOMICS=y" because it creates a circular dependency for asm/lse.h through jump_label.h:

CC arch/arm64/kernel/asm-offsets.s
In file included from ./arch/arm64/include/asm/atomic.h:34:0,

                 from ./include/linux/atomic.h:4,
                 from ./include/linux/jump_label.h:169,
                 from ./arch/arm64/include/asm/cpufeature.h:12,
                 from ./arch/arm64/include/asm/alternative.h:4,
                 from ./arch/arm64/include/asm/lse.h:7,
                 from ./arch/arm64/include/asm/spinlock.h:19,
                 from ./include/linux/spinlock.h:87,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/uapi/linux/timex.h:56,
                 from ./include/linux/timex.h:56,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:

./arch/arm64/include/asm/atomic_lse.h: In function ?atomic_andnot?:
./arch/arm64/include/asm/atomic_lse.h:35:15: error: expected string literal before ?ARM64_LSE_ATOMIC_INSN?
asm volatile(ARM64_LSE_ATOMIC_INSN(__LL_SC_ATOMIC(op), \

Quoted 5 lines

...

./arch/arm64/include/asm/cmpxchg.h: In function ?__xchg_case_1?:
./arch/arm64/include/asm/cmpxchg.h:38:15: error: expected string literal before ?ARM64_LSE_ATOMIC_INSN?
asm volatile(ARM64_LSE_ATOMIC_INSN( \

I'm unable to reproduce this. I've tried enabling LSE with defconfig and mainline, using compilers that both do and don't support the instructions.

What am I missing?

Will

#2 lore raw
Quoted 28 lines · Will Deacon

Hi Artem,

Quoted 25 lines · Artem Savkov

Hello Catalin,

Looks like your patch "efd9e03 arm64: Use static keys for CPU features" breaks arm64 build with "CONFIG_ARM64_LSE_ATOMICS=y" because it creates a circular dependency for asm/lse.h through jump_label.h:

CC arch/arm64/kernel/asm-offsets.s
In file included from ./arch/arm64/include/asm/atomic.h:34:0,

                 from ./include/linux/atomic.h:4,
                 from ./include/linux/jump_label.h:169,
                 from ./arch/arm64/include/asm/cpufeature.h:12,
                 from ./arch/arm64/include/asm/alternative.h:4,
                 from ./arch/arm64/include/asm/lse.h:7,
                 from ./arch/arm64/include/asm/spinlock.h:19,
                 from ./include/linux/spinlock.h:87,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/uapi/linux/timex.h:56,
                 from ./include/linux/timex.h:56,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:

./arch/arm64/include/asm/atomic_lse.h: In function ?atomic_andnot?:
./arch/arm64/include/asm/atomic_lse.h:35:15: error: expected string literal before ? ?
asm volatile(ARM64_LSE_ATOMIC_INSN(__LL_SC_ATOMIC(op), \

Quoted 8 lines
Quoted 5 lines

...

./arch/arm64/include/asm/cmpxchg.h: In function ?__xchg_case_1?:
./arch/arm64/include/asm/cmpxchg.h:38:15: error: expected string literal before ?ARM64_LSE_ATOMIC_INSN?
asm volatile(ARM64_LSE_ATOMIC_INSN( \

I'm unable to reproduce this. I've tried enabling LSE with defconfig and mainline, using compilers that both do and don't support the instructions.

I am not able to reproduce it either. One minor problem I see with the commit could be fixed with the following change : Does it help ?

----8>-----

arch/arm64/include/asm/cpufeature.h +1 -1
index 758d74f..62db988 100644
@@ -9,7 +9,6 @@
  #ifndef __ASM_CPUFEATURE_H
  #define __ASM_CPUFEATURE_H
  
-#include <linux/jump_label.h>
  
  #include <asm/hwcap.h>
  #include <asm/sysreg.h>
@@ -45,6 +44,7 @@
  
  #ifndef __ASSEMBLY__
  
+#include <linux/jump_label.h>
  #include <linux/kernel.h>
  
  /* CPU feature register tracking */

Suzuki

#3 lore raw
Quoted 35 lines · Suzuki K Poulose
Quoted 34 lines · Will Deacon

Hi Artem,

Quoted 30 lines · Artem Savkov

Hello Catalin,

Looks like your patch "efd9e03 arm64: Use static keys for CPU features" breaks arm64 build with "CONFIG_ARM64_LSE_ATOMICS=y" because it creates a circular dependency for asm/lse.h through jump_label.h:

CC arch/arm64/kernel/asm-offsets.s
In file included from ./arch/arm64/include/asm/atomic.h:34:0,

                 from ./include/linux/atomic.h:4,
                 from ./include/linux/jump_label.h:169,
                 from ./arch/arm64/include/asm/cpufeature.h:12,
                 from ./arch/arm64/include/asm/alternative.h:4,
                 from ./arch/arm64/include/asm/lse.h:7,
                 from ./arch/arm64/include/asm/spinlock.h:19,
                 from ./include/linux/spinlock.h:87,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/uapi/linux/timex.h:56,
                 from ./include/linux/timex.h:56,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:

./arch/arm64/include/asm/atomic_lse.h: In function ?atomic_andnot?:
./arch/arm64/include/asm/atomic_lse.h:35:15: error: expected string literal before ? ?
asm volatile(ARM64_LSE_ATOMIC_INSN(__LL_SC_ATOMIC(op), \

...

./arch/arm64/include/asm/cmpxchg.h: In function ?__xchg_case_1?:
./arch/arm64/include/asm/cmpxchg.h:38:15: error: expected string literal before ?ARM64_LSE_ATOMIC_INSN?
asm volatile(ARM64_LSE_ATOMIC_INSN( \

Quoted 5 lines
Quoted 2 lines

I'm unable to reproduce this. I've tried enabling LSE with defconfig and mainline, using compilers that both do and don't support the instructions.

I am not able to reproduce it either. One minor problem I see with the commit could be fixed with the following change : Does it help ?

Apparently it fails with an older gcc (4.8.5), but doesn't with 6.2.0. The different bit is that with 4.8.5 I don't have CC_HAVE_ASM_GOTO set. It is reproducible with 6.2.0 if you manually remove CC_HAVE_ASM_GOTO.

Quoted 13 lines

----8>-----

arch/arm64/include/asm/cpufeature.h +0 -1
index 758d74f..62db988 100644
@@ -9,7 +9,6 @@
 #ifndef __ASM_CPUFEATURE_H
 #define __ASM_CPUFEATURE_H
-#include <linux/jump_label.h>
 #include <asm/hwcap.h>
 #include <asm/sysreg.h>

arch/arm64/include/asm/cpufeature.h line 47

Quoted 4 lines
arch/arm64/include/asm/cpufeature.h +1 -0
@@ -45,6 +44,7 @@
 #ifndef __ASSEMBLY__
+#include <linux/jump_label.h>
 #include <linux/kernel.h>
 /* CPU feature register tracking */

No, this doesn't help.

Signature · 2 lines
Regards,
  Artem
maintainer
#4 lore raw
Quoted 6 lines · Artem Savkov
Quoted 5 lines · Suzuki K Poulose
Quoted 4 lines · Will Deacon
Quoted 3 lines · Artem Savkov

Looks like your patch "efd9e03 arm64: Use static keys for CPU features" breaks arm64 build with "CONFIG_ARM64_LSE_ATOMICS=y" because it creates a circular dependency for asm/lse.h through jump_label.h:

[...]

Quoted 3 lines

Apparently it fails with an older gcc (4.8.5), but doesn't with 6.2.0. The different bit is that with 4.8.5 I don't have CC_HAVE_ASM_GOTO set. It is reproducible with 6.2.0 if you manually remove CC_HAVE_ASM_GOTO.

-----------8<----------------

Quoted 1 line

From e27eb40cd5af38f1a5e64553a367220f00a1b5d8 Mon Sep 17 00:00:00 2001

From: Catalin Marinas <[email protected]>
Date: Thu, 3 Nov 2016 18:34:34 +0000
Subject: [PATCH] arm64: Fix circular include of asm/lse.h through
linux/jump_label.h

Commit efd9e03facd0 ("arm64: Use static keys for CPU features") introduced support for static keys in asm/cpufeature.h, including linux/jump_label.h. When CC_HAVE_ASM_GOTO is not defined, this causes a circular dependency via linux/atomic.h, asm/lse.h and asm/cpufeature.h.

This patch moves the capability macros out out of asm/cpufeature.h into a separate asm/cpucaps.h and modifies some of the #includes accordingly.

Fixes efd9e03facd0 ("arm64: Use static keys for CPU features")
---
 arch/arm64/include/asm/alternative.h |  2 +-
 arch/arm64/include/asm/cpucaps.h     | 40 ++++++++++++++++++++++++++++++++++++
 arch/arm64/include/asm/cpufeature.h  | 20 +-----------------
 arch/arm64/include/asm/lse.h         |  1 -
 4 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/alternative.h +1 -1
index 39feb85a6931..6e1cb8c5af4d 100644
@@ -1,7 +1,7 @@
 #ifndef __ASM_ALTERNATIVE_H
 #define __ASM_ALTERNATIVE_H
 
-#include <asm/cpufeature.h>
+#include <asm/cpucaps.h>
 #include <asm/insn.h>
 
 #ifndef __ASSEMBLY__
arch/arm64/include/asm/cpucaps.h new file +40 -0
new file mode 100644
index 000000000000..87b446535185
@@ -0,0 +1,40 @@
+/*
+ * arch/arm64/include/asm/cpucaps.h
+ *
+ * Copyright (C) 2016 ARM Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASM_CPUCAPS_H
+#define __ASM_CPUCAPS_H
+
+#define ARM64_WORKAROUND_CLEAN_CACHE		0
+#define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE	1
+#define ARM64_WORKAROUND_845719			2
+#define ARM64_HAS_SYSREG_GIC_CPUIF		3
+#define ARM64_HAS_PAN				4
+#define ARM64_HAS_LSE_ATOMICS			5
+#define ARM64_WORKAROUND_CAVIUM_23154		6
+#define ARM64_WORKAROUND_834220			7
+#define ARM64_HAS_NO_HW_PREFETCH		8
+#define ARM64_HAS_UAO				9
+#define ARM64_ALT_PAN_NOT_UAO			10
+#define ARM64_HAS_VIRT_HOST_EXTN		11
+#define ARM64_WORKAROUND_CAVIUM_27456		12
+#define ARM64_HAS_32BIT_EL0			13
+#define ARM64_HYP_OFFSET_LOW			14
+#define ARM64_MISMATCHED_CACHE_LINE_SIZE	15
+
+#define ARM64_NCAPS				16
+
+#endif /* __ASM_CPUCAPS_H */
arch/arm64/include/asm/cpufeature.h +1 -19
index a27c3245ba21..0bc0b1de90c4 100644
@@ -11,6 +11,7 @@
 
 #include <linux/jump_label.h>
 
+#include <asm/cpucaps.h>
 #include <asm/hwcap.h>
 #include <asm/sysreg.h>
 
@@ -24,25 +25,6 @@
 #define MAX_CPU_FEATURES	(8 * sizeof(elf_hwcap))
 #define cpu_feature(x)		ilog2(HWCAP_ ## x)
 
-#define ARM64_WORKAROUND_CLEAN_CACHE		0
-#define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE	1
-#define ARM64_WORKAROUND_845719			2
-#define ARM64_HAS_SYSREG_GIC_CPUIF		3
-#define ARM64_HAS_PAN				4
-#define ARM64_HAS_LSE_ATOMICS			5
-#define ARM64_WORKAROUND_CAVIUM_23154		6
-#define ARM64_WORKAROUND_834220			7
-#define ARM64_HAS_NO_HW_PREFETCH		8
-#define ARM64_HAS_UAO				9
-#define ARM64_ALT_PAN_NOT_UAO			10
-#define ARM64_HAS_VIRT_HOST_EXTN		11
-#define ARM64_WORKAROUND_CAVIUM_27456		12
-#define ARM64_HAS_32BIT_EL0			13
-#define ARM64_HYP_OFFSET_LOW			14
-#define ARM64_MISMATCHED_CACHE_LINE_SIZE	15
-
-#define ARM64_NCAPS				16
-
 #ifndef __ASSEMBLY__
 
 #include <linux/kernel.h>
arch/arm64/include/asm/lse.h +0 -1
index 23acc00be32d..fc756e22c84c 100644
@@ -5,7 +5,6 @@
 
 #include <linux/stringify.h>
 #include <asm/alternative.h>
-#include <asm/cpufeature.h>
 
 #ifdef __ASSEMBLER__
 
Signature · 1 line
Catalin
author Tested-by
#5 lore raw
Quoted 30 lines · Catalin Marinas
Quoted 6 lines · Artem Savkov
Quoted 5 lines · Suzuki K Poulose
Quoted 4 lines · Will Deacon
Quoted 3 lines · Artem Savkov

Looks like your patch "efd9e03 arm64: Use static keys for CPU features" breaks arm64 build with "CONFIG_ARM64_LSE_ATOMICS=y" because it creates a circular dependency for asm/lse.h through jump_label.h:

[...]

Quoted 3 lines

Apparently it fails with an older gcc (4.8.5), but doesn't with 6.2.0. The different bit is that with 4.8.5 I don't have CC_HAVE_ASM_GOTO set. It is reproducible with 6.2.0 if you manually remove CC_HAVE_ASM_GOTO.

-----------8<----------------
From e27eb40cd5af38f1a5e64553a367220f00a1b5d8 Mon Sep 17 00:00:00 2001
From: Catalin Marinas <[email protected]>
Date: Thu, 3 Nov 2016 18:34:34 +0000
Subject: [PATCH] arm64: Fix circular include of asm/lse.h through
linux/jump_label.h

Commit efd9e03facd0 ("arm64: Use static keys for CPU features") introduced support for static keys in asm/cpufeature.h, including linux/jump_label.h. When CC_HAVE_ASM_GOTO is not defined, this causes a circular dependency via linux/atomic.h, asm/lse.h and asm/cpufeature.h.

This patch moves the capability macros out out of asm/cpufeature.h into a separate asm/cpucaps.h and modifies some of the #includes accordingly.

Fixes efd9e03facd0 ("arm64: Use static keys for CPU features")
Quoted 7 lines
---
 arch/arm64/include/asm/alternative.h |  2 +-
 arch/arm64/include/asm/cpucaps.h     | 40 ++++++++++++++++++++++++++++++++++++
 arch/arm64/include/asm/cpufeature.h  | 20 +-----------------
 arch/arm64/include/asm/lse.h         |  1 -
 4 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 arch/arm64/include/asm/cpucaps.h

The patch fixes the issue. Thanks.

Signature · 2 lines
Regards,
  Artem