arm64/cache: Restrict which headers are included in __ASSEMBLY__
authorMark Brown <broonie@kernel.org>
Mon, 4 Jul 2022 17:02:39 +0000 (18:02 +0100)
committerWill Deacon <will@kernel.org>
Tue, 5 Jul 2022 10:45:45 +0000 (11:45 +0100)
Future changes to generate register definitions automatically will cause
this header to be included in a linker script. This will mean that headers
it in turn includes that are not safe for use in such a context (eg, due
to the use of assembler macros) cause build problems. Avoid these issues by
moving the affected includes and associated defines to the section of the
file already guarded by ifndef __ASSEMBLY__.

Suggested-by: Will Deacon <will@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20220704170302.2609529-6-broonie@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/cache.h

index 0cbe75b9e4e56838bf39b8d0ba238b08fe8baaa4..da4886b1922bfce2983a57f3334950dd3a91a548 100644 (file)
@@ -5,9 +5,6 @@
 #ifndef __ASM_CACHE_H
 #define __ASM_CACHE_H
 
-#include <asm/cputype.h>
-#include <asm/mte-def.h>
-
 #define CTR_L1IP_SHIFT         14
 #define CTR_L1IP_MASK          3
 #define CTR_DMINLINE_SHIFT     16
@@ -22,8 +19,6 @@
 #define CTR_CACHE_MINLINE_MASK \
        (0xf << CTR_DMINLINE_SHIFT | CTR_IMINLINE_MASK << CTR_IMINLINE_SHIFT)
 
-#define CTR_L1IP(ctr)          (((ctr) >> CTR_L1IP_SHIFT) & CTR_L1IP_MASK)
-
 #define ICACHE_POLICY_VPIPT    0
 #define ICACHE_POLICY_VIPT     2
 #define ICACHE_POLICY_PIPT     3
@@ -31,7 +26,6 @@
 #define L1_CACHE_SHIFT         (6)
 #define L1_CACHE_BYTES         (1 << L1_CACHE_SHIFT)
 
-
 #define CLIDR_LOUU_SHIFT       27
 #define CLIDR_LOC_SHIFT                24
 #define CLIDR_LOUIS_SHIFT      21
@@ -54,6 +48,9 @@
 #include <linux/bitops.h>
 #include <linux/kasan-enabled.h>
 
+#include <asm/cputype.h>
+#include <asm/mte-def.h>
+
 #ifdef CONFIG_KASAN_SW_TAGS
 #define ARCH_SLAB_MINALIGN     (1ULL << KASAN_SHADOW_SCALE_SHIFT)
 #elif defined(CONFIG_KASAN_HW_TAGS)
@@ -65,6 +62,8 @@ static inline unsigned int arch_slab_minalign(void)
 #define arch_slab_minalign() arch_slab_minalign()
 #endif
 
+#define CTR_L1IP(ctr)          (((ctr) >> CTR_L1IP_SHIFT) & CTR_L1IP_MASK)
+
 #define ICACHEF_ALIASING       0
 #define ICACHEF_VPIPT          1
 extern unsigned long __icache_flags;