]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/powerpc-64-use-barrier_nospec-in-syscall-entry.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / powerpc-64-use-barrier_nospec-in-syscall-entry.patch
1 From foo@baz Mon 29 Apr 2019 11:38:37 AM CEST
2 From: Michael Ellerman <mpe@ellerman.id.au>
3 Date: Mon, 22 Apr 2019 00:20:14 +1000
4 Subject: powerpc/64: Use barrier_nospec in syscall entry
5 To: stable@vger.kernel.org, gregkh@linuxfoundation.org
6 Cc: linuxppc-dev@ozlabs.org, diana.craciun@nxp.com, msuchanek@suse.de, npiggin@gmail.com, christophe.leroy@c-s.fr
7 Message-ID: <20190421142037.21881-30-mpe@ellerman.id.au>
8
9 From: Michael Ellerman <mpe@ellerman.id.au>
10
11 commit 51973a815c6b46d7b23b68d6af371ad1c9d503ca upstream.
12
13 Our syscall entry is done in assembly so patch in an explicit
14 barrier_nospec.
15
16 Based on a patch by Michal Suchanek.
17
18 Signed-off-by: Michal Suchanek <msuchanek@suse.de>
19 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 ---
22 arch/powerpc/kernel/entry_64.S | 10 ++++++++++
23 1 file changed, 10 insertions(+)
24
25 --- a/arch/powerpc/kernel/entry_64.S
26 +++ b/arch/powerpc/kernel/entry_64.S
27 @@ -36,6 +36,7 @@
28 #include <asm/hw_irq.h>
29 #include <asm/context_tracking.h>
30 #include <asm/tm.h>
31 +#include <asm/barrier.h>
32 #ifdef CONFIG_PPC_BOOK3S
33 #include <asm/exception-64s.h>
34 #else
35 @@ -177,6 +178,15 @@ system_call: /* label this so stack tr
36 clrldi r8,r8,32
37 15:
38 slwi r0,r0,4
39 +
40 + barrier_nospec_asm
41 + /*
42 + * Prevent the load of the handler below (based on the user-passed
43 + * system call number) being speculatively executed until the test
44 + * against NR_syscalls and branch to .Lsyscall_enosys above has
45 + * committed.
46 + */
47 +
48 ldx r12,r11,r0 /* Fetch system call handler [ptr] */
49 mtctr r12
50 bctrl /* Call handler */