arm64: cpufeature: Rework ptr auth hwcaps using multi_entry_cap_matches
Open-coding the pointer-auth HWCAPs is a mess and can be avoided by reusing the multi-cap logic from the CPU errata framework. Move the multi_entry_cap_matches code to cpufeature.h and reuse it for the pointer auth HWCAPs. Reviewed-by: Suzuki Poulose <suzuki.poulose@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
This commit is contained in:
@@ -507,38 +507,6 @@ cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused)
|
||||
.type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
|
||||
CAP_MIDR_RANGE_LIST(midr_list)
|
||||
|
||||
/*
|
||||
* Generic helper for handling capabilties with multiple (match,enable) pairs
|
||||
* of call backs, sharing the same capability bit.
|
||||
* Iterate over each entry to see if at least one matches.
|
||||
*/
|
||||
static bool __maybe_unused
|
||||
multi_entry_cap_matches(const struct arm64_cpu_capabilities *entry, int scope)
|
||||
{
|
||||
const struct arm64_cpu_capabilities *caps;
|
||||
|
||||
for (caps = entry->match_list; caps->matches; caps++)
|
||||
if (caps->matches(caps, scope))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Take appropriate action for all matching entries in the shared capability
|
||||
* entry.
|
||||
*/
|
||||
static void __maybe_unused
|
||||
multi_entry_cap_cpu_enable(const struct arm64_cpu_capabilities *entry)
|
||||
{
|
||||
const struct arm64_cpu_capabilities *caps;
|
||||
|
||||
for (caps = entry->match_list; caps->matches; caps++)
|
||||
if (caps->matches(caps, SCOPE_LOCAL_CPU) &&
|
||||
caps->cpu_enable)
|
||||
caps->cpu_enable(caps);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
|
||||
|
||||
/*
|
||||
@@ -700,7 +668,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
|
||||
{
|
||||
.desc = "Qualcomm Technologies Falkor/Kryo erratum 1003",
|
||||
.capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003,
|
||||
.matches = multi_entry_cap_matches,
|
||||
.matches = cpucap_multi_entry_cap_matches,
|
||||
.match_list = qcom_erratum_1003_list,
|
||||
},
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user