Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2375023pxb; Thu, 3 Feb 2022 05:25:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzfdLeDPHiDq+cWswDl2iRDg2ErdMTmGTBpuqJ+zlgO0k4hmbg4BpAkWsm4GlGVEcl2nyo X-Received: by 2002:a17:902:ea08:: with SMTP id s8mr35828037plg.95.1643894703287; Thu, 03 Feb 2022 05:25:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643894703; cv=none; d=google.com; s=arc-20160816; b=JI3VLwmxPFRPD0Z6SwJcxd3OlEVGfttIrMbqVoQsgexRspXJNtmMvvQscd6Yb9FBoj Wl9PyLOQ6OBqrZrV0iW5gVf4bM3mH8WBTHu7x7O56yKneDyfAPBiW+7dszaGOvO8ID22 Z3VQocrG5fT4/Oq7GB2M7q3kgdSqbG+jbdG0XIo5hXG0Rfnqc0LvhSohyLg03qwHyUI1 vV1/IrP4MbK8wLV8PK8fCDuzPVX2mCbsw94qKOdExknrd6JLLk1hc6Fx4DpPNp2/gTAr E2NfZ6/6Pmy5F4Jfdap9Up+tfC2UKltbZjnMV+Zwoz65l/l8X+unzcSBxjQsb5UTd1mt q6yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=f3bcsAklugUA8X5S8eqHouC9oaHAaVuRIrrTe+rJW24=; b=cp2RtUQxf6/lN2apK8kkta8vCDQV5+kv7uE4kxTWJj9zygNgTbSjv+hokWH7vqy0YM 16SPUZQDWItOgw/chzn/D9c3QRYEw7ITCrWVGTF/Keef6FDuS8IHTRkdv6XEU7MygzZp r/InEWDcu6KoImqX3yFJE+iVKb6zkv6pS2W9Mlle/CEdEzHJfRHQA5dET90k+jPiAZxy 52yBih4c/u6qiV59RksVwuoROb47If9frshQxlT551TdgmwpPmQmQALZzn1LBv2Ztf/D vW4FjpRDwnLYCSF+Ef98YuDorvFpfPGV7x2KCt/3Bfhzi+bNLQYftbBrtcJB2xq7/5qw 85iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Kyj6Bc9Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15si20543528plo.507.2022.02.03.05.24.50; Thu, 03 Feb 2022 05:25:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Kyj6Bc9Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239059AbiBAURJ (ORCPT + 99 others); Tue, 1 Feb 2022 15:17:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233574AbiBAURH (ORCPT ); Tue, 1 Feb 2022 15:17:07 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12059C061714 for ; Tue, 1 Feb 2022 12:17:06 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id z20so25751665ljo.6 for ; Tue, 01 Feb 2022 12:17:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=f3bcsAklugUA8X5S8eqHouC9oaHAaVuRIrrTe+rJW24=; b=Kyj6Bc9QCO+JV2e2BYCdvw63ME+XVX7mD1L0xBJ/nJR7GpK9LZTXleDRaKPB68Hxqf NF3WNVeqUx6R8F54VtcOKlozz9fWtsQTPFA/AD1Pn0jyl7Lj1dKaXDHiOb1YWkjeoGoJ MtGMRnHvg7Z5dGCMlqb/pWt0QVDxwvRARjEk0xuXalkpvBZpFsZDM3SWTGZT17z6jwOS lh3I5vIbaqNcWcZoxrH1NQILkUplY21IAs+EM9cLeg2p5s25+9obBeljDVfK+Hws4w3J hK5/clJiK6Qu5YhvtVndyA1SEURtS0GIwvwz9ztDT22zdvvM/9IxjtIRXHGgvTG8fflo UsOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f3bcsAklugUA8X5S8eqHouC9oaHAaVuRIrrTe+rJW24=; b=X62/yzg/O845jgo56d9P6czUT9S1Ls5WLV8JfNMA7RErMbQwjP1u53lQ9BPwvAOTfo FrHkq4h2kyNcg0lDGOJlza8+IibIWCXcQLgKU/5ipyrY0o+2wPpwitU8DUQOhW1Uyp64 6fMNFAKjYbgo9NJiYkKbzKaT2EVzgAi4+eaGKVvdyY0Uh4aeXyT6N6/k+OnZYGN1nsAm BucccL4tdxz2FI04+asSUwpgHw5beKvIquGTJLsstdNX3yc0+tosj71MpRelQXb9ezap KFhkSchKeWSjON6A8B+9+991Rr/Q2HKpcvNaND+6NccNTWinpQvEqAL40DfqjgTLjzUr J5Cg== X-Gm-Message-State: AOAM53195MmvwZfo9awkJabkJIkcNha7uZeBOeSzlKnJWj52/eqlcSR6 +uSovnDRtCyUEkJxqU/KrzDc6dMsIKjB1QYzMQRQuQ== X-Received: by 2002:a2e:954:: with SMTP id 81mr8682225ljj.198.1643746624322; Tue, 01 Feb 2022 12:17:04 -0800 (PST) MIME-Version: 1.0 References: <20220201010838.1494405-1-seanjc@google.com> <20220201010838.1494405-2-seanjc@google.com> In-Reply-To: <20220201010838.1494405-2-seanjc@google.com> From: Nick Desaulniers Date: Tue, 1 Feb 2022 12:16:52 -0800 Message-ID: Subject: Re: [PATCH 1/5] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug To: Sean Christopherson Cc: Paolo Bonzini , Nathan Chancellor , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Peter Zijlstra , syzbot+6cde2282daa792c49ab8@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 31, 2022 at 5:08 PM Sean Christopherson wrote: > > 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 > > :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; } > ^ > :1:29: error: unknown token in expression > :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. LGTM. Reviewed-by: Nick Desaulniers If you're going to respin the series, consider adding a comment in the source along the lines of: ``` clang-14 and gcc-11 fixed this. ``` or w/e. This helps us find (via grep) and remove cruft when the minimum supported compiler versions are updated. Note: gcc-10 had a bug with the symbolic references to labels when using tied constraints. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096 Both compilers had bugs here, and it may be worth mentioning that in the commit message. > > [1] https://github.com/ClangBuiltLinux/linux/issues/1512 > [2] https://lore.kernel.org/all/YfMruK8%2F1izZ2VHS@google.com > > Suggested-by: Nick Desaulniers > Cc: stable@vger.kernel.org > Signed-off-by: Sean Christopherson > --- > init/Kconfig | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/init/Kconfig b/init/Kconfig > index e9119bf54b1f..a206b21703be 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -77,6 +77,10 @@ config CC_HAS_ASM_GOTO_OUTPUT > depends on CC_HAS_ASM_GOTO > def_bool $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null) > > +config CC_HAS_ASM_GOTO_TIED_OUTPUT > + depends on CC_HAS_ASM_GOTO_OUTPUT > + def_bool $(success,echo 'int foo(int *x) { asm goto (".long (%l[bar]) - .\n": "+m"(*x) ::: bar); return *x; bar: return 0; }' | $CC -x c - -c -o /dev/null) > + > config TOOLS_SUPPORT_RELR > def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh) > > -- > 2.35.0.rc2.247.g8bbb082509-goog > -- Thanks, ~Nick Desaulniers