On Mon, Jun 06, 2022 at 09:50:46AM -0700, Nick Desaulniers wrote: > On Mon, Jun 6, 2022 at 8:37 AM <gregkh@xxxxxxxxxxxxxxxxxxx> wrote: > > > > > > This is a note to let you know that I've just added the patch titled > > > > Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug > > > > to the 5.4-stable tree which can be found at: > > http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary > > > > The filename of the patch is: > > kconfig-add-option-for-asm-goto-w-tied-outputs-to-workaround-clang-13-bug.patch > > and it can be found in the queue-5.4 subdirectory. > > > > If you, or anyone else, feels it should not be added to the stable tree, > > please let <stable@xxxxxxxxxxxxxxx> know about it. > > > > > > From 1aa0e8b144b6474c4914439d232d15bfe883636b Mon Sep 17 00:00:00 2001 > > From: Sean Christopherson <seanjc@xxxxxxxxxx> > > Date: Wed, 2 Feb 2022 00:49:41 +0000 > > Subject: Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug > > > > From: Sean Christopherson <seanjc@xxxxxxxxxx> > > > > commit 1aa0e8b144b6474c4914439d232d15bfe883636b upstream. > > > > Add a config option to guard (future) usage of asm_volatile_goto() that > > includes "tied outputs", i.e. "+" constraints that specify both an input > > and output parameter. clang-13 has a bug[1] that causes compilation of > > such inline asm to fail, and KVM wants to use a "+m" constraint to > > implement a uaccess form of CMPXCHG[2]. E.g. the test code fails with > > > > <stdin>:1:29: error: invalid operand in inline asm: '.long (${1:l}) - .' > > int foo(int *x) { asm goto (".long (%l[bar]) - .\n": "+m"(*x) ::: bar); return *x; bar: return 0; } > > ^ > > <stdin>:1:29: error: unknown token in expression > > <inline asm>:1:9: note: instantiated into assembly here > > .long () - . > > ^ > > 2 errors generated. > > > > on clang-13, but passes on gcc (with appropriate asm goto support). The > > bug is fixed in clang-14, but won't be backported to clang-13 as the > > changes are too invasive/risky. > > > > gcc also had a similar bug[3], fixed in gcc-11, where gcc failed to > > account for its behavior of assigning two numbers to tied outputs (one > > for input, one for output) when evaluating symbolic references. > > > > [1] https://github.com/ClangBuiltLinux/linux/issues/1512 > > [2] https://lore.kernel.org/all/YfMruK8%2F1izZ2VHS@xxxxxxxxxx > > [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096 > > > > Suggested-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> > > Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> > > Cc: stable@xxxxxxxxxxxxxxx > > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> > > Message-Id: <20220202004945.2540433-2-seanjc@xxxxxxxxxx> > > Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> > > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > > --- > > init/Kconfig | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > --- a/init/Kconfig > > +++ b/init/Kconfig > > @@ -33,6 +33,11 @@ config CC_CAN_LINK > > config CC_HAS_ASM_GOTO > > def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) > > > > +config CC_HAS_ASM_GOTO_TIED_OUTPUT > > + depends on CC_HAS_ASM_GOTO_OUTPUT > > ^ This is going to depend on > commit 587f17018a2c ("Kconfig: add config option for asm goto w/ outputs") > which first landed in v5.8-rc1 and is not in 5.4.y. It should be safe > to pick that first, and we'll only need it in 5.4.y (the backport of > this patch to other branches LGTM). Greg, do you mind grabbing that > first and in addition to this patch? Ok, will go do so. > Meta-comment, what's up with the curious email addresses in the cc > list? Is there a bug in a script somewhere? (I dropped them because > they don't look correct). It's my "let's parse email addresses in bash logic that I copied from akpm decades ago" script that picks up the message id stuff above and thinks it is a valid email address. To be fair, it is a valid address... thanks, greg k-h