From patchwork Thu Nov 17 12:09:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13046684 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 58EF2C4332F for ; Thu, 17 Nov 2022 12:10:30 +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=jrEXa6KmaOE1PgivgfCgV27LZFzbDHGcPhX6bGB9D34=; b=qX8okGEkIkPRMP nYM4gs6pSWisnQtXu5is+h4yh4mMib2aEzN18nOt81quJquavMZY10J/uvFpRgXWS6lOgKm1/hXMY aexJ14gfJo0eW+/qE8Y+TbjT7Iq4yE7oP7bfJI9HCP9U1llj2BAvu8WNbSKO3yIPfEfNHwx79NTvK oB1SJkywVq9qw0tluIGfOpZAbjN2vfzjAWRY384wUJ8I4N7wrjsgFWhg/XJqulnldbX6PNuuzr01l AKn7IT9TUF0l5SbrwBfInYhJIwZuCMBNX2oIw053xATvafUxOqTkx5TNfBustrfQbFR0le66lFo5k WYbnRMVEBnuxWfnS/hbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovdi5-00DgiZ-4v; Thu, 17 Nov 2022 12:09:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovdhl-00Dge5-5w for linux-arm-kernel@lists.infradead.org; Thu, 17 Nov 2022 12:09:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4BB561477; Thu, 17 Nov 2022 04:09:21 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 319C43F663; Thu, 17 Nov 2022 04:09:14 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, keescook@chromium.org, mark.rutland@arm.com, will@kernel.org Subject: [PATCH 2/2] arm64: move on_thread_stack() to Date: Thu, 17 Nov 2022 12:09:02 +0000 Message-Id: <20221117120902.3974163-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221117120902.3974163-1-mark.rutland@arm.com> References: <20221117120902.3974163-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221117_040917_337896_1459160B X-CRM114-Status: GOOD ( 12.20 ) 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 Currently on_thread_stack() is defined in , depending upon definitiong from despite this header not being included. This ends up being fragile, and any user of on_thread_stack() must include both and . We organised things this way due to header dependencies back in commit: 0b3e336601b82c6a ("arm64: Add support for STACKLEAK gcc plugin") ... but now that we no longer use current_top_of_stack(), and given that stackleak includes via , we no longer need the definition to live in . Move on_thread_stack() to , where all its dependencies are guaranteed to be defined. This requires having arm64's irq.c explicitly include , and I've taken the opportunity to sort the includes, which were slightly out of order. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Kees Cook Cc: Will Deacon Reviewed-by: Mark Brown Reviewed-by: Kees Cook --- arch/arm64/include/asm/processor.h | 2 -- arch/arm64/include/asm/stacktrace.h | 2 ++ arch/arm64/kernel/irq.c | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index cf4eefaacafc..b15fd6c11294 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -396,7 +396,5 @@ long get_tagged_addr_ctrl(struct task_struct *task); #define GET_TAGGED_ADDR_CTRL() get_tagged_addr_ctrl(current) #endif -#define on_thread_stack() (on_task_stack(current, current_stack_pointer, 1)) - #endif /* __ASSEMBLY__ */ #endif /* __ASM_PROCESSOR_H */ diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index 5a0edb064ea4..4e5354beafb0 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h @@ -57,6 +57,8 @@ static inline bool on_task_stack(const struct task_struct *tsk, return stackinfo_on_stack(&info, sp, size); } +#define on_thread_stack() (on_task_stack(current, current_stack_pointer, 1)) + #ifdef CONFIG_VMAP_STACK DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack); diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index 38dbd3828f13..0c8e30ff8eaa 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -10,20 +10,21 @@ * Copyright (C) 2012 ARM Ltd. */ -#include -#include -#include #include #include +#include #include #include +#include #include #include +#include #include #include #include -#include #include +#include +#include /* Only access this in an NMI enter/exit */ DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);