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 C3D15C433F5 for ; Thu, 28 Oct 2021 16:33:48 +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 8C1BC608FE for ; Thu, 28 Oct 2021 16:33:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8C1BC608FE 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EC7EvPWdmJLXd21eu6RwvfdNWBk6IcPtVxlHSK6SBzQ=; b=DRJx97Y/fyLR7x vpzjPqKEq/Y8Br+FGzWHcQZz0lh9sDX3RNMfUYw6/oLrEvQz0xBrZkF0nZWe1k42GAPdTUxsf69gg Ru3qY7HB3e8jyQLWsS/WMQK5s8Rjo6SChvAer8EedAh5pAfg40P2/FDG3AnCwAZrBGLkXZIjjnrRk MYp541PFQNk7xCyPwN5UphDfgIHf9tI6zVrmKx8aRRLNhAzF/FUlO6RejNeI3sAB/kk164yIGMXoB JRHDh40kzxbQ8qAbm/lF+kpzPM/VZ3Ipv3JEWD8hLjsD9eACfWo9onfYxtEkq55oG4zRONoLIyuT6 fon4VQ8JPDP5PS2J9fdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mg8KU-008aES-DN; Thu, 28 Oct 2021 16:32:38 +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 1mg8KQ-008aDj-HI for linux-arm-kernel@lists.infradead.org; Thu, 28 Oct 2021 16:32:35 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A93D608FE; Thu, 28 Oct 2021 16:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635438753; bh=JJQNrtRXm/AaGdduldmULf1PP9rl3y3DUvRqc6RCwII=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hg3qd4gVoggracmpzNwnK9PvS5XKq67+1/Q176iHGAQlH0GqHifAfTBe5EtA88DDM iRgXXvEvALZKeC7v2VqNGVIfSj3O6X/ykycc/Him73jaBfsE4rrk5A6HBZBMici0Ig 0aVH54X/tRcJw3HvnbJ537DC62DBz54C8ww2KEcr/7CJ394wV8P4/R9y1zqP3kASGc iqjq5lzX1gD7/cWsz/WiznFPLmJfhCCHBuABAEeGYtqO9ISVt+JCyUXNP/FdOwhP1I +1ncjXLkw1tqBe2TxiZ54fhSnhyiNatUaojMR6nBZ4bvByqTnMGPQGdQVXb9t2f3QN 28FEkTWMxVujA== Date: Thu, 28 Oct 2021 09:32:29 -0700 From: Nathan Chancellor To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, arnd@arndb.de, ndesaulniers@google.com, keescook@chromium.org Subject: Re: [PATCH] ARM: Thumb2: avoid __builtin_thread_pointer() on Clang Message-ID: References: <20211028083527.1057158-1-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211028083527.1057158-1-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211028_093234_619962_B56046E8 X-CRM114-Status: GOOD ( 22.66 ) 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 On Thu, Oct 28, 2021 at 10:35:27AM +0200, Ard Biesheuvel wrote: > 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 Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor > --- > 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