.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2012 ARM Ltd. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License |
---|
14 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | 4 | */ |
---|
16 | 5 | #ifndef __ASM_HWCAP_H |
---|
17 | 6 | #define __ASM_HWCAP_H |
---|
18 | 7 | |
---|
19 | 8 | #include <uapi/asm/hwcap.h> |
---|
| 9 | +#include <asm/cpufeature.h> |
---|
20 | 10 | |
---|
| 11 | +#define COMPAT_HWCAP_SWP (1 << 0) |
---|
21 | 12 | #define COMPAT_HWCAP_HALF (1 << 1) |
---|
22 | 13 | #define COMPAT_HWCAP_THUMB (1 << 2) |
---|
| 14 | +#define COMPAT_HWCAP_26BIT (1 << 3) |
---|
23 | 15 | #define COMPAT_HWCAP_FAST_MULT (1 << 4) |
---|
| 16 | +#define COMPAT_HWCAP_FPA (1 << 5) |
---|
24 | 17 | #define COMPAT_HWCAP_VFP (1 << 6) |
---|
25 | 18 | #define COMPAT_HWCAP_EDSP (1 << 7) |
---|
| 19 | +#define COMPAT_HWCAP_JAVA (1 << 8) |
---|
| 20 | +#define COMPAT_HWCAP_IWMMXT (1 << 9) |
---|
| 21 | +#define COMPAT_HWCAP_CRUNCH (1 << 10) |
---|
| 22 | +#define COMPAT_HWCAP_THUMBEE (1 << 11) |
---|
26 | 23 | #define COMPAT_HWCAP_NEON (1 << 12) |
---|
27 | 24 | #define COMPAT_HWCAP_VFPv3 (1 << 13) |
---|
| 25 | +#define COMPAT_HWCAP_VFPV3D16 (1 << 14) |
---|
28 | 26 | #define COMPAT_HWCAP_TLS (1 << 15) |
---|
29 | 27 | #define COMPAT_HWCAP_VFPv4 (1 << 16) |
---|
30 | 28 | #define COMPAT_HWCAP_IDIVA (1 << 17) |
---|
31 | 29 | #define COMPAT_HWCAP_IDIVT (1 << 18) |
---|
32 | 30 | #define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) |
---|
| 31 | +#define COMPAT_HWCAP_VFPD32 (1 << 19) |
---|
33 | 32 | #define COMPAT_HWCAP_LPAE (1 << 20) |
---|
34 | 33 | #define COMPAT_HWCAP_EVTSTRM (1 << 21) |
---|
35 | 34 | |
---|
.. | .. |
---|
40 | 39 | #define COMPAT_HWCAP2_CRC32 (1 << 4) |
---|
41 | 40 | |
---|
42 | 41 | #ifndef __ASSEMBLY__ |
---|
| 42 | +#include <linux/log2.h> |
---|
| 43 | + |
---|
| 44 | +/* |
---|
| 45 | + * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields |
---|
| 46 | + * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as |
---|
| 47 | + * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here |
---|
| 48 | + * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart. |
---|
| 49 | + * |
---|
| 50 | + * Hwcaps should be set and tested within the kernel via the |
---|
| 51 | + * cpu_{set,have}_named_feature(feature) where feature is the unique suffix |
---|
| 52 | + * of KERNEL_HWCAP_{feature}. |
---|
| 53 | + */ |
---|
| 54 | +#define __khwcap_feature(x) const_ilog2(HWCAP_ ## x) |
---|
| 55 | +#define KERNEL_HWCAP_FP __khwcap_feature(FP) |
---|
| 56 | +#define KERNEL_HWCAP_ASIMD __khwcap_feature(ASIMD) |
---|
| 57 | +#define KERNEL_HWCAP_EVTSTRM __khwcap_feature(EVTSTRM) |
---|
| 58 | +#define KERNEL_HWCAP_AES __khwcap_feature(AES) |
---|
| 59 | +#define KERNEL_HWCAP_PMULL __khwcap_feature(PMULL) |
---|
| 60 | +#define KERNEL_HWCAP_SHA1 __khwcap_feature(SHA1) |
---|
| 61 | +#define KERNEL_HWCAP_SHA2 __khwcap_feature(SHA2) |
---|
| 62 | +#define KERNEL_HWCAP_CRC32 __khwcap_feature(CRC32) |
---|
| 63 | +#define KERNEL_HWCAP_ATOMICS __khwcap_feature(ATOMICS) |
---|
| 64 | +#define KERNEL_HWCAP_FPHP __khwcap_feature(FPHP) |
---|
| 65 | +#define KERNEL_HWCAP_ASIMDHP __khwcap_feature(ASIMDHP) |
---|
| 66 | +#define KERNEL_HWCAP_CPUID __khwcap_feature(CPUID) |
---|
| 67 | +#define KERNEL_HWCAP_ASIMDRDM __khwcap_feature(ASIMDRDM) |
---|
| 68 | +#define KERNEL_HWCAP_JSCVT __khwcap_feature(JSCVT) |
---|
| 69 | +#define KERNEL_HWCAP_FCMA __khwcap_feature(FCMA) |
---|
| 70 | +#define KERNEL_HWCAP_LRCPC __khwcap_feature(LRCPC) |
---|
| 71 | +#define KERNEL_HWCAP_DCPOP __khwcap_feature(DCPOP) |
---|
| 72 | +#define KERNEL_HWCAP_SHA3 __khwcap_feature(SHA3) |
---|
| 73 | +#define KERNEL_HWCAP_SM3 __khwcap_feature(SM3) |
---|
| 74 | +#define KERNEL_HWCAP_SM4 __khwcap_feature(SM4) |
---|
| 75 | +#define KERNEL_HWCAP_ASIMDDP __khwcap_feature(ASIMDDP) |
---|
| 76 | +#define KERNEL_HWCAP_SHA512 __khwcap_feature(SHA512) |
---|
| 77 | +#define KERNEL_HWCAP_SVE __khwcap_feature(SVE) |
---|
| 78 | +#define KERNEL_HWCAP_ASIMDFHM __khwcap_feature(ASIMDFHM) |
---|
| 79 | +#define KERNEL_HWCAP_DIT __khwcap_feature(DIT) |
---|
| 80 | +#define KERNEL_HWCAP_USCAT __khwcap_feature(USCAT) |
---|
| 81 | +#define KERNEL_HWCAP_ILRCPC __khwcap_feature(ILRCPC) |
---|
| 82 | +#define KERNEL_HWCAP_FLAGM __khwcap_feature(FLAGM) |
---|
| 83 | +#define KERNEL_HWCAP_SSBS __khwcap_feature(SSBS) |
---|
| 84 | +#define KERNEL_HWCAP_SB __khwcap_feature(SB) |
---|
| 85 | +#define KERNEL_HWCAP_PACA __khwcap_feature(PACA) |
---|
| 86 | +#define KERNEL_HWCAP_PACG __khwcap_feature(PACG) |
---|
| 87 | + |
---|
| 88 | +#define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 32) |
---|
| 89 | +#define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) |
---|
| 90 | +#define KERNEL_HWCAP_SVE2 __khwcap2_feature(SVE2) |
---|
| 91 | +#define KERNEL_HWCAP_SVEAES __khwcap2_feature(SVEAES) |
---|
| 92 | +#define KERNEL_HWCAP_SVEPMULL __khwcap2_feature(SVEPMULL) |
---|
| 93 | +#define KERNEL_HWCAP_SVEBITPERM __khwcap2_feature(SVEBITPERM) |
---|
| 94 | +#define KERNEL_HWCAP_SVESHA3 __khwcap2_feature(SVESHA3) |
---|
| 95 | +#define KERNEL_HWCAP_SVESM4 __khwcap2_feature(SVESM4) |
---|
| 96 | +#define KERNEL_HWCAP_FLAGM2 __khwcap2_feature(FLAGM2) |
---|
| 97 | +#define KERNEL_HWCAP_FRINT __khwcap2_feature(FRINT) |
---|
| 98 | +#define KERNEL_HWCAP_SVEI8MM __khwcap2_feature(SVEI8MM) |
---|
| 99 | +#define KERNEL_HWCAP_SVEF32MM __khwcap2_feature(SVEF32MM) |
---|
| 100 | +#define KERNEL_HWCAP_SVEF64MM __khwcap2_feature(SVEF64MM) |
---|
| 101 | +#define KERNEL_HWCAP_SVEBF16 __khwcap2_feature(SVEBF16) |
---|
| 102 | +#define KERNEL_HWCAP_I8MM __khwcap2_feature(I8MM) |
---|
| 103 | +#define KERNEL_HWCAP_BF16 __khwcap2_feature(BF16) |
---|
| 104 | +#define KERNEL_HWCAP_DGH __khwcap2_feature(DGH) |
---|
| 105 | +#define KERNEL_HWCAP_RNG __khwcap2_feature(RNG) |
---|
| 106 | +#define KERNEL_HWCAP_BTI __khwcap2_feature(BTI) |
---|
| 107 | +#define KERNEL_HWCAP_MTE __khwcap2_feature(MTE) |
---|
| 108 | +#define KERNEL_HWCAP_ECV __khwcap2_feature(ECV) |
---|
| 109 | +#define KERNEL_HWCAP_AFP __khwcap2_feature(AFP) |
---|
| 110 | +#define KERNEL_HWCAP_RPRES __khwcap2_feature(RPRES) |
---|
| 111 | + |
---|
43 | 112 | /* |
---|
44 | 113 | * This yields a mask that user programs can use to figure out what |
---|
45 | 114 | * instruction set this cpu supports. |
---|
46 | 115 | */ |
---|
47 | | -#define ELF_HWCAP (elf_hwcap) |
---|
| 116 | +#define ELF_HWCAP cpu_get_elf_hwcap() |
---|
| 117 | +#define ELF_HWCAP2 cpu_get_elf_hwcap2() |
---|
48 | 118 | |
---|
49 | 119 | #ifdef CONFIG_COMPAT |
---|
50 | 120 | #define COMPAT_ELF_HWCAP (compat_elf_hwcap) |
---|
.. | .. |
---|
60 | 130 | #endif |
---|
61 | 131 | }; |
---|
62 | 132 | |
---|
63 | | -extern unsigned long elf_hwcap; |
---|
64 | 133 | #endif |
---|
65 | 134 | #endif |
---|