From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Cc: npiggin@gmail.com, msuchanek@suse.de, linux-kernel@vger.kernel.org
Subject: [PATCH 6/6] powerpc/64: Use barrier_nospec in syscall entry
Date: Tue, 24 Apr 2018 14:15:59 +1000 [thread overview]
Message-ID: <20180424041559.32410-6-mpe@ellerman.id.au> (raw)
In-Reply-To: <20180424041559.32410-1-mpe@ellerman.id.au>
Our syscall entry is done in assembly so patch in an explicit
barrier_nospec.
Based on a patch by Michal Suchanek.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
mpe: Move the barrier to immediately prior to the vulnerable load,
and add a comment trying to explain why. Drop the barrier from
syscall_dotrace, because that syscall number comes from the
kernel.
---
arch/powerpc/kernel/entry_64.S | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 51695608c68b..de30f9a34c0c 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -36,6 +36,7 @@
#include <asm/context_tracking.h>
#include <asm/tm.h>
#include <asm/ppc-opcode.h>
+#include <asm/barrier.h>
#include <asm/export.h>
#ifdef CONFIG_PPC_BOOK3S
#include <asm/exception-64s.h>
@@ -178,6 +179,15 @@ system_call: /* label this so stack traces look sane */
clrldi r8,r8,32
15:
slwi r0,r0,4
+
+ barrier_nospec_asm
+ /*
+ * Prevent the load of the handler below (based on the user-passed
+ * system call number) being speculatively executed until the test
+ * against NR_syscalls and branch to .Lsyscall_enosys above has
+ * committed.
+ */
+
ldx r12,r11,r0 /* Fetch system call handler [ptr] */
mtctr r12
bctrl /* Call handler */
--
2.14.1
next prev parent reply other threads:[~2018-04-24 4:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 4:15 [PATCH 1/6] powerpc/64s: Add barrier_nospec Michael Ellerman
2018-04-24 4:15 ` [PATCH 2/6] powerpc/64s: Add support for ori barrier_nospec patching Michael Ellerman
2018-04-26 16:10 ` Michal Suchánek
2018-05-01 12:25 ` Michael Ellerman
2018-04-24 4:15 ` [PATCH 3/6] powerpc/64s: Patch barrier_nospec in modules Michael Ellerman
2018-05-03 13:15 ` Michal Suchánek
2018-04-24 4:15 ` [PATCH 4/6] powerpc/64s: Enable barrier_nospec based on firmware settings Michael Ellerman
2018-04-26 16:02 ` Michal Suchánek
2018-05-01 11:11 ` Michael Ellerman
2018-05-02 11:41 ` Michal Suchánek
2018-05-04 0:58 ` Michael Ellerman
2018-04-24 4:15 ` [PATCH 5/6] powerpc: Use barrier_nospec in copy_from_user() Michael Ellerman
2018-04-24 4:15 ` Michael Ellerman [this message]
2018-04-24 5:44 ` [PATCH 1/6] powerpc/64s: Add barrier_nospec Nicholas Piggin
2018-05-28 13:19 ` [PATCH] powerpc/64s: Enhance the information in cpu_show_spectre_v1() Michal Suchanek
2018-05-29 14:03 ` kbuild test robot
2018-05-29 14:13 ` Christophe LEROY
2018-05-29 14:46 ` Michal Suchánek
2018-05-29 15:24 ` Christophe Leroy
2018-05-29 16:15 ` Joe Perches
2018-06-04 14:11 ` Michael Ellerman
2018-06-04 14:10 ` [1/6] powerpc/64s: Add barrier_nospec Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180424041559.32410-6-mpe@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=msuchanek@suse.de \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).