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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B691C4332F for ; Sat, 17 Dec 2022 00:13:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbiLQANi (ORCPT ); Fri, 16 Dec 2022 19:13:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbiLQAMd (ORCPT ); Fri, 16 Dec 2022 19:12:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348DB36D45; Fri, 16 Dec 2022 16:11:09 -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 C393C622C8; Sat, 17 Dec 2022 00:11:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 186B5C433D2; Sat, 17 Dec 2022 00:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671235868; bh=GGH++P1BIAxQRI2nLwZUP/1q16Czvf47MMs+3TpiWu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wnvoa80X19jLZDDSYkfq6IRur3AjmP3m/tPAu9Hkmdo0TVZbBgrwLFFZH5r8Gk35d eFTR5k0PvtUsLH7BxKWnn7frLDfGa8mC1YUV8XA9WfYDJZsVKqQAZvQNR9D2Un6pKY rkzA6D/aq0y/ZQRWTYAYQUW9A/7vcU8WFfl813F/xSF4DW61RHnSzEltcW2UoIyUe0 IBNdG66taUTo3t8jmwtyBNzMxjjZq85vylrh0AwYmGvFlWqAxUp6jYtOYc7kEsZQK4 zYCdma6sIoevSkchuapr9m8TPKKhMkEMjcpS5CLyj2ymkQzD+ymnVdeZOhG99YW+UZ J6/CWqyeIYp3w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Rutland , Catalin Marinas , Will Deacon , Sasha Levin , broonie@kernel.org, keescook@chromium.org, wangkefeng.wang@huawei.com, flaniel@linux.microsoft.com, christophe.leroy@csgroup.eu, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 2/5] arm64: make is_ttbrX_addr() noinstr-safe Date: Fri, 16 Dec 2022 19:10:54 -0500 Message-Id: <20221217001058.41426-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221217001058.41426-1-sashal@kernel.org> References: <20221217001058.41426-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Rutland [ Upstream commit d8c1d798a2e5091128c391c6dadcc9be334af3f5 ] We use is_ttbr0_addr() in noinstr code, but as it's only marked as inline, it's theoretically possible for the compiler to place it out-of-line and instrument it, which would be problematic. Mark is_ttbr0_addr() as __always_inline such that that can safely be used from noinstr code. For consistency, do the same to is_ttbr1_addr(). Note that while is_ttbr1_addr() calls arch_kasan_reset_tag(), this is a macro (and its callees are either macros or __always_inline), so there is not a risk of transient instrumentation. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon Link: https://lore.kernel.org/r/20221114144042.3001140-1-mark.rutland@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 7c546c3487c9..c628d8e3a403 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -230,13 +230,13 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc, } #endif -static inline bool is_ttbr0_addr(unsigned long addr) +static __always_inline bool is_ttbr0_addr(unsigned long addr) { /* entry assembly clears tags for TTBR0 addrs */ return addr < TASK_SIZE; } -static inline bool is_ttbr1_addr(unsigned long addr) +static __always_inline bool is_ttbr1_addr(unsigned long addr) { /* TTBR1 addresses may have a tag if KASAN_SW_TAGS is in use */ return arch_kasan_reset_tag(addr) >= PAGE_OFFSET; -- 2.35.1 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 27CBCC4332F for ; Sat, 17 Dec 2022 00:13:16 +0000 (UTC) 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=bnxp64bfLj07NUOOIGAzrZOi1uWBPALQpq8WSjo5h/k=; b=oy5w9peA9eexyg ifAvyGFLDz0smeXDDPLBQrkY5bj5StETTwYl+5l7wwBWzMWSzdHjhLB0uMYqW5Y9MJTbKtTW2gsLu 3LGd+3wlvjdIoDf8AgpooN/59ICjGR73/USriUDsRUrWLqbQdFqrVQXuBsZsXT8U9Y29eXgqtOt1j v69U8xZvIj3kYfUMtwPnYl/km6r3bx9y+J0lgR7Km53mJDIiLnpuMZDCHLJ9sOiCoTYZZNcATG89e jVAJqNbXYjryBXYFou2UrxnHzjxq2R1ui5umT98yMCs/j7Z8Cr3C6mc75Pp7co4+HKYHI9l8o50Ri tMiCJVVpbOfWdgnmoDSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p6KoG-0031sx-KM; Sat, 17 Dec 2022 00:12:12 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p6KnF-0031FI-9S for linux-arm-kernel@lists.infradead.org; Sat, 17 Dec 2022 00:11:11 +0000 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 C7048622D3; Sat, 17 Dec 2022 00:11:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 186B5C433D2; Sat, 17 Dec 2022 00:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671235868; bh=GGH++P1BIAxQRI2nLwZUP/1q16Czvf47MMs+3TpiWu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wnvoa80X19jLZDDSYkfq6IRur3AjmP3m/tPAu9Hkmdo0TVZbBgrwLFFZH5r8Gk35d eFTR5k0PvtUsLH7BxKWnn7frLDfGa8mC1YUV8XA9WfYDJZsVKqQAZvQNR9D2Un6pKY rkzA6D/aq0y/ZQRWTYAYQUW9A/7vcU8WFfl813F/xSF4DW61RHnSzEltcW2UoIyUe0 IBNdG66taUTo3t8jmwtyBNzMxjjZq85vylrh0AwYmGvFlWqAxUp6jYtOYc7kEsZQK4 zYCdma6sIoevSkchuapr9m8TPKKhMkEMjcpS5CLyj2ymkQzD+ymnVdeZOhG99YW+UZ J6/CWqyeIYp3w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Rutland , Catalin Marinas , Will Deacon , Sasha Levin , broonie@kernel.org, keescook@chromium.org, wangkefeng.wang@huawei.com, flaniel@linux.microsoft.com, christophe.leroy@csgroup.eu, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 2/5] arm64: make is_ttbrX_addr() noinstr-safe Date: Fri, 16 Dec 2022 19:10:54 -0500 Message-Id: <20221217001058.41426-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221217001058.41426-1-sashal@kernel.org> References: <20221217001058.41426-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221216_161109_512371_DF075BFA X-CRM114-Status: GOOD ( 12.49 ) 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 From: Mark Rutland [ Upstream commit d8c1d798a2e5091128c391c6dadcc9be334af3f5 ] We use is_ttbr0_addr() in noinstr code, but as it's only marked as inline, it's theoretically possible for the compiler to place it out-of-line and instrument it, which would be problematic. Mark is_ttbr0_addr() as __always_inline such that that can safely be used from noinstr code. For consistency, do the same to is_ttbr1_addr(). Note that while is_ttbr1_addr() calls arch_kasan_reset_tag(), this is a macro (and its callees are either macros or __always_inline), so there is not a risk of transient instrumentation. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon Link: https://lore.kernel.org/r/20221114144042.3001140-1-mark.rutland@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 7c546c3487c9..c628d8e3a403 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -230,13 +230,13 @@ static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc, } #endif -static inline bool is_ttbr0_addr(unsigned long addr) +static __always_inline bool is_ttbr0_addr(unsigned long addr) { /* entry assembly clears tags for TTBR0 addrs */ return addr < TASK_SIZE; } -static inline bool is_ttbr1_addr(unsigned long addr) +static __always_inline bool is_ttbr1_addr(unsigned long addr) { /* TTBR1 addresses may have a tag if KASAN_SW_TAGS is in use */ return arch_kasan_reset_tag(addr) >= PAGE_OFFSET; -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel