Commit 9a21c96c authored by Andre Przywara's avatar Andre Przywara Committed by Sasha Levin

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: default avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>

Cc: <stable@vger.kernel.org> # v3.18.y
(cherry picked from commit 930da09f)
Signed-off-by: default avatarKevin Hilman <khilman@linaro.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent dd690343
...@@ -21,9 +21,29 @@ ...@@ -21,9 +21,29 @@
#define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap)) #define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap))
#define cpu_feature(x) ilog2(HWCAP_ ## x) #define cpu_feature(x) ilog2(HWCAP_ ## x)
#define NCAPS 0
extern DECLARE_BITMAP(cpu_hwcaps, NCAPS);
static inline bool cpu_have_feature(unsigned int num) static inline bool cpu_have_feature(unsigned int num)
{ {
return elf_hwcap & (1UL << num); return elf_hwcap & (1UL << num);
} }
static inline bool cpus_have_cap(unsigned int num)
{
if (num >= NCAPS)
return false;
return test_bit(num, cpu_hwcaps);
}
static inline void cpus_set_cap(unsigned int num)
{
if (num >= NCAPS)
pr_warn("Attempt to set an illegal CPU capability (%d >= %d)\n",
num, NCAPS);
else
__set_bit(num, cpu_hwcaps);
}
#endif #endif
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <asm/cputype.h> #include <asm/cputype.h>
#include <asm/elf.h> #include <asm/elf.h>
#include <asm/cputable.h> #include <asm/cputable.h>
#include <asm/cpufeature.h>
#include <asm/cpu_ops.h> #include <asm/cpu_ops.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/setup.h> #include <asm/setup.h>
...@@ -79,6 +80,8 @@ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT; ...@@ -79,6 +80,8 @@ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT;
unsigned int compat_elf_hwcap2 __read_mostly; unsigned int compat_elf_hwcap2 __read_mostly;
#endif #endif
DECLARE_BITMAP(cpu_hwcaps, NCAPS);
static const char *cpu_name; static const char *cpu_name;
phys_addr_t __fdt_pointer __initdata; phys_addr_t __fdt_pointer __initdata;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment