From: Andy Lutomirski <luto@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Brian Gerst <brgerst@gmail.com>,
Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>
Subject: [PATCH 2/3] x86/entry/64: Fix fast-path syscall return register state
Date: Sun, 31 Jan 2016 09:33:27 -0800 [thread overview]
Message-ID: <a85f8360c397e48186a9bc3e565ad74307a7b011.1454261517.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1454261517.git.luto@kernel.org>
In-Reply-To: <cover.1454261517.git.luto@kernel.org>
I was fishing RIP (i.e. RCX) out of pt_regs->cx and RFLAGS (i.e. R11)
out of pt_regs->r11. While it usually worked (pt_regs started out
with cx == ip and r11 == flags), it was very fragile. In particular,
it broke iopl because iopl forgot to mark itself as using ptregs.
Undo that part of the syscall rework. There was no compelling
reason to do it this way. While I'm at it, load RCX and R11 before
the other regs to be a little friendlier to the CPU, as they will be
the first of the reloaded registers to be used.
Fixes: 1e423bff959e x86/entry/64: ("Migrate the 64-bit syscall slow path to C")
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/entry_64.S | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 9f7bb808035e..70eadb0ea5fa 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -212,7 +212,9 @@ entry_SYSCALL_64_fastpath:
LOCKDEP_SYS_EXIT
TRACE_IRQS_ON /* user mode is traced as IRQs on */
- RESTORE_C_REGS
+ movq RIP(%rsp), %rcx
+ movq EFLAGS(%rsp), %r11
+ RESTORE_C_REGS_EXCEPT_RCX_R11
movq RSP(%rsp), %rsp
USERGS_SYSRET64
--
2.5.0
next prev parent reply other threads:[~2016-01-31 17:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-31 17:33 [PATCH 0/3] x86/entry/64: Fixes for syscall rework Andy Lutomirski
2016-01-31 17:33 ` [PATCH 1/3] x86/entry/64: Fix an IRQ state error on ptregs-using syscalls Andy Lutomirski
2016-02-01 8:03 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2016-01-31 17:33 ` Andy Lutomirski [this message]
2016-02-01 8:03 ` [tip:x86/asm] x86/entry/64: Fix fast-path syscall return register state tip-bot for Andy Lutomirski
2016-01-31 17:33 ` [PATCH 3/3] x86/syscalls/64: Mark sys_iopl as using ptregs Andy Lutomirski
2016-02-01 8:04 ` [tip:x86/asm] x86/syscalls/64: Mark sys_iopl() " tip-bot for Andy Lutomirski
2016-01-31 21:46 ` [PATCH 0/3] x86/entry/64: Fixes for syscall rework Borislav Petkov
2016-02-01 7:58 ` Ingo Molnar
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=a85f8360c397e48186a9bc3e565ad74307a7b011.1454261517.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®