Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964860AbbGCOhy (ORCPT ); Fri, 3 Jul 2015 10:37:54 -0400 Received: from mail-qk0-f171.google.com ([209.85.220.171]:32994 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964840AbbGCOhs (ORCPT ); Fri, 3 Jul 2015 10:37:48 -0400 MIME-Version: 1.0 In-Reply-To: References: <1a5858d079609a3e293123c9ee45de433a4e9c44.1435602481.git.luto@kernel.org> <20150702120932.GH4001@pd.tnic> From: Denys Vlasenko Date: Fri, 3 Jul 2015 16:37:28 +0200 Message-ID: Subject: Re: [PATCH v4 14/17] x86/asm/entry/64: Migrate error and interrupt exit work to C To: Andy Lutomirski Cc: Borislav Petkov , Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Rik van Riel , Oleg Nesterov , Kees Cook , Brian Gerst , Paul McKenney 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: 2652 Lines: 76 On Thu, Jul 2, 2015 at 6:09 PM, Andy Lutomirski wrote: > On Thu, Jul 2, 2015 at 5:09 AM, Borislav Petkov wrote: >> On Mon, Jun 29, 2015 at 12:33:46PM -0700, Andy Lutomirski wrote: >>> Signed-off-by: Andy Lutomirski >>> --- >>> arch/x86/entry/entry_64.S | 63 +++++++++++----------------------------- >>> arch/x86/entry/entry_64_compat.S | 5 ++++ >>> 2 files changed, 22 insertions(+), 46 deletions(-) >>> >>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S >>> index ce2c9049abef..08a37ec049f0 100644 >>> --- a/arch/x86/entry/entry_64.S >>> +++ b/arch/x86/entry/entry_64.S >>> @@ -508,7 +508,16 @@ END(irq_entries_start) >>> >>> testb $3, CS(%rsp) >>> jz 1f >>> + >>> + /* >>> + * IRQ from user mode. Switch to kernel gsbase and inform context >>> + * tracking that we're in kernel mode. >>> + */ >>> SWAPGS >>> +#ifdef CONFIG_CONTEXT_TRACKING >>> + call enter_from_user_mode >>> +#endif >> >> I think you can make this much cleaner by getting rid of the ifdeffery >> and pushing it into the enter_from_user_mode() function: >> >> __visible void enter_from_user_mode(void) >> { >> #ifdef CONFIG_CONTEXT_TRACKING >> >> ... >> >> #endif >> } >> >> The disadvantage of all that cleanliness is that we get one dumb >> >> call enter_from_user_mode >> >> there to this abomination: >> >> ffffffff810014f0 : >> ffffffff810014f0: e8 db 97 67 00 callq ffffffff8167acd0 <__fentry__> >> ffffffff810014f5: 55 push %rbp >> ffffffff810014f6: 48 89 e5 mov %rsp,%rbp >> ffffffff810014f9: 5d pop %rbp >> ffffffff810014fa: c3 retq >> ffffffff810014fb: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) >> >> which sux. >> >> We sure could use LTO here. >> > > You mean link-time asm optimizations? Turning off frame pointers in > leaf functions as long as rbp is still preserved might not be so > terrible either. > > I'm torn on this one. In principle, you're right, or we could have a > macro CALL_ENTER_FROM_USER_MODE that does nothing if context tracking > is off. OTOH, that's also kind of messy. busybox has IF() macros: IF_CONTEXT_TRACKING(call enter_from_user_mode) Unlike #if, this needs one line, not three. -- 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/