Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2185339iof; Tue, 7 Jun 2022 22:31:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+dtKfs2SjjhxMvF3mPG7tHD1oq3ETOo/DVu6VRQFnfqy4H/GoZeAdzAFXeLw1ikRJvaGi X-Received: by 2002:a63:e4a:0:b0:3fc:a85f:8c08 with SMTP id 10-20020a630e4a000000b003fca85f8c08mr28502608pgo.450.1654666295730; Tue, 07 Jun 2022 22:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666295; cv=none; d=google.com; s=arc-20160816; b=hLjhYcYxfBnzwaZ4JiUoMVXSF77h4iHXu+51Ixfz44gees2GU1HG2jnpG8aQLgWgwE aEzfDrRVwY1aU+k4qN08uQiTVPZvjS/P7549g0v+GotTMz+L2XlWAUV/kBLRYsU+yMh/ 0ra/yRidHDmgAItNAwJFPCtjnB2PqcYRdSA8YSLSwwFMzsunht9bAnOI36rYLv1XDdDN PFBuaEPfVLT3xsJP7BL3MBSrwTazOf2fm4YgO0lw14NOc+/IkXIk+M36thyHuRcin0SM WECW9QkDozeIpPIzU7dJuDIEFRaEXIZagrOdqxNRTwrJV+RlF59ju1PtSBZKXnMzpSlK Cuhw== 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=yGVjxqIjOsXKQnI9LKChEhr5fqRyJqF/c8FvOI+6kU21MAvlqpEwxbrz1l4Rs5o9gs elSDt0hiaH2VasGGozsPRB+xUBUe3fbFDmkC8u4staWJSwVt9YvreiNPwyzOcc6afshj yOPXBTU+h+gJZuZh9nkZ0yoFggcN+W/lQM2MgkLnx1XyWFh2EXIlmY85aguNH70DyNRt 68gJ+zgeF7mUDVnfyGoMalW9BcnPeGR/baPh57aAs4pn95MJxhZtdJljcI06WRpAwwYS aWWo3ahrmu+JuxndQeTLxacLKkAJq0SX6VadxWwoCOL+K5ELJrFKd2J2NWCY83cRYM2X gbQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=12tFEJCi; 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 l7-20020a17090aaa8700b001dfd2940a5asi29314090pjq.112.2022.06.07.22.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:31:35 -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=12tFEJCi; 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 92DC548F648; Tue, 7 Jun 2022 21:58:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357017AbiFGUGr (ORCPT + 99 others); Tue, 7 Jun 2022 16:06:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354931AbiFGTKI (ORCPT ); Tue, 7 Jun 2022 15:10:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3175417590; Tue, 7 Jun 2022 11:06:48 -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 CAD32B81F38; Tue, 7 Jun 2022 18:06:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 416B8C385A5; Tue, 7 Jun 2022 18:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625205; bh=RgCuTiD3kozF3mlD2ezwdETxBXaIcFW+5/2P0Urfp64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=12tFEJCitpKNIU4YPXHNw/3S1Qbsp0qYzXZ1kAWm9NOiRnQd5LWI3JUjGwSS+M/4I m3Drg97rYmG+PQ48vBjk+mw3A2my3ZEm4vRY/otVWiOEfkr/5pk4BCAoTJzW7jl55Q aEaQY9Yecaptz4lEMBrHGdTfqpChRUQWQsBTHYZg= 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.15 602/667] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug Date: Tue, 7 Jun 2022 19:04:27 +0200 Message-Id: <20220607164952.734571545@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@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)