Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755819AbdCWTjA convert rfc822-to-8bit (ORCPT ); Thu, 23 Mar 2017 15:39:00 -0400 Received: from terminus.zytor.com ([65.50.211.136]:36519 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754139AbdCWTi5 (ORCPT ); Thu, 23 Mar 2017 15:38:57 -0400 From: "H. Peter Anvin" Message-Id: <201703231915.v2NJF848011670@mail.zytor.com> Date: Thu, 23 Mar 2017 12:14:56 -0700 User-Agent: K-9 Mail for Android In-Reply-To: References: <20170311000501.46607-1-thgarnie@google.com> <20170311000501.46607-2-thgarnie@google.com> <20170311094200.GA27700@gmail.com> <733ed189-6c01-2975-a81a-6fbfe4b7b593@zytor.com> <2d9aad2a-a677-40d2-c179-379fb6e9f194@zytor.com> <7389c6e7-87dc-ea0d-5b2a-7925b8c8d33e@zytor.com> <8fa1a789-231f-dc2c-4a43-6406194259f9@zytor.com> <60718a28-1f67-3612-49b0-84ac685e1eba@zytor.com> <679d163f-2927-ed56-71dc-976fcf5e213f@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH v3 2/4] x86/syscalls: Specific usage of verify_pre_usermode_state To: Thomas Garnier CC: Andy Lutomirski , Ingo Molnar , Martin Schwidefsky , Heiko Carstens , David Howells , Arnd Bergmann , Al Viro , Dave Hansen , =?ISO-8859-1?Q?Ren=E9_Nyffenegger?= , Andrew Morton , Kees Cook , "Paul E . McKenney" , Andy Lutomirski , Ard Biesheuvel , Nicolas Pitre , Petr Mladek , Sebastian Andrzej Siewior , Sergey Senozhatsky , Helge Deller , Rik van Riel , John Stultz , Thomas Gleixner , Oleg Nesterov , Stephen Smalley , Pavel Tikhomirov , Frederic@zytor.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3419 Lines: 65 Weisbecker ,Stanislav Kinsburskiy ,Ingo Molnar ,Paolo Bonzini ,Dmitry Safonov ,Borislav Petkov ,Josh Poimboeuf ,Brian Gerst ,Jan Beulich ,Christian Borntraeger ,Fenghua Yu ,He Chen ,Russell King ,Vladimir Murzin ,Will Deacon ,Catalin Marinas ,Mark Rutland ,James Morse ,"David A . Long" ,Pratyush Anand ,Laura Abbott ,Andre Przywara ,Chris Metcalf ,linux-s390 ,LKML ,Linux API ,the arch/x86 maintainers ,"linux-arm-kernel@lists.infradead.org" ,Kernel Hardening From: hpa@zytor.com Message-ID: On March 22, 2017 2:11:12 PM PDT, Thomas Garnier wrote: >On Wed, Mar 22, 2017 at 1:49 PM, H. Peter Anvin wrote: >> On 03/22/17 13:41, Thomas Garnier wrote: >>>>> with the change below for additional feedback. >>>> >>>> Can you specify what that means? >>> >>> If I set inline by default, the compiler chose not to inline it on >>> x86. If I force inline the size impact was actually bigger (without >>> the architecture specific code). >>> >> >> That's utterly bizarre. Something strange is going on there. I >suspect >> the right thing to do is to out-of-line the error case only, but even >> that seems strange. It should be something like four instructions >inline. >> > >The compiler seemed to often inline other functions called by the >syscall handlers. I assume the growth was due to changes in code >optimization because the function is much larger at the end. > >>>> >>>> On x86, where there is only one caller of this, it really seems >like it >>>> ought to reduce the overhead to almost zero (since it most likely >is >>>> hidden in the pipeline.) >>>> >>>> I would like to suggest defining it inline if >>>> CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE is set; I really >don't >>>> care about an architecture which doesn't have it. >>> >>> But if there is only one caller, does the compiler is not suppose to >>> inline the function based on options? >> >> If it is marked static in the same file, yes, but you have it in a >> different file from what I can tell. > >If we do global optimization, it should. Having it as a static inline >make it easier on all types of builds. > >> >>> The assembly will call it too, so I would need an inline and a >>> non-inline based on the caller. >> >> Where? I don't see that anywhere, at least for x86. > >After the latest changes on x86, yes. On arm/arm64, we call it with >the CHECK_DATA_CORRUPTION config. > >> >> -hpa >> If we do global optimization, yes, but global optimization (generally called link-time optimization, LTO, on Linux) is very much the exception and not the rule for the Linux kernel at this time. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.