[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-eb2a54c3271cb6443ae93ec44a91687b60c559a3@git.kernel.org>
Date: Mon, 1 Feb 2016 00:03:59 -0800
From: tip-bot for Andy Lutomirski <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: luto@...nel.org, torvalds@...ux-foundation.org, hpa@...or.com,
dvlasenk@...hat.com, mingo@...nel.org, luto@...capital.net,
peterz@...radead.org, bp@...e.de, tglx@...utronix.de,
linux-kernel@...r.kernel.org, brgerst@...il.com, bp@...en8.de
Subject: [tip:x86/asm] x86/entry/64:
Fix fast-path syscall return register state
Commit-ID: eb2a54c3271cb6443ae93ec44a91687b60c559a3
Gitweb: http://git.kernel.org/tip/eb2a54c3271cb6443ae93ec44a91687b60c559a3
Author: Andy Lutomirski <luto@...nel.org>
AuthorDate: Sun, 31 Jan 2016 09:33:27 -0800
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Mon, 1 Feb 2016 08:53:25 +0100
x86/entry/64: Fix fast-path syscall return register state
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 sys_iopl() because sys_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.
Reported-and-tested-by: Borislav Petkov <bp@...e.de>
Signed-off-by: Andy Lutomirski <luto@...nel.org>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Denys Vlasenko <dvlasenk@...hat.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Fixes: 1e423bff959e x86/entry/64: ("Migrate the 64-bit syscall slow path to C")
Link: http://lkml.kernel.org/r/a85f8360c397e48186a9bc3e565ad74307a7b011.1454261517.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@...nel.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 9f7bb80..70eadb0 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
Powered by blists - more mailing lists