1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #ifndef __ASM_CPUCAPS_H 4 #define __ASM_CPUCAPS_H 5 6 #include <asm/cpucap-defs.h> 7 8 #ifndef __ASSEMBLY__ 9 #include <linux/types.h> 10 /* 11 * Check whether a cpucap is possible at compiletime. 12 */ 13 static __always_inline bool 14 cpucap_is_possible(const unsigned int cap) 15 { 16 compiletime_assert(__builtin_constant_p(cap), 17 "cap must be a constant"); 18 compiletime_assert(cap < ARM64_NCAPS, 19 "cap must be < ARM64_NCAPS"); 20 21 switch (cap) { 22 case ARM64_HAS_PAN: 23 return IS_ENABLED(CONFIG_ARM64_PAN); 24 case ARM64_HAS_EPAN: 25 return IS_ENABLED(CONFIG_ARM64_EPAN); 26 case ARM64_SVE: 27 return IS_ENABLED(CONFIG_ARM64_SVE); 28 case ARM64_SME: 29 case ARM64_SME2: 30 case ARM64_SME_FA64: 31 return IS_ENABLED(CONFIG_ARM64_SME); 32 case ARM64_HAS_CNP: 33 return IS_ENABLED(CONFIG_ARM64_CNP); 34 case ARM64_HAS_ADDRESS_AUTH: 35 case ARM64_HAS_GENERIC_AUTH: 36 return IS_ENABLED(CONFIG_ARM64_PTR_AUTH); 37 case ARM64_HAS_GIC_PRIO_MASKING: 38 return IS_ENABLED(CONFIG_ARM64_PSEUDO_NMI); 39 case ARM64_MTE: 40 return IS_ENABLED(CONFIG_ARM64_MTE); 41 case ARM64_BTI: 42 return IS_ENABLED(CONFIG_ARM64_BTI); 43 case ARM64_HAS_TLB_RANGE: 44 return IS_ENABLED(CONFIG_ARM64_TLB_RANGE); 45 case ARM64_HAS_S1POE: 46 return IS_ENABLED(CONFIG_ARM64_POE); 47 case ARM64_UNMAP_KERNEL_AT_EL0: 48 return IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0); 49 case ARM64_WORKAROUND_843419: 50 return IS_ENABLED(CONFIG_ARM64_ERRATUM_843419); 51 case ARM64_WORKAROUND_1742098: 52 return IS_ENABLED(CONFIG_ARM64_ERRATUM_1742098); 53 case ARM64_WORKAROUND_2645198: 54 return IS_ENABLED(CONFIG_ARM64_ERRATUM_2645198); 55 case ARM64_WORKAROUND_2658417: 56 return IS_ENABLED(CONFIG_ARM64_ERRATUM_2658417); 57 case ARM64_WORKAROUND_CAVIUM_23154: 58 return IS_ENABLED(CONFIG_CAVIUM_ERRATUM_23154); 59 case ARM64_WORKAROUND_NVIDIA_CARMEL_CNP: 60 return IS_ENABLED(CONFIG_NVIDIA_CARMEL_CNP_ERRATUM); 61 case ARM64_WORKAROUND_REPEAT_TLBI: 62 return IS_ENABLED(CONFIG_ARM64_WORKAROUND_REPEAT_TLBI); 63 case ARM64_WORKAROUND_SPECULATIVE_SSBS: 64 return IS_ENABLED(CONFIG_ARM64_ERRATUM_3194386); 65 case ARM64_MPAM: 66 /* 67 * KVM MPAM support doesn't rely on the host kernel supporting MPAM. 68 */ 69 return true; 70 } 71 72 return true; 73 } 74 #endif /* __ASSEMBLY__ */ 75 76 #endif /* __ASM_CPUCAPS_H */ 77