linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Nick Desaulniers <ndesaulniers@google.com>,
	Uros Bizjak <ubizjak@gmail.com>,
	 Jakub Jelinek <jakub@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
	"Andrew Pinski (QUIC)" <quic_apinski@quicinc.com>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	 Peter Zijlstra <peterz@infradead.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH] Kconfig: Explicitly disable asm goto w/ outputs on gcc-11 (and earlier)
Date: Fri, 9 Feb 2024 12:39:31 -0800	[thread overview]
Message-ID: <CAHk-=wgBt9SsYjyHWn1ZH5V0Q7P6thqv_urVCTYqyWNUWSJ6_g@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wgEABCwu7HkJufpWC=K7u_say8k6Tp9eHvAXFa4DNXgzQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2386 bytes --]

On Fri, 9 Feb 2024 at 11:01, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> We should also probably get rid of the existing "asm_volatile_goto()"
> macro name entirely. That name was always pretty horrific, in that it
> didn't even mark the asm as volatile even in the case where it did
> anything.
>
> So the name of that macro made little sense, and the new workaround
> should be only for asm goto with outputs. So I'd suggest jmaking a new
> macro with that name:
>
>    #define asm_goto_output(x...)
>
> and on gcc use that old workaround, and on clang just make it be a
> plain "asm goto".

So here's a suggested patch that does this.

It's largely done with "git grep" and "sed -i", plus some manual
fixups for the (few) cases where we have outputs.

It looks superficially sane to me, and it passed an allmodconfig build
with gcc, but I'm not going to claim that it is really tested.

Sean? Does this work for the case you noticed?

Basically this gets rid of the old "asm_volatile_goto()" entirely as
useless, but replaces it with "asm_goto_outputs()" for the places
where we have outputs.

And then for gcc, it makes those cases

 (a) use "asm volatile goto" to fix the fact that some versions of gcc
will have missed the "volatile"

 (b) adds that extra empty asm as a second barrier after the "real"
asm goto statement

That (b) is very much voodoo programming, but it matches the old magic
barrier thing that Jakub Jelinek suggested for the really *old* gcc
bug wrt plain (non-output) "asm goto". The underlying bug for _that_
was fixed long ago:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670

We removed that for plain "asm goto" workaround a couple of years ago,
so "asm_volatile_goto()" has been a no-op since June 2022, but this
now resurrects that hack for the output case.

I'm not loving it, but Sean seemed to confirm that it fixes the code
generation problem, so ...

Adding Uros to the cc, since he is both involved with gcc and with the
previous asm goto workaround removal, so maybe he has other
suggestions. Uros, see

    https://lore.kernel.org/all/20240208220604.140859-1-seanjc@google.com/

for background.

Also adding Jakub since I'm re-using the hack he suggested for a
different - but similar - case. He may have strong opinions too, and
may object to that particular monkey-see-monkey-do voodoo programming.

                Linus

[-- Attachment #2: patch.diff --]
[-- Type: application/x-patch, Size: 32071 bytes --]

  parent reply	other threads:[~2024-02-09 20:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08 22:06 [PATCH] Kconfig: Explicitly disable asm goto w/ outputs on gcc-11 (and earlier) Sean Christopherson
2024-02-09 17:03 ` Nick Desaulniers
2024-02-09 17:14   ` Andrew Pinski (QUIC)
2024-02-09 17:55     ` Linus Torvalds
2024-02-09 18:43       ` Sean Christopherson
2024-02-09 18:55         ` Nick Desaulniers
2024-02-09 19:01           ` Linus Torvalds
2024-02-09 19:20             ` Nick Desaulniers
2024-02-09 20:39             ` Linus Torvalds [this message]
2024-02-09 21:46               ` Sean Christopherson
2024-02-10 17:21                 ` David Laight
2024-02-11 11:12               ` Uros Bizjak
2024-02-11 19:59                 ` Linus Torvalds
2024-02-11 20:12                   ` Jakub Jelinek
2024-02-13  0:15                   ` Sean Christopherson
2024-02-14 17:20                     ` Sean Christopherson
2024-02-14 18:43                 ` Linus Torvalds
2024-02-15  0:11                   ` Linus Torvalds
2024-02-15  8:39                     ` Jakub Jelinek
2024-02-15 18:25                       ` Linus Torvalds
2024-02-15 19:17                         ` Linus Torvalds
2024-02-15 19:26                           ` Jakub Jelinek
2024-02-09 18:56         ` Linus Torvalds
2024-02-09 19:26           ` Andrew Pinski (QUIC)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHk-=wgBt9SsYjyHWn1ZH5V0Q7P6thqv_urVCTYqyWNUWSJ6_g@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=jakub@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=quic_apinski@quicinc.com \
    --cc=seanjc@google.com \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).