Commit 92b4b561 authored by Mark Rutland's avatar Mark Rutland Committed by Catalin Marinas

arm64: cpufeature: make cpus_have_cap() noinstr-safe

Currently it isn't safe to use cpus_have_cap() from noinstr code as
test_bit() is explicitly instrumented, and were cpus_have_cap() placed
out-of-line, cpus_have_cap() itself could be instrumented.

Make cpus_have_cap() noinstr safe by marking it __always_inline and
using arch_test_bit().

Aside from the prevention of instrumentation, there should be no
functional change as a result of this patch.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Will Deacon <will@kernel.org>
Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20220912162210.3626215-2-mark.rutland@arm.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent b90cb105
...@@ -448,11 +448,11 @@ static __always_inline bool system_capabilities_finalized(void) ...@@ -448,11 +448,11 @@ static __always_inline bool system_capabilities_finalized(void)
* *
* Before the capability is detected, this returns false. * Before the capability is detected, this returns false.
*/ */
static inline bool cpus_have_cap(unsigned int num) static __always_inline bool cpus_have_cap(unsigned int num)
{ {
if (num >= ARM64_NCAPS) if (num >= ARM64_NCAPS)
return false; return false;
return test_bit(num, cpu_hwcaps); return arch_test_bit(num, cpu_hwcaps);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment