From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967600AbeEYR6I convert rfc822-to-8bit (ORCPT ); Fri, 25 May 2018 13:58:08 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45307 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967386AbeEYR6I (ORCPT ); Fri, 25 May 2018 13:58:08 -0400 Date: Fri, 25 May 2018 10:57:56 -0700 User-Agent: K-9 Mail for Android In-Reply-To: References: <26B017D5-4063-46CB-8768-B0E5E7CD3838@zytor.com> <319FB971-ABB6-4BE7-969B-D87D84853196@zytor.com> <31A5469A-176F-451F-886A-ECD649DDC78C@zytor.com> <12a870df-5f9d-94d1-8318-42cfff1bedab@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [clang] stack protector and f1f029c7bf To: Nick Desaulniers , tstellar@redhat.com CC: Alistair Strachan , Manoj Gupta , Matthias Kaehlcke , Greg Hackmann , sedat.dilek@gmail.com, LKML , Kees Cook From: hpa@zytor.com Message-ID: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On May 25, 2018 10:49:28 AM PDT, Nick Desaulniers wrote: >On Fri, May 25, 2018 at 10:35 AM Tom Stellard >wrote: >> On 05/25/2018 10:31 AM, Nick Desaulniers wrote: >> > On Fri, May 25, 2018 at 9:53 AM wrote: >> >> On May 25, 2018 9:46:42 AM PDT, Nick Desaulniers < >ndesaulniers@google.com> >> > wrote: >> >>> On Fri, May 25, 2018 at 9:33 AM wrote: >> >>>> On May 25, 2018 9:27:40 AM PDT, Nick Desaulniers >> >>> wrote: >> >>> When you say >> >>> >> >>>> It still should be available as as inline, however, but now >"extern >> >>> inline". >> >>> >> >>> Am I understanding correctly that native_save_fl should be >inlined >into >> >>> all >> >>> call sites (modulo the problematic pv_irq_ops.save_fl case)? >Because >> >>> for >> >>> these two assembly implementations, it's not, but maybe there's >> >>> something >> >>> missing in my implementation? >> > >> >> Yes, that's what "extern inline" means. Maybe it needs a must >inline >> > annotation, but that's really messed up. >> > > >> What about doing something like suggested here: >> https://bugs.llvm.org/show_bug.cgi?id=37512#c17 > >> This would keep the definition in C and make it easier for compilers >> to inline. > >The GCC docs for __attribute__((naked)) seem to imply this is a machine >specific constraint (of which x86 is not listed): >https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html > >But let's try with source: >https://godbolt.org/g/aJ4gZB > >Clang errors: >:3:3: error: non-ASM statement in naked function is not >supported > unsigned long flags; > ^ > >Is it valid to use assembly to place the results in %rax and mark the c >function somehow? > >gcc doesn't support this attribute until 4.9 (but we can add a feature >test >for attributes with gcc (unlike builtins)), but warns that: > >warning: ‘naked’ attribute directive ignored [-Wattributes] > >gcc 8.1 and trunk inserts a `ud2` instruction (what?!) (let me see if I >can >repro outside of godbolt, and will file a bug report). No, we found that the paravirt code can do the wrong thing for a C implementation. Nick, could you forward the list of problems so we all have it? -- Sent from my Android device with K-9 Mail. Please excuse my brevity.