diff options
author | Andre Przywara <andre.przywara@arm.com> | 2014-11-14 10:54:07 -0500 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2014-11-25 08:22:37 -0500 |
commit | 930da09f5e50dd22fb0a8600388da8677d62d671 (patch) | |
tree | c2cfac924f9513700dad6bffdda1b8838b73b145 /arch/arm64 | |
parent | 909633957d85561dab7655d69a9d17dd16231d92 (diff) |
arm64: add cpu_capabilities bitmap
For taking note if at least one CPU in the system needs a bug
workaround or would benefit from a code optimization, we create a new
bitmap to hold (artificial) feature bits.
Since elf_hwcap is part of the userland ABI, we keep it alone and
introduce a new data structure for that (along with some accessors).
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/include/asm/cpufeature.h | 20 | ||||
-rw-r--r-- | arch/arm64/kernel/setup.c | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index cd4ac0516488..20b2b3d6b702 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h | |||
@@ -21,9 +21,29 @@ | |||
21 | #define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap)) | 21 | #define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap)) |
22 | #define cpu_feature(x) ilog2(HWCAP_ ## x) | 22 | #define cpu_feature(x) ilog2(HWCAP_ ## x) |
23 | 23 | ||
24 | #define NCAPS 0 | ||
25 | |||
26 | extern DECLARE_BITMAP(cpu_hwcaps, NCAPS); | ||
27 | |||
24 | static inline bool cpu_have_feature(unsigned int num) | 28 | static inline bool cpu_have_feature(unsigned int num) |
25 | { | 29 | { |
26 | return elf_hwcap & (1UL << num); | 30 | return elf_hwcap & (1UL << num); |
27 | } | 31 | } |
28 | 32 | ||
33 | static inline bool cpus_have_cap(unsigned int num) | ||
34 | { | ||
35 | if (num >= NCAPS) | ||
36 | return false; | ||
37 | return test_bit(num, cpu_hwcaps); | ||
38 | } | ||
39 | |||
40 | static inline void cpus_set_cap(unsigned int num) | ||
41 | { | ||
42 | if (num >= NCAPS) | ||
43 | pr_warn("Attempt to set an illegal CPU capability (%d >= %d)\n", | ||
44 | num, NCAPS); | ||
45 | else | ||
46 | __set_bit(num, cpu_hwcaps); | ||
47 | } | ||
48 | |||
29 | #endif | 49 | #endif |
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 2e17bd3806c8..c8629eb07ba6 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include <asm/cputype.h> | 50 | #include <asm/cputype.h> |
51 | #include <asm/elf.h> | 51 | #include <asm/elf.h> |
52 | #include <asm/cputable.h> | 52 | #include <asm/cputable.h> |
53 | #include <asm/cpufeature.h> | ||
53 | #include <asm/cpu_ops.h> | 54 | #include <asm/cpu_ops.h> |
54 | #include <asm/sections.h> | 55 | #include <asm/sections.h> |
55 | #include <asm/setup.h> | 56 | #include <asm/setup.h> |
@@ -79,6 +80,8 @@ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT; | |||
79 | unsigned int compat_elf_hwcap2 __read_mostly; | 80 | unsigned int compat_elf_hwcap2 __read_mostly; |
80 | #endif | 81 | #endif |
81 | 82 | ||
83 | DECLARE_BITMAP(cpu_hwcaps, NCAPS); | ||
84 | |||
82 | static const char *cpu_name; | 85 | static const char *cpu_name; |
83 | phys_addr_t __fdt_pointer __initdata; | 86 | phys_addr_t __fdt_pointer __initdata; |
84 | 87 | ||