Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2144661iof; Tue, 7 Jun 2022 21:14:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE8sXjpzB/kVdrpGDWYgYBt6k6tvS0U/98nVthPCBKYSdvnq5L8JzbcRR1IeqqEC3O/UU6 X-Received: by 2002:a17:90b:3ecc:b0:1e3:4b89:e576 with SMTP id rm12-20020a17090b3ecc00b001e34b89e576mr42642160pjb.183.1654661661591; Tue, 07 Jun 2022 21:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661661; cv=none; d=google.com; s=arc-20160816; b=0wsNP5QJFEnXhdvuLIOhNcUxxQAchJl/zwLPr3Ne5GyWxL8LJuqurSf2d1XrMi7dQp 2vsFQsNR2VFufoQos9Gz+9OJ19wHKaIXx0EHFjma6QiEcxYuTpBF0kolNK1hmkqwfUOE YQ6iAKycQ0lJv5MuPJ+x70CoziHmuxBmSGh14ir+XfEcpe+Y/eZPkt5veeDfdT0W5724 kCQ0H9NGxSIMgvl6zIjCJob9BQIHZlvpEdtRl9ThLUFBhidYkxcUR4D/2u9v3BnQWr+9 1WgJuCnSMF8xGe6OTq/elHF63xG7ZqshUh4ds0jZN2j5dmGeQ6vfJZ+R4pwuSSlfQWNP vrWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SZ63Zd3nnkW3FMA2s4yCvxOt8xP/sqEpBF2Qdpn5Nus=; b=YMafObr8QWGLM7T8mKWjMOPcFDYC4jFkX31jOlJdCm2htrKJkAGppG5+ASWWrzzPFU xdemkUTXVq0/vOBvt54IWugsaNXCI8E9u9E4NJNb43znJ2B3V485T0W1c3ApbrDMa5lb kChYpJ0a+1Lj/qIle4x0prMgXMQ7ZdTKw3MSWATDh95Vq5YXV7N4daoV0MpgOwyJyZrr mAMOMdoNFKqqxpjzkcLiAor9edA5Zy44xAZB5MjKt4w/vY13z0bUqRYkp0UC+pAiVb8P Ls8QNFLp2InYLG0rsmXX+QYNuugANGTQHG95MH6DXeqRVzHWh4ZoMTtxZr5QFE6JJByQ c/Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x++LNaYP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b4-20020aa79504000000b0050822e94cefsi10452780pfp.369.2022.06.07.21.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:14:21 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x++LNaYP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C81FA22FA2A; Tue, 7 Jun 2022 20:46:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380730AbiFGVoc (ORCPT + 99 others); Tue, 7 Jun 2022 17:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378455AbiFGUwI (ORCPT ); Tue, 7 Jun 2022 16:52:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5EAA2004F2; Tue, 7 Jun 2022 11:42:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0B734B82182; Tue, 7 Jun 2022 18:42:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 753B6C385A2; Tue, 7 Jun 2022 18:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627333; bh=RgCuTiD3kozF3mlD2ezwdETxBXaIcFW+5/2P0Urfp64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x++LNaYPkikP0X5pDogmom/6ZtFBazieFD8gEu+AyIdqIslTa0/TBOnRIwvF3dXcW msz2FgvAGOuzLI5ZWXYb/K/o7NAGjFlZDrQUszx6NVoLnU1oa3+Lqcuq2QflnIN8dW Cq03KXcptqbto0JqfcKypXY8OP2RZH4S07bHglxk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Desaulniers , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.17 703/772] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug Date: Tue, 7 Jun 2022 19:04:55 +0200 Message-Id: <20220607165009.763815047@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson 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 :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. 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@google.com [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096 Suggested-by: Nick Desaulniers Reviewed-by: Nick Desaulniers Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20220202004945.2540433-2-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- init/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) --- a/init/Kconfig +++ b/init/Kconfig @@ -77,6 +77,11 @@ 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 + # Detect buggy gcc and clang, fixed in gcc-11 clang-14. + 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)