Thread (14 messages) 14 messages, 2 authors, 2019-02-19
STALE2669d
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 3/6] arm64: HWCAP: encapsulate elf_hwcap

From: Andrew Murray <hidden>
Date: 2019-02-06 13:32:24
Subsystem: arm64 port (aarch64 architecture), the rest · Maintainers: Catalin Marinas, Will Deacon, Linus Torvalds

The introduction of elf_hwcap2 introduced accessors which ensure that
features are set/tested in the appropriate elf_hwcapX variable.

Let's now mandate access to elf_hwcapX via these accessors by making
elf_hwcapX static within cpufeature.c.

Signed-off-by: Andrew Murray <redacted>
---
 arch/arm64/include/asm/cpufeature.h | 19 ++++---------------
 arch/arm64/include/asm/hwcap.h      |  6 +++---
 arch/arm64/kernel/cpufeature.c      | 33 ++++++++++++++++++++++++++++-----
 3 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 15d939e..0e6132f 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -395,21 +395,10 @@ extern struct static_key_false arm64_const_caps_ready;
 
 bool this_cpu_has_cap(unsigned int cap);
 
-static inline void cpu_set_feature(unsigned int num)
-{
-	if (num < 32)
-		elf_hwcap |= BIT(num);
-	else
-		elf_hwcap2 |= BIT(num - 32);
-}
-
-static inline bool cpu_have_feature(unsigned int num)
-{
-	if (num < 32)
-		return elf_hwcap & BIT(num);
-	else
-		return elf_hwcap2 & BIT(num - 32);
-}
+void cpu_set_feature(unsigned int num);
+bool cpu_have_feature(unsigned int num);
+unsigned long cpu_get_elf_hwcap(void);
+unsigned long cpu_get_elf_hwcap2(void);
 
 /* System capability check for constant caps */
 static inline bool __cpus_have_const_cap(int num)
diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h
index 05ee9b9..ced87ad 100644
--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -17,6 +17,7 @@
 #define __ASM_HWCAP_H
 
 #include <uapi/asm/hwcap.h>
+#include <asm/cpufeature.h>
 
 #define COMPAT_HWCAP_HALF	(1 << 1)
 #define COMPAT_HWCAP_THUMB	(1 << 2)
@@ -80,8 +81,8 @@
  * This yields a mask that user programs can use to figure out what
  * instruction set this cpu supports.
  */
-#define ELF_HWCAP		elf_hwcap
-#define ELF_HWCAP2		elf_hwcap2
+#define ELF_HWCAP		cpu_get_elf_hwcap()
+#define ELF_HWCAP2		cpu_get_elf_hwcap2()
 
 #ifdef CONFIG_COMPAT
 #define COMPAT_ELF_HWCAP	(compat_elf_hwcap)
@@ -97,6 +98,5 @@ enum {
 #endif
 };
 
-extern unsigned long elf_hwcap, elf_hwcap2;
 #endif
 #endif
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index d10a455..5b9620d 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -35,11 +35,8 @@
 #include <asm/traps.h>
 #include <asm/virt.h>
 
-unsigned long elf_hwcap __read_mostly;
-EXPORT_SYMBOL_GPL(elf_hwcap);
-
-unsigned long elf_hwcap2 __read_mostly;
-EXPORT_SYMBOL_GPL(elf_hwcap2);
+static unsigned long elf_hwcap __read_mostly;
+static unsigned long elf_hwcap2 __read_mostly;
 
 #ifdef CONFIG_COMPAT
 #define COMPAT_ELF_HWCAP_DEFAULT	\
@@ -1912,6 +1909,32 @@ bool this_cpu_has_cap(unsigned int n)
 	return false;
 }
 
+void cpu_set_feature(unsigned int num)
+{
+	if (num < 32)
+		elf_hwcap |= BIT(num);
+	else
+		elf_hwcap2 |= BIT(num - 32);
+}
+
+bool cpu_have_feature(unsigned int num)
+{
+	if (num < 32)
+		return elf_hwcap & BIT(num);
+	else
+		return elf_hwcap2 & BIT(num - 32);
+}
+
+unsigned long cpu_get_elf_hwcap(void)
+{
+	return elf_hwcap;
+}
+
+unsigned long cpu_get_elf_hwcap2(void)
+{
+	return elf_hwcap2;
+}
+
 static void __init setup_system_capabilities(void)
 {
 	/*
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help