9292#include <asm/virt.h>
9393
9494/* Kernel representation of AT_HWCAP and AT_HWCAP2 */
95- static unsigned long elf_hwcap __read_mostly ;
95+ static DECLARE_BITMAP ( elf_hwcap , MAX_CPU_FEATURES ) __read_mostly ;
9696
9797#ifdef CONFIG_COMPAT
9898#define COMPAT_ELF_HWCAP_DEFAULT \
@@ -362,6 +362,7 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr0[] = {
362362};
363363
364364static const struct arm64_ftr_bits ftr_id_aa64mmfr1 [] = {
365+ ARM64_FTR_BITS (FTR_HIDDEN , FTR_NONSTRICT , FTR_LOWER_SAFE , ID_AA64MMFR1_TIDCP1_SHIFT , 4 , 0 ),
365366 ARM64_FTR_BITS (FTR_VISIBLE , FTR_STRICT , FTR_LOWER_SAFE , ID_AA64MMFR1_AFP_SHIFT , 4 , 0 ),
366367 ARM64_FTR_BITS (FTR_HIDDEN , FTR_STRICT , FTR_LOWER_SAFE , ID_AA64MMFR1_ETS_SHIFT , 4 , 0 ),
367368 ARM64_FTR_BITS (FTR_HIDDEN , FTR_STRICT , FTR_LOWER_SAFE , ID_AA64MMFR1_TWED_SHIFT , 4 , 0 ),
@@ -2035,6 +2036,11 @@ static bool is_kvm_protected_mode(const struct arm64_cpu_capabilities *entry, in
20352036}
20362037#endif /* CONFIG_KVM */
20372038
2039+ static void cpu_trap_el0_impdef (const struct arm64_cpu_capabilities * __unused )
2040+ {
2041+ sysreg_clear_set (sctlr_el1 , 0 , SCTLR_EL1_TIDCP );
2042+ }
2043+
20382044/* Internal helper functions to match cpu capability type */
20392045static bool
20402046cpucap_late_cpu_optional (const struct arm64_cpu_capabilities * cap )
@@ -2578,6 +2584,18 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
25782584 .matches = has_cpuid_feature ,
25792585 .min_field_value = ID_AA64ISAR2_EL1_WFxT_IMP ,
25802586 },
2587+ {
2588+ .desc = "Trap EL0 IMPLEMENTATION DEFINED functionality" ,
2589+ .capability = ARM64_HAS_TIDCP1 ,
2590+ .type = ARM64_CPUCAP_SYSTEM_FEATURE ,
2591+ .sys_reg = SYS_ID_AA64MMFR1_EL1 ,
2592+ .sign = FTR_UNSIGNED ,
2593+ .field_pos = ID_AA64MMFR1_TIDCP1_SHIFT ,
2594+ .field_width = 4 ,
2595+ .min_field_value = ID_AA64MMFR1_TIDCP1_IMP ,
2596+ .matches = has_cpuid_feature ,
2597+ .cpu_enable = cpu_trap_el0_impdef ,
2598+ },
25812599 {},
25822600};
25832601
@@ -2680,6 +2698,7 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
26802698 HWCAP_CAP (SYS_ID_AA64ISAR1_EL1 , ID_AA64ISAR1_EL1_FRINTTS_SHIFT , 4 , FTR_UNSIGNED , 1 , CAP_HWCAP , KERNEL_HWCAP_FRINT ),
26812699 HWCAP_CAP (SYS_ID_AA64ISAR1_EL1 , ID_AA64ISAR1_EL1_SB_SHIFT , 4 , FTR_UNSIGNED , 1 , CAP_HWCAP , KERNEL_HWCAP_SB ),
26822700 HWCAP_CAP (SYS_ID_AA64ISAR1_EL1 , ID_AA64ISAR1_EL1_BF16_SHIFT , 4 , FTR_UNSIGNED , 1 , CAP_HWCAP , KERNEL_HWCAP_BF16 ),
2701+ HWCAP_CAP (SYS_ID_AA64ISAR1_EL1 , ID_AA64ISAR1_EL1_BF16_SHIFT , 4 , FTR_UNSIGNED , 2 , CAP_HWCAP , KERNEL_HWCAP_EBF16 ),
26832702 HWCAP_CAP (SYS_ID_AA64ISAR1_EL1 , ID_AA64ISAR1_EL1_DGH_SHIFT , 4 , FTR_UNSIGNED , 1 , CAP_HWCAP , KERNEL_HWCAP_DGH ),
26842703 HWCAP_CAP (SYS_ID_AA64ISAR1_EL1 , ID_AA64ISAR1_EL1_I8MM_SHIFT , 4 , FTR_UNSIGNED , 1 , CAP_HWCAP , KERNEL_HWCAP_I8MM ),
26852704 HWCAP_CAP (SYS_ID_AA64MMFR2_EL1 , ID_AA64MMFR2_AT_SHIFT , 4 , FTR_UNSIGNED , 1 , CAP_HWCAP , KERNEL_HWCAP_USCAT ),
@@ -3155,14 +3174,12 @@ static bool __maybe_unused __system_matches_cap(unsigned int n)
31553174
31563175void cpu_set_feature (unsigned int num )
31573176{
3158- WARN_ON (num >= MAX_CPU_FEATURES );
3159- elf_hwcap |= BIT (num );
3177+ set_bit (num , elf_hwcap );
31603178}
31613179
31623180bool cpu_have_feature (unsigned int num )
31633181{
3164- WARN_ON (num >= MAX_CPU_FEATURES );
3165- return elf_hwcap & BIT (num );
3182+ return test_bit (num , elf_hwcap );
31663183}
31673184EXPORT_SYMBOL_GPL (cpu_have_feature );
31683185
@@ -3173,12 +3190,12 @@ unsigned long cpu_get_elf_hwcap(void)
31733190 * note that for userspace compatibility we guarantee that bits 62
31743191 * and 63 will always be returned as 0.
31753192 */
3176- return lower_32_bits ( elf_hwcap ) ;
3193+ return elf_hwcap [ 0 ] ;
31773194}
31783195
31793196unsigned long cpu_get_elf_hwcap2 (void )
31803197{
3181- return upper_32_bits ( elf_hwcap ) ;
3198+ return elf_hwcap [ 1 ] ;
31823199}
31833200
31843201static void __init setup_system_capabilities (void )
0 commit comments