Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753573AbbBYAjU (ORCPT ); Tue, 24 Feb 2015 19:39:20 -0500 Received: from mail-la0-f54.google.com ([209.85.215.54]:46070 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995AbbBYAjS (ORCPT ); Tue, 24 Feb 2015 19:39:18 -0500 MIME-Version: 1.0 In-Reply-To: <1424824222-10856-1-git-send-email-dvlasenk@redhat.com> References: <1424824222-10856-1-git-send-email-dvlasenk@redhat.com> From: Andy Lutomirski Date: Tue, 24 Feb 2015 16:38:56 -0800 Message-ID: Subject: Re: [PATCH 2/7 v2] x86: entry.S: simplify optimistic SYSRET To: Denys Vlasenko Cc: Linus Torvalds , Steven Rostedt , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , X86 ML , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2536 Lines: 74 On Tue, Feb 24, 2015 at 4:30 PM, Denys Vlasenko wrote: > Avoid redundant load of %r11 (it is already loaded a few instructions before). > Do not needlessly increment %rsp - we are going to return to userspace > via SYSRET, this insn doesn't use stack for return. Applied. > > Changes since v1: added a comment > > Signed-off-by: Denys Vlasenko > CC: Linus Torvalds > CC: Steven Rostedt > CC: Ingo Molnar > CC: Borislav Petkov > CC: "H. Peter Anvin" > CC: Andy Lutomirski > CC: Oleg Nesterov > CC: Frederic Weisbecker > CC: Alexei Starovoitov > CC: Will Drewry > CC: Kees Cook > CC: x86@kernel.org > CC: linux-kernel@vger.kernel.org > --- > arch/x86/include/asm/calling.h | 3 +++ > arch/x86/kernel/entry_64.S | 6 +++--- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h > index 3374235..f1a962f 100644 > --- a/arch/x86/include/asm/calling.h > +++ b/arch/x86/include/asm/calling.h > @@ -176,6 +176,9 @@ For 32-bit we have the following conventions - kernel is built with > .macro RESTORE_C_REGS_EXCEPT_RCX > RESTORE_C_REGS_HELPER 1,0,1,1,1 > .endm > + .macro RESTORE_C_REGS_EXCEPT_R11 > + RESTORE_C_REGS_HELPER 1,1,0,1,1 > + .endm > .macro RESTORE_RSI_RDI > RESTORE_C_REGS_HELPER 0,0,0,0,0 > .endm > diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S > index 4b3f3c1..4f113c8 100644 > --- a/arch/x86/kernel/entry_64.S > +++ b/arch/x86/kernel/entry_64.S > @@ -756,9 +756,9 @@ retint_swapgs: /* return to user-space */ > */ > irq_return_via_sysret: > CFI_REMEMBER_STATE > - RESTORE_C_REGS > - REMOVE_PT_GPREGS_FROM_STACK 8 > - movq (RSP-RIP)(%rsp),%rsp > + /* r11 is already restored (see code above) */ > + RESTORE_C_REGS_EXCEPT_R11 > + movq RSP(%rsp),%rsp > USERGS_SYSRET64 > CFI_RESTORE_STATE > > -- > 1.8.1.4 > -- Andy Lutomirski AMA Capital Management, LLC -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/