arm64: cpufeature: Reduce number of pointer auth CPU caps from 6 to 4
authorWill Deacon <will.deacon@arm.com>
Wed, 12 Dec 2018 15:52:02 +0000 (15:52 +0000)
committerWill Deacon <will.deacon@arm.com>
Thu, 13 Dec 2018 16:42:47 +0000 (16:42 +0000)
We can easily avoid defining the two meta-capabilities for the address
and generic keys, so remove them and instead just check both of the
architected and impdef capabilities when determining the level of system
support.

Reviewed-by: Suzuki Poulose <suzuki.poulose@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpufeature.c

index 803f388e81d4f285dc0d883e70dfa486b464b635..82e9099834ae3679791dd7e7434e1987a169b418 100644 (file)
 #define ARM64_WORKAROUND_1165522               37
 #define ARM64_HAS_ADDRESS_AUTH_ARCH            38
 #define ARM64_HAS_ADDRESS_AUTH_IMP_DEF         39
-#define ARM64_HAS_ADDRESS_AUTH                 40
-#define ARM64_HAS_GENERIC_AUTH_ARCH            41
-#define ARM64_HAS_GENERIC_AUTH_IMP_DEF         42
-#define ARM64_HAS_GENERIC_AUTH                 43
+#define ARM64_HAS_GENERIC_AUTH_ARCH            40
+#define ARM64_HAS_GENERIC_AUTH_IMP_DEF         41
 
-#define ARM64_NCAPS                            44
+#define ARM64_NCAPS                            42
 
 #endif /* __ASM_CPUCAPS_H */
index daec4b50d7fb615218e19b94c8f2f5298e676742..1e7fcd12b1c13bd3f1bcb5bab00c352a4329d212 100644 (file)
@@ -568,13 +568,15 @@ static inline bool system_supports_cnp(void)
 static inline bool system_supports_address_auth(void)
 {
        return IS_ENABLED(CONFIG_ARM64_PTR_AUTH) &&
-               cpus_have_const_cap(ARM64_HAS_ADDRESS_AUTH);
+               (cpus_have_const_cap(ARM64_HAS_ADDRESS_AUTH_ARCH) ||
+                cpus_have_const_cap(ARM64_HAS_ADDRESS_AUTH_IMP_DEF));
 }
 
 static inline bool system_supports_generic_auth(void)
 {
        return IS_ENABLED(CONFIG_ARM64_PTR_AUTH) &&
-               cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH);
+               (cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH_ARCH) ||
+                cpus_have_const_cap(ARM64_HAS_GENERIC_AUTH_IMP_DEF));
 }
 
 #define ARM64_SSBD_UNKNOWN             -1
index f15000872e0834a9fbc1caf94e003798c34fe122..e0c76622f630044fa93080628c3b3bd933921803 100644 (file)
@@ -1469,6 +1469,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .field_pos = ID_AA64ISAR1_APA_SHIFT,
                .min_field_value = ID_AA64ISAR1_APA_ARCHITECTED,
                .matches = has_cpuid_feature,
+               .cpu_enable = cpu_enable_address_auth,
        },
        {
                .desc = "Address authentication (IMP DEF algorithm)",
@@ -1479,11 +1480,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .field_pos = ID_AA64ISAR1_API_SHIFT,
                .min_field_value = ID_AA64ISAR1_API_IMP_DEF,
                .matches = has_cpuid_feature,
-       },
-       {
-               .capability = ARM64_HAS_ADDRESS_AUTH,
-               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
-               .matches = has_address_auth,
                .cpu_enable = cpu_enable_address_auth,
        },
        {
@@ -1506,11 +1502,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .min_field_value = ID_AA64ISAR1_GPI_IMP_DEF,
                .matches = has_cpuid_feature,
        },
-       {
-               .capability = ARM64_HAS_GENERIC_AUTH,
-               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
-               .matches = has_generic_auth,
-       },
 #endif /* CONFIG_ARM64_PTR_AUTH */
        {},
 };