Skip to content

Commit 876e3c8

Browse files
brooniewilldeacon
authored andcommitted
arm64/cpufeature: Pull out helper for CPUID register definitions
We use the same structure to match hwcaps and CPU features so we can use the same helper to generate the fields required. Pull the portion of the current hwcaps helper that initialises the fields out into a separate define placed earlier in the file so we can use it for cpufeatures. No functional change. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent e8d018d commit 876e3c8

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ void dump_cpu_features(void)
140140
pr_emerg("0x%*pb\n", ARM64_NCAPS, &cpu_hwcaps);
141141
}
142142

143+
#define ARM64_CPUID_FIELDS(reg, field, min_value) \
144+
.sys_reg = SYS_##reg, \
145+
.field_pos = reg##_##field##_SHIFT, \
146+
.field_width = reg##_##field##_WIDTH, \
147+
.sign = reg##_##field##_SIGNED, \
148+
.min_field_value = reg##_##field##_##min_value,
149+
143150
#define __ARM64_FTR_BITS(SIGNED, VISIBLE, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \
144151
{ \
145152
.sign = SIGNED, \
@@ -2776,12 +2783,8 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
27762783
};
27772784

27782785
#define HWCAP_CPUID_MATCH(reg, field, min_value) \
2779-
.matches = has_user_cpuid_feature, \
2780-
.sys_reg = SYS_##reg, \
2781-
.field_pos = reg##_##field##_SHIFT, \
2782-
.field_width = reg##_##field##_WIDTH, \
2783-
.sign = reg##_##field##_SIGNED, \
2784-
.min_field_value = reg##_##field##_##min_value,
2786+
.matches = has_user_cpuid_feature, \
2787+
ARM64_CPUID_FIELDS(reg, field, min_value)
27852788

27862789
#define __HWCAP_CAP(name, cap_type, cap) \
27872790
.desc = name, \
@@ -2811,26 +2814,26 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
28112814
#ifdef CONFIG_ARM64_PTR_AUTH
28122815
static const struct arm64_cpu_capabilities ptr_auth_hwcap_addr_matches[] = {
28132816
{
2814-
HWCAP_CPUID_MATCH(ID_AA64ISAR1_EL1, APA, PAuth)
2817+
ARM64_CPUID_FIELDS(ID_AA64ISAR1_EL1, APA, PAuth)
28152818
},
28162819
{
2817-
HWCAP_CPUID_MATCH(ID_AA64ISAR2_EL1, APA3, PAuth)
2820+
ARM64_CPUID_FIELDS(ID_AA64ISAR2_EL1, APA3, PAuth)
28182821
},
28192822
{
2820-
HWCAP_CPUID_MATCH(ID_AA64ISAR1_EL1, API, PAuth)
2823+
ARM64_CPUID_FIELDS(ID_AA64ISAR1_EL1, API, PAuth)
28212824
},
28222825
{},
28232826
};
28242827

28252828
static const struct arm64_cpu_capabilities ptr_auth_hwcap_gen_matches[] = {
28262829
{
2827-
HWCAP_CPUID_MATCH(ID_AA64ISAR1_EL1, GPA, IMP)
2830+
ARM64_CPUID_FIELDS(ID_AA64ISAR1_EL1, GPA, IMP)
28282831
},
28292832
{
2830-
HWCAP_CPUID_MATCH(ID_AA64ISAR2_EL1, GPA3, IMP)
2833+
ARM64_CPUID_FIELDS(ID_AA64ISAR2_EL1, GPA3, IMP)
28312834
},
28322835
{
2833-
HWCAP_CPUID_MATCH(ID_AA64ISAR1_EL1, GPI, IMP)
2836+
ARM64_CPUID_FIELDS(ID_AA64ISAR1_EL1, GPI, IMP)
28342837
},
28352838
{},
28362839
};

0 commit comments

Comments
 (0)