[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181129141648.6ef944a9@gandalf.local.home>
Date: Thu, 29 Nov 2018 14:16:48 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andy Lutomirski <luto@...capital.net>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Andrew Lutomirski <luto@...nel.org>,
"the arch/x86 maintainers" <x86@...nel.org>,
Linux List Kernel Mailing <linux-kernel@...r.kernel.org>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, mhiramat@...nel.org,
jbaron@...mai.com, Jiri Kosina <jkosina@...e.cz>,
David.Laight@...lab.com, bp@...en8.de, julia@...com,
jeyu@...nel.org, Peter Anvin <hpa@...or.com>
Subject: Re: [PATCH v2 4/4] x86/static_call: Add inline static call
implementation for x86-64
On Thu, 29 Nov 2018 10:58:40 -0800
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> On Thu, Nov 29, 2018 at 10:47 AM Steven Rostedt <rostedt@...dmis.org> wrote:
> >
> > Note, we do have a bit of control at what is getting called. The patch
> > set requires that the callers are wrapped in macros. We should not
> > allow just any random callers (like from asm).
>
> Actually, I'd argue that asm is often more controlled than C code.
>
> Right now you can do odd things if you really want to, and have the
> compiler generate indirect calls to those wrapper functions.
>
> For example, I can easily imagine a pre-retpoline compiler turning
>
> if (cond)
> fn1(a,b)
> else
> fn2(a,b);
>
> into a function pointer conditional
>
> (cond ? fn1 : fn2)(a,b);
If we are worried about such a construct, wouldn't a compiler barrier
before and after the static_call solve that?
barrier();
static_call(func...);
barrier();
It should also stop tail calls too.
>
> and honestly, the way "static_call()" works now, can you guarantee
> that the call-site doesn't end up doing that, and calling the
> trampoline function for two different static calls from one indirect
> call?
>
> See what I'm talking about? Saying "callers are wrapped in macros"
> doesn't actually protect you from the compiler doing things like that.
>
> In contrast, if the call was wrapped in an inline asm, we'd *know* the
> compiler couldn't turn a "call wrapper(%rip)" into anything else.
But then we need to implement all numbers of parameters.
-- Steve
Powered by blists - more mailing lists