Patch "[Variant 1/Spectre-v1] arm64: Implement array_index_mask_nospec()" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
[Variant 1/Spectre-v1] arm64: Implement array_index_mask_nospec()
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm64-implement-array_index_mask_nospec.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Wed Feb 14 14:44:54 CET 2018
From: Robin Murphy <[email protected]>
Date: Mon, 5 Feb 2018 15:34:17 +0000
Subject: [Variant 1/Spectre-v1] arm64: Implement array_index_mask_nospec()
From: Robin Murphy <[email protected]>
Commit 022620eed3d0 upstream.
Provide an optimised, assembly implementation of array_index_mask_nospec() for arm64 so that the compiler is not in a position to transform the code in ways which affect its ability to inhibit speculation (e.g. by introducing conditional branches).
This is similar to the sequence used by x86, modulo architectural differences in the carry/borrow flags.
--- arch/arm64/include/asm/barrier.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/arm64/include/asm/barrier.h +21 -0
@@ -40,6 +40,27 @@#define dma_rmb () dmb(oshld)#define dma_wmb () dmb(oshst) +/* +* Generate a mask for array_index__nospec() that is ~0UL when 0 <= idx < sz +* and 0 otherwise. +*/ +#define array_index_mask_nospec array_index_mask_nospec +static inline unsigned long array_index_mask_nospec (unsigned long idx, +unsigned long sz) +{ +unsigned long mask; + + asmvolatile ( +" cmp %1, %2\n" +" sbc %0, xzr, xzr\n" + :"=r" (mask) + :"r" (idx),"Ir" (sz) + :"cc" ); + +csdb (); +return mask; +} +#define __smp_mb () dmb(ish)#define __smp_rmb () dmb(ishld)#define __smp_wmb () dmb(ishst)
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/arm64-make-user_ds-an-inclusive-limit.patch queue-4.14/arm64-uaccess-don-t-bother-eliding-access_ok-checks-in-__-get-put-_user.patch queue-4.14/arm-arm64-smccc-make-function-identifiers-an-unsigned-quantity.patch queue-4.14/firmware-psci-expose-psci-conduit.patch queue-4.14/firmware-psci-expose-smccc-version-through-psci_ops.patch queue-4.14/arm64-use-pointer-masking-to-limit-uaccess-speculation.patch queue-4.14/arm-arm64-smccc-implement-smccc-v1.1-inline-primitive.patch queue-4.14/arm64-implement-array_index_mask_nospec.patch