From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751550AbcBAIFI (ORCPT ); Mon, 1 Feb 2016 03:05:08 -0500 Received: from terminus.zytor.com ([198.137.202.10]:54825 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751379AbcBAIFE (ORCPT ); Mon, 1 Feb 2016 03:05:04 -0500 Date: Mon, 1 Feb 2016 00:03:59 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: luto@kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, dvlasenk@redhat.com, mingo@kernel.org, luto@amacapital.net, peterz@infradead.org, bp@suse.de, tglx@linutronix.de, linux-kernel@vger.kernel.org, brgerst@gmail.com, bp@alien8.de Reply-To: dvlasenk@redhat.com, mingo@kernel.org, hpa@zytor.com, luto@kernel.org, torvalds@linux-foundation.org, brgerst@gmail.com, bp@alien8.de, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, bp@suse.de, luto@amacapital.net In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/entry/64: Fix fast-path syscall return register state Git-Commit-ID: eb2a54c3271cb6443ae93ec44a91687b60c559a3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: eb2a54c3271cb6443ae93ec44a91687b60c559a3 Gitweb: http://git.kernel.org/tip/eb2a54c3271cb6443ae93ec44a91687b60c559a3 Author: Andy Lutomirski AuthorDate: Sun, 31 Jan 2016 09:33:27 -0800 Committer: Ingo Molnar 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 Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner 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 --- 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