1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2012 ARM Ltd. 4 */ 5 #ifndef __ASM_HWCAP_H 6 #define __ASM_HWCAP_H 7 8 #include <uapi/asm/hwcap.h> 9 #include <asm/cpufeature.h> 10 11 #define COMPAT_HWCAP_SWP (1 << 0) 12 #define COMPAT_HWCAP_HALF (1 << 1) 13 #define COMPAT_HWCAP_THUMB (1 << 2) 14 #define COMPAT_HWCAP_26BIT (1 << 3) 15 #define COMPAT_HWCAP_FAST_MULT (1 << 4) 16 #define COMPAT_HWCAP_FPA (1 << 5) 17 #define COMPAT_HWCAP_VFP (1 << 6) 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) /* Obsolete */ 22 #define COMPAT_HWCAP_THUMBEE (1 << 11) 23 #define COMPAT_HWCAP_NEON (1 << 12) 24 #define COMPAT_HWCAP_VFPv3 (1 << 13) 25 #define COMPAT_HWCAP_VFPV3D16 (1 << 14) 26 #define COMPAT_HWCAP_TLS (1 << 15) 27 #define COMPAT_HWCAP_VFPv4 (1 << 16) 28 #define COMPAT_HWCAP_IDIVA (1 << 17) 29 #define COMPAT_HWCAP_IDIVT (1 << 18) 30 #define COMPAT_HWCAP_IDIV (COMPAT_HWCAP_IDIVA|COMPAT_HWCAP_IDIVT) 31 #define COMPAT_HWCAP_VFPD32 (1 << 19) 32 #define COMPAT_HWCAP_LPAE (1 << 20) 33 #define COMPAT_HWCAP_EVTSTRM (1 << 21) 34 #define COMPAT_HWCAP_FPHP (1 << 22) 35 #define COMPAT_HWCAP_ASIMDHP (1 << 23) 36 #define COMPAT_HWCAP_ASIMDDP (1 << 24) 37 #define COMPAT_HWCAP_ASIMDFHM (1 << 25) 38 #define COMPAT_HWCAP_ASIMDBF16 (1 << 26) 39 #define COMPAT_HWCAP_I8MM (1 << 27) 40 41 #define COMPAT_HWCAP2_AES (1 << 0) 42 #define COMPAT_HWCAP2_PMULL (1 << 1) 43 #define COMPAT_HWCAP2_SHA1 (1 << 2) 44 #define COMPAT_HWCAP2_SHA2 (1 << 3) 45 #define COMPAT_HWCAP2_CRC32 (1 << 4) 46 #define COMPAT_HWCAP2_SB (1 << 5) 47 #define COMPAT_HWCAP2_SSBS (1 << 6) 48 49 #ifndef __ASSEMBLY__ 50 #include <linux/log2.h> 51 52 /* 53 * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields 54 * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as 55 * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here 56 * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart. 57 * 58 * Hwcaps should be set and tested within the kernel via the 59 * cpu_{set,have}_named_feature(feature) where feature is the unique suffix 60 * of KERNEL_HWCAP_{feature}. 61 */ 62 #define __khwcap_feature(x) const_ilog2(HWCAP_ ## x) 63 #define KERNEL_HWCAP_FP __khwcap_feature(FP) 64 #define KERNEL_HWCAP_ASIMD __khwcap_feature(ASIMD) 65 #define KERNEL_HWCAP_EVTSTRM __khwcap_feature(EVTSTRM) 66 #define KERNEL_HWCAP_AES __khwcap_feature(AES) 67 #define KERNEL_HWCAP_PMULL __khwcap_feature(PMULL) 68 #define KERNEL_HWCAP_SHA1 __khwcap_feature(SHA1) 69 #define KERNEL_HWCAP_SHA2 __khwcap_feature(SHA2) 70 #define KERNEL_HWCAP_CRC32 __khwcap_feature(CRC32) 71 #define KERNEL_HWCAP_ATOMICS __khwcap_feature(ATOMICS) 72 #define KERNEL_HWCAP_FPHP __khwcap_feature(FPHP) 73 #define KERNEL_HWCAP_ASIMDHP __khwcap_feature(ASIMDHP) 74 #define KERNEL_HWCAP_CPUID __khwcap_feature(CPUID) 75 #define KERNEL_HWCAP_ASIMDRDM __khwcap_feature(ASIMDRDM) 76 #define KERNEL_HWCAP_JSCVT __khwcap_feature(JSCVT) 77 #define KERNEL_HWCAP_FCMA __khwcap_feature(FCMA) 78 #define KERNEL_HWCAP_LRCPC __khwcap_feature(LRCPC) 79 #define KERNEL_HWCAP_DCPOP __khwcap_feature(DCPOP) 80 #define KERNEL_HWCAP_SHA3 __khwcap_feature(SHA3) 81 #define KERNEL_HWCAP_SM3 __khwcap_feature(SM3) 82 #define KERNEL_HWCAP_SM4 __khwcap_feature(SM4) 83 #define KERNEL_HWCAP_ASIMDDP __khwcap_feature(ASIMDDP) 84 #define KERNEL_HWCAP_SHA512 __khwcap_feature(SHA512) 85 #define KERNEL_HWCAP_SVE __khwcap_feature(SVE) 86 #define KERNEL_HWCAP_ASIMDFHM __khwcap_feature(ASIMDFHM) 87 #define KERNEL_HWCAP_DIT __khwcap_feature(DIT) 88 #define KERNEL_HWCAP_USCAT __khwcap_feature(USCAT) 89 #define KERNEL_HWCAP_ILRCPC __khwcap_feature(ILRCPC) 90 #define KERNEL_HWCAP_FLAGM __khwcap_feature(FLAGM) 91 #define KERNEL_HWCAP_SSBS __khwcap_feature(SSBS) 92 #define KERNEL_HWCAP_SB __khwcap_feature(SB) 93 #define KERNEL_HWCAP_PACA __khwcap_feature(PACA) 94 #define KERNEL_HWCAP_PACG __khwcap_feature(PACG) 95 96 #define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 64) 97 #define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) 98 #define KERNEL_HWCAP_SVE2 __khwcap2_feature(SVE2) 99 #define KERNEL_HWCAP_SVEAES __khwcap2_feature(SVEAES) 100 #define KERNEL_HWCAP_SVEPMULL __khwcap2_feature(SVEPMULL) 101 #define KERNEL_HWCAP_SVEBITPERM __khwcap2_feature(SVEBITPERM) 102 #define KERNEL_HWCAP_SVESHA3 __khwcap2_feature(SVESHA3) 103 #define KERNEL_HWCAP_SVESM4 __khwcap2_feature(SVESM4) 104 #define KERNEL_HWCAP_FLAGM2 __khwcap2_feature(FLAGM2) 105 #define KERNEL_HWCAP_FRINT __khwcap2_feature(FRINT) 106 #define KERNEL_HWCAP_SVEI8MM __khwcap2_feature(SVEI8MM) 107 #define KERNEL_HWCAP_SVEF32MM __khwcap2_feature(SVEF32MM) 108 #define KERNEL_HWCAP_SVEF64MM __khwcap2_feature(SVEF64MM) 109 #define KERNEL_HWCAP_SVEBF16 __khwcap2_feature(SVEBF16) 110 #define KERNEL_HWCAP_I8MM __khwcap2_feature(I8MM) 111 #define KERNEL_HWCAP_BF16 __khwcap2_feature(BF16) 112 #define KERNEL_HWCAP_DGH __khwcap2_feature(DGH) 113 #define KERNEL_HWCAP_RNG __khwcap2_feature(RNG) 114 #define KERNEL_HWCAP_BTI __khwcap2_feature(BTI) 115 #define KERNEL_HWCAP_MTE __khwcap2_feature(MTE) 116 #define KERNEL_HWCAP_ECV __khwcap2_feature(ECV) 117 #define KERNEL_HWCAP_AFP __khwcap2_feature(AFP) 118 #define KERNEL_HWCAP_RPRES __khwcap2_feature(RPRES) 119 #define KERNEL_HWCAP_MTE3 __khwcap2_feature(MTE3) 120 #define KERNEL_HWCAP_SME __khwcap2_feature(SME) 121 #define KERNEL_HWCAP_SME_I16I64 __khwcap2_feature(SME_I16I64) 122 #define KERNEL_HWCAP_SME_F64F64 __khwcap2_feature(SME_F64F64) 123 #define KERNEL_HWCAP_SME_I8I32 __khwcap2_feature(SME_I8I32) 124 #define KERNEL_HWCAP_SME_F16F32 __khwcap2_feature(SME_F16F32) 125 #define KERNEL_HWCAP_SME_B16F32 __khwcap2_feature(SME_B16F32) 126 #define KERNEL_HWCAP_SME_F32F32 __khwcap2_feature(SME_F32F32) 127 #define KERNEL_HWCAP_SME_FA64 __khwcap2_feature(SME_FA64) 128 #define KERNEL_HWCAP_WFXT __khwcap2_feature(WFXT) 129 #define KERNEL_HWCAP_EBF16 __khwcap2_feature(EBF16) 130 #define KERNEL_HWCAP_SVE_EBF16 __khwcap2_feature(SVE_EBF16) 131 #define KERNEL_HWCAP_CSSC __khwcap2_feature(CSSC) 132 #define KERNEL_HWCAP_RPRFM __khwcap2_feature(RPRFM) 133 #define KERNEL_HWCAP_SVE2P1 __khwcap2_feature(SVE2P1) 134 #define KERNEL_HWCAP_SME2 __khwcap2_feature(SME2) 135 #define KERNEL_HWCAP_SME2P1 __khwcap2_feature(SME2P1) 136 #define KERNEL_HWCAP_SME_I16I32 __khwcap2_feature(SME_I16I32) 137 #define KERNEL_HWCAP_SME_BI32I32 __khwcap2_feature(SME_BI32I32) 138 #define KERNEL_HWCAP_SME_B16B16 __khwcap2_feature(SME_B16B16) 139 #define KERNEL_HWCAP_SME_F16F16 __khwcap2_feature(SME_F16F16) 140 #define KERNEL_HWCAP_MOPS __khwcap2_feature(MOPS) 141 #define KERNEL_HWCAP_HBC __khwcap2_feature(HBC) 142 143 /* 144 * This yields a mask that user programs can use to figure out what 145 * instruction set this cpu supports. 146 */ 147 #define ELF_HWCAP cpu_get_elf_hwcap() 148 #define ELF_HWCAP2 cpu_get_elf_hwcap2() 149 150 #ifdef CONFIG_COMPAT 151 #define COMPAT_ELF_HWCAP (compat_elf_hwcap) 152 #define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) 153 extern unsigned int compat_elf_hwcap, compat_elf_hwcap2; 154 #endif 155 156 enum { 157 CAP_HWCAP = 1, 158 #ifdef CONFIG_COMPAT 159 CAP_COMPAT_HWCAP, 160 CAP_COMPAT_HWCAP2, 161 #endif 162 }; 163 164 #endif 165 #endif 166