Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2252188iof; Wed, 8 Jun 2022 00:32:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKVTxXlsU+NtBgpgeVst/pSVP6Mj8DzszgQY6XRHLTjsNVt3RBTGbyxsJDABMXxSZ1Vqju X-Received: by 2002:a05:6a00:24c1:b0:51c:784:cb59 with SMTP id d1-20020a056a0024c100b0051c0784cb59mr17782421pfv.57.1654673543211; Wed, 08 Jun 2022 00:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654673543; cv=none; d=google.com; s=arc-20160816; b=e4Cz/hlYF5N0ZNNPS3Xe7bKeNBg9HTp73z+PDaEYG051ChTtlaCPSluCPNwPJBWdzK 4o13kStfUqQIZ8jLKA/4DaQDVu/4FmMF57gNkKGfg6U/68uFTlgO+qC3LfIZxPbQGG0V k3JpQO7Pbyo+ir2e9iiZV4HPrAXR5OQ92lXIDbvuBJTnsDJ+myqTr49l9n5F/ONeV84J CyCCIZKpWEe3t4NZb0KsriCXhcnzVebg67qsMKwbPuPvZbHB7Rjdld2w/em/BeXA9h0M 96NTndDUh8L9OyMrfeL1Tclmuit86PEg7YQ85ZafKXNzBjBhKRiw5IHpbZUMWUZCEB/V FYPA== 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=grb12hDQ4z0uOBKUx2LEyJ5UBbysf0x9FcJaOdmvJOW3vjcVUAPiLcirLOmURH5waj BP9uMbN0fvFcQvLSXkxw2WdNP/6AYIOy+FXGSRcVyLA/1qwGri/TBXuV7BjJbIBpa1C6 wCLT8RQZ11EvHjpym9Wb4LSg6iV3fM+wlBylU+gvYCk2vJ5twS+IhNMPFSLjoDXYOVIa kum01GhfpY/MSZUB+4QQFIAiEvdRJGxZDHzOPju5oSt1X8rApkzZvLZa9yBj7JHFYDgp o4O/MiifMFYt9iTqwAPSmEDvUETn134CHmpIgJh5ZlsZBO4IceORabiSdM3H8fxY7Vr6 DbAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vl9tpxgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c4-20020a056a000ac400b0050fac0168c6si28291937pfl.49.2022.06.08.00.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vl9tpxgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 954952004EB; Wed, 8 Jun 2022 00:05:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442358AbiFHCAV (ORCPT + 99 others); Tue, 7 Jun 2022 22:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1837532AbiFHAAJ (ORCPT ); Tue, 7 Jun 2022 20:00:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F1119C3A9; Tue, 7 Jun 2022 12:23:00 -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 1AD52B823CC; Tue, 7 Jun 2022 19:22:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CF32C385A5; Tue, 7 Jun 2022 19:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629774; bh=RgCuTiD3kozF3mlD2ezwdETxBXaIcFW+5/2P0Urfp64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vl9tpxgVZi6sCC8n6bVPLDKKSJMDAOVfGKlJJ6Ed4oM24LrF+D5tofHCJZBrGDkfg 0jsxa6wfun+113XwL8sgKuPMFqP9pZ3081gkZsi6momcerJAZoVw+094foQ8dKlodT 0BmwJhH96VQ+IiCEcn+R5/lFLc5JiOJBrTAwhnc0= 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.18 805/879] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug Date: Tue, 7 Jun 2022 19:05:23 +0200 Message-Id: <20220607165026.224872138@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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)