From patchwork Mon Jul 12 21:46:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 12372373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01FFEC07E99 for ; Mon, 12 Jul 2021 21:52:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BDD8B61106 for ; Mon, 12 Jul 2021 21:52:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDD8B61106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OH5W6Z6iFEkHlOUFyYvFisltEjEJtYi8U5M4R+TlHN8=; b=Np9fBw0/i48m3E Xf4FzKJjjPyureKVhSafCyL7/MgSszXwCUGeezGYJLnj/Qn7YBDge1erSl9gDriA+br5Gjyyb9iK5 U4lzSpn9nM8tfO5cQhmqEEAiPhtMGE0/nZHqUG2IjEvuvDwX/H46msCVN5CyoULTI5EtgQ4Eqyrrt SIKG1V5qjtQ8sGJQtw3HWTO/SXCtGdmrzj6CJJxR9dXZroRMHlyByafcHZB2+taeQd0AY5+ADPCY1 AfZHPVLYlhGFgCFmRZ23jLVzE+3M2VyZg9tO+lpvw9Ib7pjNrOclb3KQ4T5VGRIhuNYgdPPJ0Xwwg HWJOZ2hbd8/t5sZnEUuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m33pk-008WaF-If; Mon, 12 Jul 2021 21:51:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m33pe-008WYM-Aq for linux-arm-kernel@lists.infradead.org; Mon, 12 Jul 2021 21:51:22 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E1F860232; Mon, 12 Jul 2021 21:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626126677; bh=5vqH/9WMlx5qlNWbJyIbS33BMltJ59roYjI/NA3A8zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nabIYQH1RzcFAg09o1rTJxVWITUxILIHB5/Luu5fGL4rmO7LU2ZLz+GihxhLh/k// W9sHG23QF5gW6mjfP68OpjQUxu5resqOGeEpCuEmyZPmZwONDMkDXCTgf2rXDuD31Z Yqi+EJqqoHsyoEqJs4JLYcty8ZnXe9Mfe0I2gsELyqy9B89Qsr3HVJxfAfCSd/XaNs p29kCtsmU0zDiFMjdSGNcyR5bY1TnQsZyyTNPEVB60ond0PvmWdGtfowQsOyrKluLy VZOLzI+oKzNuaQf+/QX6sGU/9KbdtYY5BoMcgcl07Dg6BhbL3bhDPiklTxRxdbYSER hqd59j6HnPFjg== From: Nathan Chancellor To: Catalin Marinas , Will Deacon Cc: Nick Desaulniers , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH v2] arm64: Restrict ARM64_BTI_KERNEL to clang 12.0.0 and newer Date: Mon, 12 Jul 2021 14:46:37 -0700 Message-Id: <20210712214636.3134425-1-nathan@kernel.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890 In-Reply-To: <20210709000627.3183718-1-nathan@kernel.org> References: <20210709000627.3183718-1-nathan@kernel.org> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210712_145118_490908_8E12D6A0 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 97fed779f2a6 ("arm64: bti: Provide Kconfig for kernel mode BTI") disabled CONFIG_ARM64_BTI_KERNEL when CONFIG_GCOV_KERNEL was enabled and compiling with clang because of warnings that were seen with allmodconfig because LLVM was not emitting PAC/BTI instructions for compiler generated functions: warning: some functions compiled with BTI and some compiled without BTI warning: not setting BTI in feature flags This depedency was fine for avoiding the warnings with allmodconfig until commit 51c2ee6d121c ("Kconfig: Introduce ARCH_WANTS_NO_INSTR and CC_HAS_NO_PROFILE_FN_ATTR"), which prevents CONFIG_GCOV_KERNEL from being enabled with clang 12.0.0 or older because those versions do not support the no_profile_instrument_function attribute. As a result, CONFIG_ARM64_BTI_KERNEL gets enabled with allmodconfig and there are more warnings like the ones above due to CONFIG_KASAN, which suffers from the same problem as CONFIG_GCOV_KERNEL. This was most likely not noticed at the time because allmodconfig + CONFIG_GCOV_KERNEL=n was not tested. defconfig + CONFIG_KASAN=y is enough to reproduce the same warnings as above. The root cause of the warnings was resolved in LLVM during the 12.0.0 release so rather than play whack-a-mole with the dependencies, just update CONFIG_ARM64_BTI_KERNEL to require clang 12.0.0, which will have all of the issues ironed out. Link: https://github.com/ClangBuiltLinux/linux/issues/1428 Link: https://github.com/ClangBuiltLinux/continuous-integration2/runs/3010034706?check_suite_focus=true Link: https://github.com/ClangBuiltLinux/continuous-integration2/runs/3010035725?check_suite_focus=true Link: https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9 Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers --- v1 -> v2: * Fix typo ("compilign" to "compiling") per Will. * Clarify that these warnings are reproducible back at the time of 97fed779f2a6 with allmodconfig + CONFIG_GCOV_KERNEL=n but that configuration was most likely not tested. * Clarify that the warnings come from CONFIG_KASAN, which suffers from the same issue at CONFIG_GCOV_KERNEL because there are compiler generated functions. * Clarify that the root cause of the warnings is resolved in 12.0.0 and link to the GitHub commit rather than the Phabricator instance, in case LLVM moves to GitHub reviews in the future. Hopefully this is adequate explanation for what is going on, thanks to Will and Nick for providing input on the commit message. arch/arm64/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: e73f0f0ee7541171d89f2e2491130c7771ba58d3 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index e07e7de9ac49..b5b13a932561 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1605,7 +1605,8 @@ config ARM64_BTI_KERNEL depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697 depends on !CC_IS_GCC || GCC_VERSION >= 100100 - depends on !(CC_IS_CLANG && GCOV_KERNEL) + # https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9 + depends on !CC_IS_CLANG || CLANG_VERSION >= 120000 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) help Build the kernel with Branch Target Identification annotations