From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755287AbdKAUff (ORCPT ); Wed, 1 Nov 2017 16:35:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:35618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755182AbdKAUfe (ORCPT ); Wed, 1 Nov 2017 16:35:34 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9534721937 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org X-Google-Smtp-Source: ABhQp+R/VpnWf3hl4X5WAPcMdNz/GZpkU0kMkH9WWTcK0jCBlPsCWm/mxiECjBINBzrlznXJOhS3b5PxHwsPXtuwWdY= MIME-Version: 1.0 In-Reply-To: References: <998a8c2c39546115f93e4c6e2ad7f918626f6145.1509006199.git.luto@kernel.org> From: Andy Lutomirski Date: Wed, 1 Nov 2017 13:35:12 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 07/18] x86/asm/64: Merge the fast and slow SYSRET paths To: Brian Gerst Cc: Andy Lutomirski , X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Dave Hansen , Linus Torvalds Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 1, 2017 at 10:25 AM, Brian Gerst wrote: > On Thu, Oct 26, 2017 at 4:26 AM, Andy Lutomirski wrote: >> They did almost the same thing. Remove a bunch of pointless >> instructions (mostly hidden in macros) and reduce cognitive load by >> merging them. >> >> Signed-off-by: Andy Lutomirski >> --- >> arch/x86/entry/entry_64.S | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S >> index 9dafafa3e0ec..c855ee91a3a5 100644 >> --- a/arch/x86/entry/entry_64.S >> +++ b/arch/x86/entry/entry_64.S >> @@ -220,10 +220,9 @@ entry_SYSCALL_64_fastpath: >> TRACE_IRQS_ON /* user mode is traced as IRQs on */ >> movq RIP(%rsp), %rcx >> movq EFLAGS(%rsp), %r11 >> - RESTORE_C_REGS_EXCEPT_RCX_R11 >> - movq RSP(%rsp), %rsp >> + addq $6*8, %rsp /* skip extra regs -- they were preserved */ >> UNWIND_HINT_EMPTY >> - USERGS_SYSRET64 >> + jmp .Lpop_c_regs_except_rcx_r11_and_sysret >> >> 1: >> /* >> @@ -315,6 +314,7 @@ syscall_return_via_sysret: >> /* rcx and r11 are already restored (see code above) */ >> UNWIND_HINT_EMPTY >> POP_EXTRA_REGS >> +.Lpop_c_regs_except_rcx_r11_and_sysret: >> popq %rsi /* skip r11 */ >> popq %r10 >> popq %r9 > > Wouldn't it be more logical to keep the SYSRET path at the end of the > fast path (reverse of what you are doing here)? That way the fast > path falls through without jumping. Ugh, probably. I think I'll save that for v3, though. I want to keep this moving.