From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755508AbdKBKub (ORCPT ); Thu, 2 Nov 2017 06:50:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:33322 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbdKBKu3 (ORCPT ); Thu, 2 Nov 2017 06:50:29 -0400 Date: Thu, 2 Nov 2017 11:50:18 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: X86 ML , "linux-kernel@vger.kernel.org" , Brian Gerst , Dave Hansen , Linus Torvalds Subject: Re: [PATCH v2 02/20] x86/asm/64: Split the iret-to-user and iret-to-kernel paths Message-ID: <20171102105018.gdpjhixuf2f5v5e5@pd.tnic> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 02, 2017 at 12:58:59AM -0700, Andy Lutomirski wrote: > These code paths will diverge soon. > > Signed-off-by: Andy Lutomirski > --- > arch/x86/entry/entry_64.S | 34 +++++++++++++++++++++++++--------- > arch/x86/entry/entry_64_compat.S | 2 +- > arch/x86/kernel/head_64.S | 2 +- > 3 files changed, 27 insertions(+), 11 deletions(-) > > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > index afe1f403fa0e..07fe816f0d28 100644 > --- a/arch/x86/entry/entry_64.S > +++ b/arch/x86/entry/entry_64.S > @@ -321,7 +321,7 @@ syscall_return_via_sysret: > > opportunistic_sysret_failed: > SWAPGS > - jmp restore_regs_and_iret > + jmp restore_regs_and_return_to_usermode > END(entry_SYSCALL_64) > > ENTRY(stub_ptregs_64) > @@ -423,7 +423,7 @@ ENTRY(ret_from_fork) > call syscall_return_slowpath /* returns with IRQs disabled */ > TRACE_IRQS_ON /* user mode is traced as IRQS on */ > SWAPGS > - jmp restore_regs_and_iret > + jmp restore_regs_and_return_to_usermode > > 1: > /* kernel thread */ > @@ -612,7 +612,20 @@ GLOBAL(retint_user) > call prepare_exit_to_usermode > TRACE_IRQS_IRETQ > SWAPGS > - jmp restore_regs_and_iret > + > +GLOBAL(restore_regs_and_return_to_usermode) > +#ifdef CONFIG_DEBUG_ENTRY > + /* Assert that pt_regs indicates user mode. */ > + testl $3, CS(%rsp) > + jnz 1f > + ud2 > +1: > +#endif Here's me arguing in v2: If these paths are slow and adding a TEST and a Jcc would give us the additional sanity-checking, then I don't see any downside to it. -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --