arm64: cpufeature: __this_cpu_has_cap() shouldn't stop early

From: James Morse <james.morse@arm.com>

commit edf298cfce upstream.

this_cpu_has_cap() tests caps->desc not caps->matches, so it stops
walking the list when it finds a 'silent' feature, instead of
walking to the end of the list.

Prior to v4.6's 644c2ae198 ("arm64: cpufeature: Test 'matches' pointer
to find the end of the list") we always tested desc to find the end of
a capability list. This was changed for dubious things like PAN_NOT_UAO.
v4.7's e3661b128e ("arm64: Allow a capability to be checked on
single CPU") added this_cpu_has_cap() using the old desc style test.

CC: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com> [v4.9 backport]
Tested-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Mark Rutland
2018-04-12 12:11:07 +01:00
committed by Greg Kroah-Hartman
parent 4504c5ccef
commit 93f339ef41

View File

@@ -1024,9 +1024,8 @@ static bool __this_cpu_has_cap(const struct arm64_cpu_capabilities *cap_array,
if (WARN_ON(preemptible()))
return false;
for (caps = cap_array; caps->desc; caps++)
for (caps = cap_array; caps->matches; caps++)
if (caps->capability == cap &&
caps->matches &&
caps->matches(caps, SCOPE_LOCAL_CPU))
return true;
return false;