From patchwork Mon Aug 7 18:35:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 109587 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1952692qge; Mon, 7 Aug 2017 11:38:30 -0700 (PDT) X-Received: by 10.98.245.20 with SMTP id n20mr1584215pfh.46.1502131110030; Mon, 07 Aug 2017 11:38:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502131110; cv=none; d=google.com; s=arc-20160816; b=g0QIEoB487OT9wpbXSD24F+cXFr3nKdHzubrUW7hex3+K09VE1erwZyz2TGPjZ8ZCh hHmE2XtLDnkKMwfPFiZ/S9hS1T4VyX8qK0lRda7D65BiLxinlJIGvyS8GELEVa5jaz36 llBJweIjizGgJS90n+4PTQhaC0MFee0RhWsS1Zhe/EggQcnUUXsB8GSpWecUcCIRtagN UvsY0IlUql328eukA4ihZJtslpeZjqgXkt2Red20NHZw9Klub/aUGVNyhucBe4dDz/05 +q5Rw9+vtf/0VuEVjA/aBILwjAdvRddE/QE/uP20uWlXHuEXRsvFEeggOZYjEjecqzG+ f8tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rpxYGujq7JZgNvn32iBo2ddGsB4dn4smHUwCuhgxPEw=; b=a1FeCL7nuXzvDqqOflrXTkQ4X93ZdSKOMxdZbl00pPqSRkZIYzZsZcJqV09plJWI28 e0wKAgNVXlVuiDXyLq8grvuEtsez7xyD8hpzJVbhP9i4rFdPr8aNnKrK/JJR9t2r58LQ YN6e1tHC5O2ajwU7goKT0UP1awiLx4ujEjD8qArEAJq5vSLsE5T9A6HaoEM3A6pJuCG2 3VYGEFt68mkozW7x7mWUuDoSDpEFNkCt9pBA4tcJG5Q8UmEwxbuXIR3vV8dImHiLAQ9E eoWzYlxyfNXzDQPhSvDO3wKfUW25uRBkuTLoZL9lDufKaFYTd0QpOWoDyeM055o6GqBq zsjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si4879932pgc.821.2017.08.07.11.38.29; Mon, 07 Aug 2017 11:38:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752123AbdHGSi1 (ORCPT + 25 others); Mon, 7 Aug 2017 14:38:27 -0400 Received: from foss.arm.com ([217.140.101.70]:52610 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752069AbdHGSiX (ORCPT ); Mon, 7 Aug 2017 14:38:23 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7C850168F; Mon, 7 Aug 2017 11:38:23 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 69F033F577; Mon, 7 Aug 2017 11:38:21 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ard.biesheuvel@linaro.org, catalin.marinas@arm.com, james.morse@arm.com, labbott@redhat.com, linux-kernel@vger.kernel.org, luto@amacapital.net, mark.rutland@arm.com, matt@codeblueprint.co.uk, will.deacon@arm.com, kernel-hardening@lists.openwall.com, keescook@chromium.org Subject: [PATCH 06/14] arm64: clean up irq stack definitions Date: Mon, 7 Aug 2017 19:35:57 +0100 Message-Id: <1502130965-18710-7-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502130965-18710-1-git-send-email-mark.rutland@arm.com> References: <1502130965-18710-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before we add yet another stack to the kernel, it would be nice to ensure that we consistently organise stack definitions and related helper functions. This patch moves the basic IRQ stack defintions to to live with their task stack counterparts. Helpers used for unwinding are moved into , where subsequent patches will add helpers for other stacks. Includes are fixed up accordingly. This patch is a pure refactoring -- there should be no functional changes as a result of this patch. Signed-off-by: Mark Rutland Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Cc: Laura Abbott Cc: Will Deacon --- arch/arm64/include/asm/irq.h | 24 ------------------------ arch/arm64/include/asm/memory.h | 2 ++ arch/arm64/include/asm/stacktrace.h | 25 ++++++++++++++++++++++++- arch/arm64/kernel/ptrace.c | 1 + 4 files changed, 27 insertions(+), 25 deletions(-) -- 1.9.1 diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index 1ebe202..5e6f772 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -1,20 +1,12 @@ #ifndef __ASM_IRQ_H #define __ASM_IRQ_H -#define IRQ_STACK_SIZE THREAD_SIZE - #ifndef __ASSEMBLER__ -#include -#include - #include -#include struct pt_regs; -DECLARE_PER_CPU(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack); - extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); static inline int nr_legacy_irqs(void) @@ -22,21 +14,5 @@ static inline int nr_legacy_irqs(void) return 0; } -static inline bool on_irq_stack(unsigned long sp) -{ - unsigned long low = (unsigned long)raw_cpu_ptr(irq_stack); - unsigned long high = low + IRQ_STACK_SIZE; - - return (low <= sp && sp < high); -} - -static inline bool on_task_stack(struct task_struct *tsk, unsigned long sp) -{ - unsigned long low = (unsigned long)task_stack_page(tsk); - unsigned long high = low + THREAD_SIZE; - - return (low <= sp && sp < high); -} - #endif /* !__ASSEMBLER__ */ #endif diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 8ab4774..1fc2453 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -110,6 +110,8 @@ #define THREAD_SIZE (UL(1) << THREAD_SHIFT) +#define IRQ_STACK_SIZE THREAD_SIZE + /* * Memory types available. */ diff --git a/arch/arm64/include/asm/stacktrace.h b/arch/arm64/include/asm/stacktrace.h index 3bebab3..000e2418 100644 --- a/arch/arm64/include/asm/stacktrace.h +++ b/arch/arm64/include/asm/stacktrace.h @@ -16,7 +16,12 @@ #ifndef __ASM_STACKTRACE_H #define __ASM_STACKTRACE_H -struct task_struct; +#include +#include +#include + +#include +#include struct stackframe { unsigned long fp; @@ -31,4 +36,22 @@ extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame, int (*fn)(struct stackframe *, void *), void *data); extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk); +DECLARE_PER_CPU(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack); + +static inline bool on_irq_stack(unsigned long sp) +{ + unsigned long low = (unsigned long)raw_cpu_ptr(irq_stack); + unsigned long high = low + IRQ_STACK_SIZE; + + return (low <= sp && sp < high); +} + +static inline bool on_task_stack(struct task_struct *tsk, unsigned long sp) +{ + unsigned long low = (unsigned long)task_stack_page(tsk); + unsigned long high = low + THREAD_SIZE; + + return (low <= sp && sp < high); +} + #endif /* __ASM_STACKTRACE_H */ diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index baf0838..a9f8715 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include