xref: /openbmc/linux/arch/arm64/include/asm/hwcap.h (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2f668cd16SCatalin Marinas /*
3f668cd16SCatalin Marinas  * Copyright (C) 2012 ARM Ltd.
4f668cd16SCatalin Marinas  */
5f668cd16SCatalin Marinas #ifndef __ASM_HWCAP_H
6f668cd16SCatalin Marinas #define __ASM_HWCAP_H
7f668cd16SCatalin Marinas 
84262a727SDavid Howells #include <uapi/asm/hwcap.h>
9aec0bff7SAndrew Murray #include <asm/cpufeature.h>
10f668cd16SCatalin Marinas 
114e56de82SAnshuman Khandual #define COMPAT_HWCAP_SWP	(1 << 0)
12f668cd16SCatalin Marinas #define COMPAT_HWCAP_HALF	(1 << 1)
13f668cd16SCatalin Marinas #define COMPAT_HWCAP_THUMB	(1 << 2)
144e56de82SAnshuman Khandual #define COMPAT_HWCAP_26BIT	(1 << 3)
15f668cd16SCatalin Marinas #define COMPAT_HWCAP_FAST_MULT	(1 << 4)
164e56de82SAnshuman Khandual #define COMPAT_HWCAP_FPA	(1 << 5)
17f668cd16SCatalin Marinas #define COMPAT_HWCAP_VFP	(1 << 6)
18f668cd16SCatalin Marinas #define COMPAT_HWCAP_EDSP	(1 << 7)
194e56de82SAnshuman Khandual #define COMPAT_HWCAP_JAVA	(1 << 8)
204e56de82SAnshuman Khandual #define COMPAT_HWCAP_IWMMXT	(1 << 9)
2112c3dca2SArnd Bergmann #define COMPAT_HWCAP_CRUNCH	(1 << 10) /* Obsolete */
224e56de82SAnshuman Khandual #define COMPAT_HWCAP_THUMBEE	(1 << 11)
23f668cd16SCatalin Marinas #define COMPAT_HWCAP_NEON	(1 << 12)
24f668cd16SCatalin Marinas #define COMPAT_HWCAP_VFPv3	(1 << 13)
254e56de82SAnshuman Khandual #define COMPAT_HWCAP_VFPV3D16	(1 << 14)
26f668cd16SCatalin Marinas #define COMPAT_HWCAP_TLS	(1 << 15)
27f668cd16SCatalin Marinas #define COMPAT_HWCAP_VFPv4	(1 << 16)
28f668cd16SCatalin Marinas #define COMPAT_HWCAP_IDIVA	(1 << 17)
29f668cd16SCatalin Marinas #define COMPAT_HWCAP_IDIVT	(1 << 18)
30f668cd16SCatalin Marinas #define COMPAT_HWCAP_IDIV	(COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT)
314e56de82SAnshuman Khandual #define COMPAT_HWCAP_VFPD32	(1 << 19)
327d57511dSCatalin Marinas #define COMPAT_HWCAP_LPAE	(1 << 20)
3346efe547SSudeep KarkadaNagesha #define COMPAT_HWCAP_EVTSTRM	(1 << 21)
34846b73a4SAmit Daniel Kachhap #define COMPAT_HWCAP_FPHP	(1 << 22)
35846b73a4SAmit Daniel Kachhap #define COMPAT_HWCAP_ASIMDHP	(1 << 23)
3627addd40SAmit Daniel Kachhap #define COMPAT_HWCAP_ASIMDDP	(1 << 24)
374a87be25SAmit Daniel Kachhap #define COMPAT_HWCAP_ASIMDFHM	(1 << 25)
38f64234faSAmit Daniel Kachhap #define COMPAT_HWCAP_ASIMDBF16	(1 << 26)
390864d1e4SAmit Daniel Kachhap #define COMPAT_HWCAP_I8MM	(1 << 27)
40f668cd16SCatalin Marinas 
414cf761cdSArd Biesheuvel #define COMPAT_HWCAP2_AES	(1 << 0)
424cf761cdSArd Biesheuvel #define COMPAT_HWCAP2_PMULL	(1 << 1)
434cf761cdSArd Biesheuvel #define COMPAT_HWCAP2_SHA1	(1 << 2)
444cf761cdSArd Biesheuvel #define COMPAT_HWCAP2_SHA2	(1 << 3)
454cf761cdSArd Biesheuvel #define COMPAT_HWCAP2_CRC32	(1 << 4)
462d602aa9SAmit Daniel Kachhap #define COMPAT_HWCAP2_SB	(1 << 5)
474f2c9bf1SAmit Daniel Kachhap #define COMPAT_HWCAP2_SSBS	(1 << 6)
484cf761cdSArd Biesheuvel 
491c1e4362SDavid Howells #ifndef __ASSEMBLY__
50aaba098fSAndrew Murray #include <linux/log2.h>
51aaba098fSAndrew Murray 
52aaba098fSAndrew Murray /*
53aaba098fSAndrew Murray  * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields
54aaba098fSAndrew Murray  * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as
55aaba098fSAndrew Murray  * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here
56aaba098fSAndrew Murray  * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart.
57aaba098fSAndrew Murray  *
58aaba098fSAndrew Murray  * Hwcaps should be set and tested within the kernel via the
59aaba098fSAndrew Murray  * cpu_{set,have}_named_feature(feature) where feature is the unique suffix
60aaba098fSAndrew Murray  * of KERNEL_HWCAP_{feature}.
61aaba098fSAndrew Murray  */
62aaba098fSAndrew Murray #define __khwcap_feature(x)		const_ilog2(HWCAP_ ## x)
63aaba098fSAndrew Murray #define KERNEL_HWCAP_FP			__khwcap_feature(FP)
64aaba098fSAndrew Murray #define KERNEL_HWCAP_ASIMD		__khwcap_feature(ASIMD)
65aaba098fSAndrew Murray #define KERNEL_HWCAP_EVTSTRM		__khwcap_feature(EVTSTRM)
66aaba098fSAndrew Murray #define KERNEL_HWCAP_AES		__khwcap_feature(AES)
67aaba098fSAndrew Murray #define KERNEL_HWCAP_PMULL		__khwcap_feature(PMULL)
68aaba098fSAndrew Murray #define KERNEL_HWCAP_SHA1		__khwcap_feature(SHA1)
69aaba098fSAndrew Murray #define KERNEL_HWCAP_SHA2		__khwcap_feature(SHA2)
70aaba098fSAndrew Murray #define KERNEL_HWCAP_CRC32		__khwcap_feature(CRC32)
71aaba098fSAndrew Murray #define KERNEL_HWCAP_ATOMICS		__khwcap_feature(ATOMICS)
72aaba098fSAndrew Murray #define KERNEL_HWCAP_FPHP		__khwcap_feature(FPHP)
73aaba098fSAndrew Murray #define KERNEL_HWCAP_ASIMDHP		__khwcap_feature(ASIMDHP)
74aaba098fSAndrew Murray #define KERNEL_HWCAP_CPUID		__khwcap_feature(CPUID)
75aaba098fSAndrew Murray #define KERNEL_HWCAP_ASIMDRDM		__khwcap_feature(ASIMDRDM)
76aaba098fSAndrew Murray #define KERNEL_HWCAP_JSCVT		__khwcap_feature(JSCVT)
77aaba098fSAndrew Murray #define KERNEL_HWCAP_FCMA		__khwcap_feature(FCMA)
78aaba098fSAndrew Murray #define KERNEL_HWCAP_LRCPC		__khwcap_feature(LRCPC)
79aaba098fSAndrew Murray #define KERNEL_HWCAP_DCPOP		__khwcap_feature(DCPOP)
80aaba098fSAndrew Murray #define KERNEL_HWCAP_SHA3		__khwcap_feature(SHA3)
81aaba098fSAndrew Murray #define KERNEL_HWCAP_SM3		__khwcap_feature(SM3)
82aaba098fSAndrew Murray #define KERNEL_HWCAP_SM4		__khwcap_feature(SM4)
83aaba098fSAndrew Murray #define KERNEL_HWCAP_ASIMDDP		__khwcap_feature(ASIMDDP)
84aaba098fSAndrew Murray #define KERNEL_HWCAP_SHA512		__khwcap_feature(SHA512)
85aaba098fSAndrew Murray #define KERNEL_HWCAP_SVE		__khwcap_feature(SVE)
86aaba098fSAndrew Murray #define KERNEL_HWCAP_ASIMDFHM		__khwcap_feature(ASIMDFHM)
87aaba098fSAndrew Murray #define KERNEL_HWCAP_DIT		__khwcap_feature(DIT)
88aaba098fSAndrew Murray #define KERNEL_HWCAP_USCAT		__khwcap_feature(USCAT)
89aaba098fSAndrew Murray #define KERNEL_HWCAP_ILRCPC		__khwcap_feature(ILRCPC)
90aaba098fSAndrew Murray #define KERNEL_HWCAP_FLAGM		__khwcap_feature(FLAGM)
91aaba098fSAndrew Murray #define KERNEL_HWCAP_SSBS		__khwcap_feature(SSBS)
92aaba098fSAndrew Murray #define KERNEL_HWCAP_SB			__khwcap_feature(SB)
93aaba098fSAndrew Murray #define KERNEL_HWCAP_PACA		__khwcap_feature(PACA)
94aaba098fSAndrew Murray #define KERNEL_HWCAP_PACG		__khwcap_feature(PACG)
95aaba098fSAndrew Murray 
9660c868efSMark Brown #define __khwcap2_feature(x)		(const_ilog2(HWCAP2_ ## x) + 64)
97671db581SAndrew Murray #define KERNEL_HWCAP_DCPODP		__khwcap2_feature(DCPODP)
9806a916feSDave Martin #define KERNEL_HWCAP_SVE2		__khwcap2_feature(SVE2)
9906a916feSDave Martin #define KERNEL_HWCAP_SVEAES		__khwcap2_feature(SVEAES)
10006a916feSDave Martin #define KERNEL_HWCAP_SVEPMULL		__khwcap2_feature(SVEPMULL)
10106a916feSDave Martin #define KERNEL_HWCAP_SVEBITPERM		__khwcap2_feature(SVEBITPERM)
10206a916feSDave Martin #define KERNEL_HWCAP_SVESHA3		__khwcap2_feature(SVESHA3)
10306a916feSDave Martin #define KERNEL_HWCAP_SVESM4		__khwcap2_feature(SVESM4)
10412019374SMark Brown #define KERNEL_HWCAP_FLAGM2		__khwcap2_feature(FLAGM2)
105ca9503fcSMark Brown #define KERNEL_HWCAP_FRINT		__khwcap2_feature(FRINT)
106d4209d8bSSteven Price #define KERNEL_HWCAP_SVEI8MM		__khwcap2_feature(SVEI8MM)
107d4209d8bSSteven Price #define KERNEL_HWCAP_SVEF32MM		__khwcap2_feature(SVEF32MM)
108d4209d8bSSteven Price #define KERNEL_HWCAP_SVEF64MM		__khwcap2_feature(SVEF64MM)
109d4209d8bSSteven Price #define KERNEL_HWCAP_SVEBF16		__khwcap2_feature(SVEBF16)
110d4209d8bSSteven Price #define KERNEL_HWCAP_I8MM		__khwcap2_feature(I8MM)
111d4209d8bSSteven Price #define KERNEL_HWCAP_BF16		__khwcap2_feature(BF16)
112bc206065SWill Deacon #define KERNEL_HWCAP_DGH		__khwcap2_feature(DGH)
1131a50ec0bSRichard Henderson #define KERNEL_HWCAP_RNG		__khwcap2_feature(RNG)
1148ef8f360SDave Martin #define KERNEL_HWCAP_BTI		__khwcap2_feature(BTI)
1153b714d24SVincenzo Frascino #define KERNEL_HWCAP_MTE		__khwcap2_feature(MTE)
116fee29f00SMarc Zyngier #define KERNEL_HWCAP_ECV		__khwcap2_feature(ECV)
1175c13f042SJoey Gouly #define KERNEL_HWCAP_AFP		__khwcap2_feature(AFP)
1181175011aSJoey Gouly #define KERNEL_HWCAP_RPRES		__khwcap2_feature(RPRES)
119d082a025SMark Brown #define KERNEL_HWCAP_MTE3		__khwcap2_feature(MTE3)
1205e64b862SMark Brown #define KERNEL_HWCAP_SME		__khwcap2_feature(SME)
1215e64b862SMark Brown #define KERNEL_HWCAP_SME_I16I64		__khwcap2_feature(SME_I16I64)
1225e64b862SMark Brown #define KERNEL_HWCAP_SME_F64F64		__khwcap2_feature(SME_F64F64)
1235e64b862SMark Brown #define KERNEL_HWCAP_SME_I8I32		__khwcap2_feature(SME_I8I32)
1245e64b862SMark Brown #define KERNEL_HWCAP_SME_F16F32		__khwcap2_feature(SME_F16F32)
1255e64b862SMark Brown #define KERNEL_HWCAP_SME_B16F32		__khwcap2_feature(SME_B16F32)
1265e64b862SMark Brown #define KERNEL_HWCAP_SME_F32F32		__khwcap2_feature(SME_F32F32)
1275e64b862SMark Brown #define KERNEL_HWCAP_SME_FA64		__khwcap2_feature(SME_FA64)
12869bb02ebSMarc Zyngier #define KERNEL_HWCAP_WFXT		__khwcap2_feature(WFXT)
129a6a468f5SMark Brown #define KERNEL_HWCAP_EBF16		__khwcap2_feature(EBF16)
13081ff692aSMark Brown #define KERNEL_HWCAP_SVE_EBF16		__khwcap2_feature(SVE_EBF16)
13195aa6860SMark Brown #define KERNEL_HWCAP_CSSC		__khwcap2_feature(CSSC)
132939e4649SMark Brown #define KERNEL_HWCAP_RPRFM		__khwcap2_feature(RPRFM)
133d12aada8SMark Brown #define KERNEL_HWCAP_SVE2P1		__khwcap2_feature(SVE2P1)
1347d5d8601SMark Brown #define KERNEL_HWCAP_SME2		__khwcap2_feature(SME2)
1357d5d8601SMark Brown #define KERNEL_HWCAP_SME2P1		__khwcap2_feature(SME2P1)
1367d5d8601SMark Brown #define KERNEL_HWCAP_SME_I16I32		__khwcap2_feature(SME_I16I32)
1377d5d8601SMark Brown #define KERNEL_HWCAP_SME_BI32I32	__khwcap2_feature(SME_BI32I32)
1387d5d8601SMark Brown #define KERNEL_HWCAP_SME_B16B16		__khwcap2_feature(SME_B16B16)
1397d5d8601SMark Brown #define KERNEL_HWCAP_SME_F16F16		__khwcap2_feature(SME_F16F16)
140b7564127SKristina Martsenko #define KERNEL_HWCAP_MOPS		__khwcap2_feature(MOPS)
141*7f86d128SJoey Gouly #define KERNEL_HWCAP_HBC		__khwcap2_feature(HBC)
142aaba098fSAndrew Murray 
143f668cd16SCatalin Marinas /*
144f668cd16SCatalin Marinas  * This yields a mask that user programs can use to figure out what
145f668cd16SCatalin Marinas  * instruction set this cpu supports.
146f668cd16SCatalin Marinas  */
147aec0bff7SAndrew Murray #define ELF_HWCAP		cpu_get_elf_hwcap()
148aec0bff7SAndrew Murray #define ELF_HWCAP2		cpu_get_elf_hwcap2()
14946efe547SSudeep KarkadaNagesha 
15046efe547SSudeep KarkadaNagesha #ifdef CONFIG_COMPAT
15146efe547SSudeep KarkadaNagesha #define COMPAT_ELF_HWCAP	(compat_elf_hwcap)
15228964d32SArd Biesheuvel #define COMPAT_ELF_HWCAP2	(compat_elf_hwcap2)
15328964d32SArd Biesheuvel extern unsigned int compat_elf_hwcap, compat_elf_hwcap2;
15446efe547SSudeep KarkadaNagesha #endif
155f668cd16SCatalin Marinas 
15637b01d53SSuzuki K. Poulose enum {
15737b01d53SSuzuki K. Poulose 	CAP_HWCAP = 1,
15837b01d53SSuzuki K. Poulose #ifdef CONFIG_COMPAT
15937b01d53SSuzuki K. Poulose 	CAP_COMPAT_HWCAP,
16037b01d53SSuzuki K. Poulose 	CAP_COMPAT_HWCAP2,
16137b01d53SSuzuki K. Poulose #endif
16237b01d53SSuzuki K. Poulose };
16337b01d53SSuzuki K. Poulose 
164f668cd16SCatalin Marinas #endif
1651c1e4362SDavid Howells #endif
166