Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1026374pxb; Tue, 1 Feb 2022 16:09:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwI8dvepRde48ppw15oOzKyZ3N8YHcikA86I2H9fohqlldty08c10v8bELXUCYM5OCc0ohE X-Received: by 2002:a17:906:6a26:: with SMTP id qw38mr24651788ejc.560.1643760585589; Tue, 01 Feb 2022 16:09:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643760585; cv=none; d=google.com; s=arc-20160816; b=fBTM0I8HLDlrL/KknNjWXF2k86tnX24ixWmf5S4jwUu5mSYPLnWoxMuLSo0vDPevki wjYZ/Z6zFzN7DQ04RRuPfxzb4xJq0oUtLt3zYcWI7cTM+VihO0WJHyVe3LECe7gqCs+f ITs3J9ib9pW8WG2w3ssWx46UiCoBPn192Gujcy1t+LPDuj3fB+VpQczDTVSjxYLLuSYN cPYcOKaaX7Q6VAb/+tBVuiUU0CFhYUiH+XwErKoRpga/PZXm6tRpvtCI624mjvdwVC9P l9N/6fiPItU1vYeUMqy+lPJLcFAcFjgXt6DErlwJGqTt5cNpjoQr76IsfhiScfmqaoZI u2iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=+cGTUlncoKI8qOYBohRERc3y0sAWcqimeQBl8Ab9RTI=; b=w8+OoMk4IqDGrfmlOdw73eMXEo7zZIbeNl2HfutAgtcvSWoAg1CiF8nvExVOR0lDlL 76sIW3ZWSovULsGlWOYJa+74MVZuvKw3+gJjlcJmIBhM/bjPD0QZRfYamJb7NwvUiMli Qr8fUbNHm4fOOfQ19u3drMKR7rsZknH7iJe1Ex/6fNNJW4ufkM5ybWm7Pjug/J9ywQ+e KUzlL2H6jsLJmhLRbtE0h8aFbWy539nz0Ah3B7276xemf4bkOoKteJwOgvHVN7uHS1XZ ulw+QsIJPl2+DpeGmfvxFQJgXE6rCsildyRvoFcv4bUxHUgWMOq7SnybHqatdyEx17Q6 F3mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=e+kmca8j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hg5si12065492ejc.279.2022.02.01.16.09.19; Tue, 01 Feb 2022 16:09:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=e+kmca8j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231582AbiBABJA (ORCPT + 99 others); Mon, 31 Jan 2022 20:09:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbiBABI5 (ORCPT ); Mon, 31 Jan 2022 20:08:57 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23A1C061714 for ; Mon, 31 Jan 2022 17:08:57 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id a9-20020a170902710900b0014c8132e8b8so5816141pll.10 for ; Mon, 31 Jan 2022 17:08:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=+cGTUlncoKI8qOYBohRERc3y0sAWcqimeQBl8Ab9RTI=; b=e+kmca8jtulDGdN54BEXwgAQTzwVvQmOdxghFymavue4yUbH/JhbYwHShmg1mknAC6 TGWIGxmq/jFX2ptfeKHdKOfDRmgEQ5v4CL5i0MZStw7TyXz0CKikehanAZ6q80gNqdkb Ln5rWelPLY+WQKzPp2vu9zFOh71C0LYNRNranTXX76/y2XvUFmFfGmEf/iVuidZzaps1 CjSQiklb9jr+iJ0X5DmoXGzzY6x4s3D4XjdeLZJcY33tvhR/KBRMFbbVerGg86YRHTIL osbxNrDIlYlZl+1rA1VTn8E3fc1/sAuiWV221P8fbNWyWHM3ryGiW4oTC8AqpbxI3xiT Avcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=+cGTUlncoKI8qOYBohRERc3y0sAWcqimeQBl8Ab9RTI=; b=p6vyUmuVlFSQcXFOMrxSb4Iorjfs2BvfPQY77aw72BAovhExwpvASV3eV4QjLkIgQV D9XOByDNfKYIaBFqkOA97Wsd0x0wg0dqrzlttDY6AcmOhZ8/plmwFlnlOIs/9R+uFbpj VZXdOvezACfj+o0ZP1Y9ISyNbRgw4umHdd/uH0LAL3APTcGu9OPOkp/SmY2puYTXlEH2 Lg65CW4SXfZopeHsOpI7lu8z/toR3t63LoUK3pf5cDlmBbxD+o28NUSOTRtRl/WoBwgN r0p2/9yn0ZUGGRGSEdrHH+Edhvy8UMLsdh4pIlzYKEDFLOxXMPywzrywefXBzobpQMFK LckQ== X-Gm-Message-State: AOAM533W/B4H3mviIMgtA/R96d7YFFkNGRL8wLOyAM2Tpj/MDcREB604 ZE/n/JgI0nV11LsM7DYWdVKZH1EOa9w= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:c086:: with SMTP id j6mr22888340pld.101.1643677736737; Mon, 31 Jan 2022 17:08:56 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 1 Feb 2022 01:08:34 +0000 In-Reply-To: <20220201010838.1494405-1-seanjc@google.com> Message-Id: <20220201010838.1494405-2-seanjc@google.com> Mime-Version: 1.0 References: <20220201010838.1494405-1-seanjc@google.com> X-Mailer: git-send-email 2.35.0.rc2.247.g8bbb082509-goog Subject: [PATCH 1/5] Kconfig: Add option for asm goto w/ tied outputs to workaround clang-13 bug From: Sean Christopherson To: Paolo Bonzini , Nathan Chancellor , Nick Desaulniers Cc: Sean Christopherson , 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 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. [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