arm64: Use register field helper in kaslr_requires_kpti()

Rather than open-code the extraction of the E0PD field from the MMFR2
register, we can use the cpuid_feature_extract_unsigned_field() helper
instead.

Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
Will Deacon 2020-01-15 14:06:37 +00:00
parent ebac96ede6
commit a569f5f372

View File

@ -980,7 +980,6 @@ has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope)
*/
bool kaslr_requires_kpti(void)
{
u64 ftr;
if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
return false;
@ -989,8 +988,9 @@ bool kaslr_requires_kpti(void)
* where available.
*/
if (IS_ENABLED(CONFIG_ARM64_E0PD)) {
ftr = read_sysreg_s(SYS_ID_AA64MMFR2_EL1);
if ((ftr >> ID_AA64MMFR2_E0PD_SHIFT) & 0xf)
u64 mmfr2 = read_sysreg_s(SYS_ID_AA64MMFR2_EL1);
if (cpuid_feature_extract_unsigned_field(mmfr2,
ID_AA64MMFR2_E0PD_SHIFT))
return false;
}