[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200917183923.b5b2btxt26u73fgx@treble>
Date: Thu, 17 Sep 2020 13:39:23 -0500
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Marco Elver <elver@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Borislav Petkov <bp@...en8.de>,
Rong Chen <rong.a.chen@...el.com>,
kernel test robot <lkp@...el.com>,
"Li, Philip" <philip.li@...el.com>, x86-ml <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Kees Cook <keescook@...omium.org>,
Masahiro Yamada <masahiroy@...nel.org>,
kasan-dev <kasan-dev@...glegroups.com>,
Daniel Kiss <daniel.kiss@....com>, momchil.velikov@....com
Subject: Re: [tip:x86/seves] BUILD SUCCESS WITH WARNING
e6eb15c9ba3165698488ae5c34920eea20eaa38e
On Wed, Sep 16, 2020 at 11:22:02AM -0700, Nick Desaulniers wrote:
> I looked into this a bit, and IIRC, the issue was that compiler
> generated functions aren't very good about keeping track of whether
> they should or should not emit framepointer setup/teardown
> prolog/epilogs. In LLVM's IR, -fno-omit-frame-pointer gets attached
> to every function as a function level attribute.
> https://godbolt.org/z/fcn9c6 ("frame-pointer"="all").
>
> There were some recent LLVM patches for BTI (arm64) that made some BTI
> related command line flags module level attributes, which I thought
> was interesting; I was wondering last night if -fno-omit-frame-pointer
> and maybe even the level of stack protector should be? I guess LTO
> would complicate things; not sure it would be good to merge modules
> with different attributes; I'm not sure how that's handled today in
> LLVM.
>
> Basically, when the compiler is synthesizing a new function
> definition, it should check whether a frame pointer should be emitted
> or not. We could do that today by maybe scanning all other function
> definitions for the presence of "frame-pointer"="all" fn attr,
> breaking early if we find one, and emitting the frame pointer setup in
> that case. Though I guess it's "frame-pointer"="none" otherwise, so
> maybe checking any other fn def would be fine; I don't see any C fn
> attr's that allow you to keep frame pointers or not. What's tricky is
> that the front end flag was resolved much earlier than where this code
> gets generated, so it would need to look for traces that the flag ever
> existed, which sounds brittle on paper to me.
For code generated by the kernel at runtime, our current (x86) policy is
"always use frame pointers for non-leaf functions".
A lot of this compiler talk is over my head, but if *non-leaf* generated
functions are rare enough then it might be worth considering to just
always use frame pointers for them.
--
Josh
Powered by blists - more mailing lists