Skip to content

Commit ddadbcd

Browse files
brooniectmarinas
authored andcommitted
arm64: Support AT_HWCAP3
We have filled all 64 bits of AT_HWCAP2 so in order to support discovery of further features provide the framework to use the already defined AT_HWCAP3 for further CPU features. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Link: https://lore.kernel.org/r/20241004-arm64-elf-hwcap3-v2-2-799d1daad8b0@kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 4e6e8c2 commit ddadbcd

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

Documentation/arch/arm64/elf_hwcaps.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ architected discovery mechanism available to userspace code at EL0. The
1616
kernel exposes the presence of these features to userspace through a set
1717
of flags called hwcaps, exposed in the auxiliary vector.
1818

19-
Userspace software can test for features by acquiring the AT_HWCAP or
20-
AT_HWCAP2 entry of the auxiliary vector, and testing whether the relevant
21-
flags are set, e.g.::
19+
Userspace software can test for features by acquiring the AT_HWCAP,
20+
AT_HWCAP2 or AT_HWCAP3 entry of the auxiliary vector, and testing
21+
whether the relevant flags are set, e.g.::
2222

2323
bool floating_point_is_present(void)
2424
{

arch/arm64/include/asm/cpufeature.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <asm/hwcap.h>
1313
#include <asm/sysreg.h>
1414

15-
#define MAX_CPU_FEATURES 128
15+
#define MAX_CPU_FEATURES 192
1616
#define cpu_feature(x) KERNEL_HWCAP_ ## x
1717

1818
#define ARM64_SW_FEATURE_OVERRIDE_NOKASLR 0
@@ -438,6 +438,7 @@ void cpu_set_feature(unsigned int num);
438438
bool cpu_have_feature(unsigned int num);
439439
unsigned long cpu_get_elf_hwcap(void);
440440
unsigned long cpu_get_elf_hwcap2(void);
441+
unsigned long cpu_get_elf_hwcap3(void);
441442

442443
#define cpu_set_named_feature(name) cpu_set_feature(cpu_feature(name))
443444
#define cpu_have_named_feature(name) cpu_have_feature(cpu_feature(name))

arch/arm64/include/asm/hwcap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,21 @@
159159
#define KERNEL_HWCAP_SME_SF8DP2 __khwcap2_feature(SME_SF8DP2)
160160
#define KERNEL_HWCAP_POE __khwcap2_feature(POE)
161161

162+
#define __khwcap3_feature(x) (const_ilog2(HWCAP3_ ## x) + 128)
163+
162164
/*
163165
* This yields a mask that user programs can use to figure out what
164166
* instruction set this cpu supports.
165167
*/
166168
#define ELF_HWCAP cpu_get_elf_hwcap()
167169
#define ELF_HWCAP2 cpu_get_elf_hwcap2()
170+
#define ELF_HWCAP3 cpu_get_elf_hwcap3()
168171

169172
#ifdef CONFIG_COMPAT
170173
#define COMPAT_ELF_HWCAP (compat_elf_hwcap)
171174
#define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2)
172-
extern unsigned int compat_elf_hwcap, compat_elf_hwcap2;
175+
#define COMPAT_ELF_HWCAP3 (compat_elf_hwcap3)
176+
extern unsigned int compat_elf_hwcap, compat_elf_hwcap2, compat_elf_hwcap3;
173177
#endif
174178

175179
enum {

arch/arm64/include/uapi/asm/hwcap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,8 @@
124124
#define HWCAP2_SME_SF8DP2 (1UL << 62)
125125
#define HWCAP2_POE (1UL << 63)
126126

127+
/*
128+
* HWCAP3 flags - for AT_HWCAP3
129+
*/
130+
127131
#endif /* _UAPI__ASM_HWCAP_H */

arch/arm64/kernel/cpufeature.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static DECLARE_BITMAP(elf_hwcap, MAX_CPU_FEATURES) __read_mostly;
103103
COMPAT_HWCAP_LPAE)
104104
unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT;
105105
unsigned int compat_elf_hwcap2 __read_mostly;
106+
unsigned int compat_elf_hwcap3 __read_mostly;
106107
#endif
107108

108109
DECLARE_BITMAP(system_cpucaps, ARM64_NCAPS);
@@ -3499,6 +3500,11 @@ unsigned long cpu_get_elf_hwcap2(void)
34993500
return elf_hwcap[1];
35003501
}
35013502

3503+
unsigned long cpu_get_elf_hwcap3(void)
3504+
{
3505+
return elf_hwcap[2];
3506+
}
3507+
35023508
static void __init setup_boot_cpu_capabilities(void)
35033509
{
35043510
/*

0 commit comments

Comments
 (0)