Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp797820pxp; Fri, 11 Mar 2022 15:25:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHQuhf1qZ6Nqzbk2cfiYcysGnavA63p7nntiodzNUzxXzro+xaJs8dNnyL3uFAY92VLdB4 X-Received: by 2002:a17:90b:3e88:b0:1bf:3a96:54c1 with SMTP id rj8-20020a17090b3e8800b001bf3a9654c1mr13173763pjb.244.1647041108379; Fri, 11 Mar 2022 15:25:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647041108; cv=none; d=google.com; s=arc-20160816; b=S+zMXhAdL0MLAugamL7BjokUlg2rtfdMFc0dS5GMReHffBydLuqk8/144KEnqkR+uI QQh7X8hNUtzIhR8zJVEo8TS+2ACrCLcL4sBFRBwSfdZJv+lvYK1GR4F5o4QH5QL70HdR SM3Sf6zjVp05HCHtCS9z70ankVhtZTjU2SJUWs8HZKyrD43D9HNje240j1UpG5pR6G/0 xqZctUkvUQti2vCLCGNdaz4ZTx16Gl+Fp6Vf99T95RwqgjIZ6QDc5Trq1EjakmxneH30 zDjg2k6NhaaKsPdNxSzJw1zhUeAWufdVjjNx0VOwV0CLSqHip4TYHyCgYHsY4Lu5Ul8x 0rNg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=N5uPGV905+fnFeSQdaNR+3+nutoRv0lGEjE7aVy4l9o=; b=Us+T4UUf9nrDdabLFC0qvC2gHv3wX0mVftzRZ2iXlJXhHLgiI2cn5xUngPsN1XRDxe ONqN5w1KuC2YaEhTGHXj/skgvTayFGDIfDOvzZAxg4D2gLknvs/xHGTYiR6/eZGdB6RW R+WnXf03JnBt5HKPeJEM9VA4T5T1klm8vSZ4zeTVVdUjHk0D4C/Ss/b/Ho4ZDkr8CJHQ C+cPsaJ21sAqBahG7BMmuKz+uCLEJvcV0K/+oPfzJ4fz1rj4FHgRNlLQ4d9rOYw2bqxX 8VU49pb0syHtapZHI1z2aFJjQPcf8zjRb/6AWjZD6z64KnsuDqEtRyJ1TUvGs6f6sn1Y NVuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rV6f1TwU; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n19-20020a635c53000000b003728448ecbdsi9131226pgm.304.2022.03.11.15.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 15:25:08 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=rV6f1TwU; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 932CB3B7B70; Fri, 11 Mar 2022 14:11:56 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351141AbiCKT6S (ORCPT + 99 others); Fri, 11 Mar 2022 14:58:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344254AbiCKT6R (ORCPT ); Fri, 11 Mar 2022 14:58:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2BF1CF0AE for ; Fri, 11 Mar 2022 11:57:14 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 6054561E3A for ; Fri, 11 Mar 2022 19:57:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60E0DC340E9; Fri, 11 Mar 2022 19:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647028632; bh=K/3BmQl+yVa1K2EX0K8gw5URhrVb2cfe6vu4OaCFOK8=; h=From:To:Cc:Subject:Date:From; b=rV6f1TwUIGZwmcr6Y5HkN1tBwPzvtU7wFLyxgmgSuGRi/i8IGByG0aHENT6ReWWv2 mXod3uImMVCGpfLNXQLg4MkgLRysLlri+jBd3DnqAaWi1ivVn9wyEd3Q6gCh7BKiuy i/jazlJYYXsHker3KfD3V67ZkMW2rIodyB1Zexg/SwaOwNzcI8TETlKXbx254SqUiv J4gTnunCG06jq+w0AHevNo07z9n6YdkuPbEErAtce7aVa14LXXEZmSPTbVwUTuW96C BEgQ6joyvm4bmTw3EHxeeeqeHWt5hrj0ApB2PH6JWyKpzOs4m0FRwxtVhquvpHUPG7 bElweiqncqSTQ== From: Nathan Chancellor To: Peter Zijlstra , x86@kernel.org Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH] x86/ibt: Fix CC_HAS_IBT check for clang Date: Fri, 11 Mar 2022 12:56:42 -0700 Message-Id: <20220311195642.2033108-1-nathan@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Commit 41c5ef31ad71 ("x86/ibt: Base IBT bits") added a check for a crash in clang. However, this check does not work for two reasons. The first reason is that '-pg' is missing from the check, which is required for '-mfentry' to do anything. The second reason is that cc-option only uses /dev/null as the input file, which does not show a problem: $ clang --version | head -1 Ubuntu clang version 12.0.1-8build1 $ clang -fcf-protection=branch -mfentry -pg -c -x c /dev/null -o /dev/null $ echo $? 0 $ echo "void a(void) {}" | clang -fcf-protection=branch -mfentry -pg -c -x c - -o /dev/null ... $ echo $? 139 Use this test instead so that the check works for older versions of clang. Fixes: 41c5ef31ad71 ("x86/ibt: Base IBT bits") Signed-off-by: Nathan Chancellor --- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 4ca7bfe927b3..870e0d10452d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1867,7 +1867,7 @@ config CC_HAS_IBT # Clang/LLVM >= 14 # fentry check to work around https://reviews.llvm.org/D111108 def_bool ((CC_IS_GCC && $(cc-option, -fcf-protection=branch -mindirect-branch-register)) || \ - (CC_IS_CLANG && $(cc-option, -fcf-protection=branch -mfentry))) && \ + (CC_IS_CLANG && $(success,echo "void a(void) {}" | $(CC) -Werror $(CLANG_FLAGS) -fcf-protection=branch -mfentry -pg -x c - -c -o /dev/null))) && \ $(as-instr,endbr64) config X86_KERNEL_IBT base-commit: 9e1db76f44de4d9439e48c9ef61e5d457395202b -- 2.35.1