mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
ARM: spectre-v1: add array_index_mask_nospec() implementation
Commit 1d4238c56f upstream.
Add an implementation of the array_index_mask_nospec() function for
mitigating Spectre variant 1 throughout the kernel.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Boot-tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: David A. Long <dave.long@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
abdeed7e61
commit
8a4ae2876f
@@ -75,6 +75,25 @@ extern void arm_heavy_mb(void);
|
||||
#define __smp_rmb() __smp_mb()
|
||||
#define __smp_wmb() dmb(ishst)
|
||||
|
||||
#ifdef CONFIG_CPU_SPECTRE
|
||||
static inline unsigned long array_index_mask_nospec(unsigned long idx,
|
||||
unsigned long sz)
|
||||
{
|
||||
unsigned long mask;
|
||||
|
||||
asm volatile(
|
||||
"cmp %1, %2\n"
|
||||
" sbc %0, %1, %1\n"
|
||||
CSDB
|
||||
: "=r" (mask)
|
||||
: "r" (idx), "Ir" (sz)
|
||||
: "cc");
|
||||
|
||||
return mask;
|
||||
}
|
||||
#define array_index_mask_nospec array_index_mask_nospec
|
||||
#endif
|
||||
|
||||
#include <asm-generic/barrier.h>
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
|
||||
Reference in New Issue
Block a user