From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D673C433F5 for ; Thu, 28 Oct 2021 08:37:29 +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 3AF4A60720 for ; Thu, 28 Oct 2021 08:37:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3AF4A60720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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: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:In-Reply-To:References: List-Owner; bh=TiFXCZjmAqJ9b934K3bPHQNnGkAw6DMpK8Nmk+VUS7g=; b=NuM7S5KrnFA/WT /d8b0OZrSm0Ij65rP6y+I5mgRjFLSVTAC1M6CCo2m/PjyL/ifdhhVXcyIzBWo0egcxJ0v1Uq3PIrC uU3wW3NgRGY9q2x2oJbs4GOIFHnkZMqjP7xURm3TGlPLcgCPBpJTxtrbOGK+LsnOmS1irt3qlVb8m QNjj4T+sA7mVLldMwvrwktUF/GlfClKCXjG+wwjcZekGGiQQgjEPX0mmbmBxPCZXq/3msoRXtAGgB T/hwAW08XdV8sxCXInDttS2OwA/iWqjKxA8qDkD5OIrWSoIGobMMkh/mOO8mv4SVdXf8lc1e8Lcbv /z4JsIvVtCPK9B81S5oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mg0tP-007HzF-0n; Thu, 28 Oct 2021 08:36:11 +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 1mg0tH-007Hyv-KG for linux-arm-kernel@lists.infradead.org; Thu, 28 Oct 2021 08:36:08 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 902DD610CF; Thu, 28 Oct 2021 08:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635410163; bh=pa1UntvD1wodJK7D6f88+hWol6WlPge/OMjRGzJgGEU=; h=From:To:Cc:Subject:Date:From; b=Ken2ISU9CYoJhH7AXfnVu7VRuB1ked5cYr0kmmCDUcZh9M7JKJwJf95ogHrhnCTMn Bd3RxYwVeCHO5RReTituvtQD6Ds2BGeUWFyLGdNGfoPkvAnxf32qbDb6OjV6sm9+kC Q0lLKKlrZ+7nuMYfqFpuDEGVsp3GDExFsTN3GbDt3IedQ8PRM0DSZ5Vdqb4bRqcAKR RW9xSUQl/95izzt0JaJniraleJyi8MFlul1mFbeKXPNuQBB3XTPMkTxLkdzFMGWA2Y WTMF18V94DGslXAivp9kX59Yp0j+Wby6fHin4CthiCj3veCU+GrhSTN0gd2TiwkJpk 3WgjA3bXtjtoA== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: linux@armlinux.org.uk, arnd@arndb.de, ndesaulniers@google.com, nathan@kernel.org, keescook@chromium.org, Ard Biesheuvel Subject: [PATCH] ARM: Thumb2: avoid __builtin_thread_pointer() on Clang Date: Thu, 28 Oct 2021 10:35:27 +0200 Message-Id: <20211028083527.1057158-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1789; h=from:subject; bh=pa1UntvD1wodJK7D6f88+hWol6WlPge/OMjRGzJgGEU=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhemDOdGImRvMKZjL03MoPSIPL/+B+/ciVDkV6r+Zo vMdTi42JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYXpgzgAKCRDDTyI5ktmPJM+BC/ 4xhfmxLGkxoR9HRBg7FC6AHip3SN+Xrmy0oYZ3jOTcXr2Jsh3wHNLuFl6pKEkhn//o3bppPX6CMzle jjIZK041ZGmZwaidpsa0wEfhWIpdD56DpWY1ewRln306Ayng+k2Nfso+TP4gNc64klw6K8gxY5Cs0K 3B5jylOPR1cwFoaWEPnE1sij3BG+vFBQz8hIR/FCtplWEHneNFrKe5GSNnhqBFfw9MLDwoFxFfPqTm 6KgMFFP66/w3ha0PbfMm668inHOxApTT1ok7pJK16zAZEE0LtFf0ugiKvUehyWphDu59VSUD8Lt74D VFdBk1OMqL9p/hxhLbzEBNX33VOcxMfqKNF0MpE86vhf7iqJH1znFPRntaNKIrjKko8vfqsL1hucRy i2wTGGez6nXN52nQm/KtSrOqt1jDysjlkh0Ld3Bp4smkGFfKM5tYLpJ+8Buz2rTuJFkTvcoEMogH4j bsqtRLZHN4umx10ZCEvXe6UlK6YitXYw1GyRzGMEK2f+Q= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211028_013603_729180_8F26C9F5 X-CRM114-Status: GOOD ( 12.97 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If available, we use the __builtin_thread_pointer() helper to get the value of the TLS register, to help the compiler understand that it doesn't need to reload it every time we access 'current'. Unfortunately, Clang fails to emit the MRC system register read directly when building for Thumb2, and instead, it issues a call to the __aeabi_read_tp helper, which the kernel does not provide, and so this result in link failures at build time. So create a special case for this, and emit the MRC directly using an asm() block, just like we do when the helper is not available to begin with. Link: https://github.com/ClangBuiltLinux/linux/issues/1485 Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/current.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/current.h b/arch/arm/include/asm/current.h index 1d472fa7697b..6bf0aad672c3 100644 --- a/arch/arm/include/asm/current.h +++ b/arch/arm/include/asm/current.h @@ -26,12 +26,17 @@ static inline struct task_struct *get_current(void) { struct task_struct *cur; -#if __has_builtin(__builtin_thread_pointer) +#if __has_builtin(__builtin_thread_pointer) && \ + !(defined(CONFIG_THUMB2_KERNEL) && \ + defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 130001) /* * Use the __builtin helper when available - this results in better * code, especially when using GCC in combination with the per-task * stack protector, as the compiler will recognize that it needs to * load the TLS register only once in every function. + * + * Clang < 13.0.1 gets this wrong for Thumb2 builds: + * https://github.com/ClangBuiltLinux/linux/issues/1485 */ cur = __builtin_thread_pointer(); #else -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel