Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1990929pxp; Mon, 21 Mar 2022 09:03:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtPMmUEHqbhBoWDyeEa7xERchxoBhTZiR6lFPP/q8+7+y5Wr8Nf/0Uw6K8QnRVioXpK2ca X-Received: by 2002:a05:6808:2308:b0:2da:b43:8d63 with SMTP id bn8-20020a056808230800b002da0b438d63mr10289499oib.177.1647878627766; Mon, 21 Mar 2022 09:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647878627; cv=none; d=google.com; s=arc-20160816; b=muc3kEvHkp1e8dDjNicCamzxWhJPycZucApntkBlpeOrnqM8q+iTXUDZeJwVUpXvF3 f6u31olYz9T3jrB0Rl41kvAEkzU4jgKZ8ysazG1ZBx2ZuUtH4FqR3EkULM07uH81XZ/X zB5V1+weLmzfEHIcwk6tbnqg30qWn6sL+dh7/Vv7q0WZJ8V8V4ODGaz7taAq5mkIdSwn FDBelI93hVa7vnLUkFPHLMoyg6hLzGO7en9uZR6nR3z2x0wbseCCz+zvu+GoEK8w9zzz RntmQafFxOsSBlOlIYI1pfqGWEWhUJg6p0iF7wOEvurXoTTzRhERN6L2jODvuQUw+81M jaAQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gb14cZgmHqH+4NacdQC4czzOQjA+yepVHV03/G3KtwE=; b=A8Buf+uH2NoM6K6CSTNjLu9KpKle7Sid+raG96wb6/QzVXJHaa1ZjGYdo0rS5G0P/9 TYccxoOobIunK6BNXGFO+yxywu0XKfD8bgjd4xa4znUA16lo0MectxWehpi0w61s6uyH Q8yJyXBqahUvP3TAUmNGGUJ2XtrO/wCfLU7aX4u8vPx3nOr2DLuKmecpHXmcFhgl5yQE pjCU8obZ8h2kJnRAixrp2Cp/7hKWjxItcpN+eIjmk03oDChbZi9bIhPB/0aAvrdxGFPX E1ZyQWQ5i6VqI7uSZIGS/4sCRk9KIuF2csBpTaysO4Fn5TfpltsoQhsjjRll7lG3UefI uXJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fxU5nerO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be34-20020a05680821a200b002ef0c3475casi4891556oib.74.2022.03.21.09.03.31; Mon, 21 Mar 2022 09:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fxU5nerO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241455AbiCRXKV (ORCPT + 99 others); Fri, 18 Mar 2022 19:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241433AbiCRXKU (ORCPT ); Fri, 18 Mar 2022 19:10:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32179F47EA for ; Fri, 18 Mar 2022 16:08:58 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A5928615DE for ; Fri, 18 Mar 2022 23:08:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7958DC340E8; Fri, 18 Mar 2022 23:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647644936; bh=+Gr67379WVWBWHw2ybHUFLROVBWIzwE3VSkuwwrlIuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fxU5nerOYn+YVqvuq87g+2P5UNUhrvDTJf0l/G6D6cq/fOie6DZIaCKcFhmvvN53t TgDwejuZeS8YL0DWUVGPjaYHpbUU7cSyNc/4haUxLkAG8KVj3Y6ONK0NumuHM+uvxG WgCtrs2DGbm5inrsqXO6v/kJlLtXnPNY0Ob1+XDQzbBRI78s3Ua7dLrzjwZ2Jcal8u y/oUJ1GxZx5MJ6ibMfUwLQh2w+zoKDP1pbOVdfYUsLCh8NS1ly/1a8PcBmjo6CLLPa WfndH/8lLVUi24s0HkVUzHt1KVGRLzQaxc6qI5lUaM42wWW9N0rz1KL8SgMGfhVtR/ 7Ivpdow0zR3mA== 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 1/2] x86/Kconfig: Only enable CONFIG_CC_HAS_IBT for clang >= 14.0.0 Date: Fri, 18 Mar 2022 16:07:46 -0700 Message-Id: <20220318230747.3900772-2-nathan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220318230747.3900772-1-nathan@kernel.org> References: <20220318230747.3900772-1-nathan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 156ff4a544ae ("x86/ibt: Base IBT bits") added a check for a crash with 'clang -fcf-protection=branch -mfentry -pg', which intended to exclude Clang versions older than 14.0.0 from selecting CONFIG_X86_KERNEL_IBT. clang-11 does not have the issue that the check is testing for, so CONFIG_X86_KERNEL_IBT is selectable. Unfortunately, there is a different crash in clang-11 that was fixed in clang-12. To make matters worse, that crash does not appear to be entirely deterministic, as the same input to the compiler will sometimes crash and other times not, which makes dynamically checking for the crash like the '-pg' one unreliable. To make everything work properly for all common versions of clang, use a hard version check of 14.0.0, as that will be the first release upstream that has both bugs properly fixed. Link: https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39bf31d7f6aac00e0f Signed-off-by: Nathan Chancellor --- arch/x86/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 0f0672d2c816..921e4ebda564 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1865,9 +1865,10 @@ config CC_HAS_IBT # GCC >= 9 and binutils >= 2.29 # Retpoline check to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654 # Clang/LLVM >= 14 - # fentry check to work around https://reviews.llvm.org/D111108 + # https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39bf31d7f6aac00e0f + # https://github.com/llvm/llvm-project/commit/dfcf69770bc522b9e411c66454934a37c1f35332 def_bool ((CC_IS_GCC && $(cc-option, -fcf-protection=branch -mindirect-branch-register)) || \ - (CC_IS_CLANG && $(success,echo "void a(void) {}" | $(CC) -Werror $(CLANG_FLAGS) -fcf-protection=branch -mfentry -pg -x c - -c -o /dev/null))) && \ + (CC_IS_CLANG && CLANG_VERSION >= 140000)) && \ $(as-instr,endbr64) config X86_KERNEL_IBT -- 2.35.1