public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Uros Bizjak <ubizjak@gmail.com>,
	 Jakub Jelinek <jakub@redhat.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 13:46:52 -0800	[thread overview]
Message-ID: <ZcadTKwaSvvywNA9@google.com> (raw)
In-Reply-To: <CAHk-=wgBt9SsYjyHWn1ZH5V0Q7P6thqv_urVCTYqyWNUWSJ6_g@mail.gmail.com>

On Fri, Feb 09, 2024, Linus Torvalds wrote:
> Sean? Does this work for the case you noticed?

Yep.  You can quite literally see the effect of the asm("").  A "good" sequence
directly propagates the result from the VMREAD's destination register to its
final destination

  <+1756>:  mov    $0x280e,%r13d
  <+1762>:  vmread %r13,%r13
  <+1766>:  jbe    0x209fa <sync_vmcs02_to_vmcs12+1834>
  <+1768>:  mov    %r13,0xe8(%rbx)

whereas the "bad" sequence bounces through a different register.

  <+1780>:  mov    $0x2810,%eax
  <+1785>:  vmread %rax,%rax
  <+1788>:  jbe    0x209e4 <sync_vmcs02_to_vmcs12+1812>
  <+1790>:  mov    %rax,%r12
  <+1793>:  mov    %r12,0xf0(%rbx)

> 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 ...

Yeah, I'm in the same boat.

  reply	other threads:[~2024-02-09 21:46 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
2024-02-09 21:46               ` Sean Christopherson [this message]
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=ZcadTKwaSvvywNA9@google.com \
    --to=seanjc@google.com \
    --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=torvalds@linux-foundation.org \
    --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