Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2174905iof; Tue, 7 Jun 2022 22:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydqj7fZjMue4lQWM9s+nvsBdvc5t0O9IN+VVduiDnjSBGxYdOvfDzFoRioaEw/nu0/Nrc8 X-Received: by 2002:a63:5b5d:0:b0:3fc:97d5:f8b2 with SMTP id l29-20020a635b5d000000b003fc97d5f8b2mr28953988pgm.322.1654665138716; Tue, 07 Jun 2022 22:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665138; cv=none; d=google.com; s=arc-20160816; b=HFoaOOXvjCX7Fq39/bk+gtCTt7AjGJ/0MSyW+1t2N/d3a2fh4TvzZex7PD81pamu1g ajq3bZ8mz2f5aeyOPZF6wBfp7wO1WP5AKaIcyV5hcYSjx1xpNTzgZbsZE4V8SkAiBYhJ Dxb/oKNyIybjUK9nTXAGtBYBTlpnptNViiKBdqwo1KCrRX0ivhnI5tqiRVrEAs5EX8uD n7Id1R8cqZDMHvLTgt7Q30ZFJ1F2P1gElmfLxVxjF0TZdrzbVvaA3+oqt/QTE+6MBxS4 J+YkIVN/0WwKYIkQEkQzRhLSu9hwoA73/9sRYji6s/ViDD/EkkjKdUHiczZFdCggI96j PD6Q== 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=ga1dPWJ9FwOKVCXnW3j/IUdQMbOGT+K+Fzk8Gtp2B9M=; b=r3Xdp+2OFETe/be9RXqRNeH8fqEI7kxyxdIoXiIMKfHOG4fAsegRVxnrZ0629ZSoE/ 14sXOMyaPJxdEMN9iMAK6FNFdC6TCHdkhA01JOHMVUZCKuYNfza0+OFvJs2gZcfON+g9 YFUm8kI/qXfi3qMDsWdCsjmgs/7PAdgCy+ZRcp30la4UrcLh/V3tAMq4WtqTIK+a+7ZL tmLpai+8ul1BUN4+5AgyvlyzKwe30udUFtfEl+kHBAwKoSHhK9JDCBxlJxOOOrvn7opA +gwp1b/kQ/2MnjsLzdhUJsPmaZ8P1aZVEvLyI3tSLEHVcrK4VmNqhq4Hwv+l903mKnh8 zphg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dKRurXy/"; 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 n124-20020a622782000000b0051c6e86d46bsi164901pfn.248.2022.06.07.22.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:12:18 -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="dKRurXy/"; 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 56F652CE0D; Tue, 7 Jun 2022 21:42:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350905AbiFGSGj (ORCPT + 99 others); Tue, 7 Jun 2022 14:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349024AbiFGRqm (ORCPT ); Tue, 7 Jun 2022 13:46:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B9E104C8D; Tue, 7 Jun 2022 10:36:05 -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 2DAA3B822AD; Tue, 7 Jun 2022 17:36:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93949C385A5; Tue, 7 Jun 2022 17:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623363; bh=anXB3R1k7SnZfxkNf0jrOXFiouNniGQO+BdlRmAYfHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKRurXy/Mv5r4+WzFBGROtXtBs7yCICCbRN/uuQ3QuyXXSoaNaUwpItuKDEymBSfR WiC1US6NiWDqdwVM8q/xEb93qPR+XwCwTbFVRiZVSq76zx9ZxoXj+LfGdn6WxJsqw0 NAXV8Vs16STAKk/zxSMcLzw50Q4lYjuaMj9KC/XM= 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.10 391/452] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug Date: Tue, 7 Jun 2022 19:04:08 +0200 Message-Id: <20220607164920.215056412@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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 @@ -68,6 +68,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)