Re: clang asm-goto support (Was Re: [PATCH v2] x86/retpoline: Add clang support)

From: Linus Torvalds
Date: Wed Feb 14 2018 - 12:40:00 EST


On Wed, Feb 14, 2018 at 2:34 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> So it's far more than just tracepoints. We use it all over the kernel to
> do runtime branch patching.

Side note: I have a patch to the user access code to do "asm goto" for
the exception handling too.

In fact, the infrastructure is there already, but because we supported
older gcc versions that didn't have asm goto, I never applied the
final patch to actually make use of it.

See "unsafe_put_user()", which currently does

if (unlikely(__pu_err)) goto err_label;

rather than just have the exception table itself directly reference
"err_label", and not needing any code at all in the regular path.

I suspect there are other things like that, where the lack of "asm
goto" means that it's not worth the pain of having two code paths.
Once we update to a newer gcc requirement, those suddenly will also
very naturally use asm goto.

The other asm use that the clang people might want to look at is the
"condition codes as return value" one. That one we currently handle
with CC_SET/CC_OUT, and it's somewhat more amenable to those kinds of
games, so missing it isn't as nasty. But it *is* a useful "modern"
extension of gcc asms.

Maybe clang already supports cflags output, I haven't checked.

Linus