Re: [PATCH] x86: work around clang IAS bug referencing __force_order

From: Paul E. McKenney
Date: Thu Aug 13 2020 - 13:37:04 EST


On Thu, Aug 13, 2020 at 07:28:57PM +0200, Thomas Gleixner wrote:
> Nick Desaulniers <ndesaulniers@xxxxxxxxxx> writes:
> > On Thu, Aug 6, 2020 at 3:11 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> >> > + *
> >> > + * Clang sometimes fails to kill the reference to the dummy variable, so
> >> > + * provide an actual copy.
> >>
> >> Can that compiler be fixed instead?
> >
> > I don't think so. The logic in the compiler whether to emit an
>
> Forget that I asked. Heat induced brain damaged.
>
> > I'd much rather remove all of __force_order.
>
> Right.
>
> > Not sure about the comment in arch/x86/include/asm/special_insns.h
> > either; smells fishy like a bug with a compiler from a long time ago.
> > It looks like it was introduced in:
> > commit d3ca901f94b32 ("x86: unify paravirt parts of system.h")
> > Lore has this thread:
> > https://lore.kernel.org/lkml/4755A809.4050305@xxxxxxxxxxxx/
> > Patch 4: https://lore.kernel.org/lkml/11967844071346-git-send-email-gcosta@xxxxxxxxxx/
> > It seems like there was a discussion about %cr8, but no one asked
> > "what's going on here with __force_order, is that right?"
>
> Correct and the changelog is uselss in this regard.
>
> > Quick boot test of the below works for me, though I should probably
> > test hosting a virtualized guest since d3ca901f94b32 refers to
> > paravirt. Thoughts?
>
> Let me ask (hopefully) useful questions this time:
>
> Is a compiler allowed to reorder two 'asm volatile()'?
>
> Are there compilers (gcc >= 4.9 or other supported ones) which do that?

I would hope that the answer to both of these questions is "no"!

But I freely confess that I have been disappointed before on this sort
of thing. :-/

Thanx, Paul