devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: devicetree@vger.kernel.org,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Rob Herring <robh+dt@kernel.org>, Loc Ho <lho@apm.com>,
	Heyi Guo <guoheyi@huawei.com>,
	kvmarm@lists.cs.columbia.edu
Subject: [PATCH v6 08/16] arm64: Add vmap_stack header file
Date: Mon,  8 Jan 2018 15:38:10 +0000	[thread overview]
Message-ID: <20180108153818.22743-9-james.morse@arm.com> (raw)
In-Reply-To: <20180108153818.22743-1-james.morse@arm.com>

Today the arm64 arch code allocates an extra IRQ stack per-cpu. If we
also have SDEI and VMAP stacks we need two extra per-cpu VMAP stacks.

Move the VMAP stack allocation out to a helper in a new header file.
This avoids missing THREADINFO_GFP, or getting the all-important alignment
wrong.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
---
Changes since v5:
 * Added two required header files

Changes since v4:
 * Added gfp.h include

Changes since v3:
 * Added BUILD_BUG() instead of a spooky link error

 arch/arm64/include/asm/vmap_stack.h | 28 ++++++++++++++++++++++++++++
 arch/arm64/kernel/irq.c             | 13 ++-----------
 2 files changed, 30 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm64/include/asm/vmap_stack.h

diff --git a/arch/arm64/include/asm/vmap_stack.h b/arch/arm64/include/asm/vmap_stack.h
new file mode 100644
index 000000000000..0b5ec6e08c10
--- /dev/null
+++ b/arch/arm64/include/asm/vmap_stack.h
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2017 Arm Ltd.
+#ifndef __ASM_VMAP_STACK_H
+#define __ASM_VMAP_STACK_H
+
+#include <linux/bug.h>
+#include <linux/gfp.h>
+#include <linux/kconfig.h>
+#include <linux/vmalloc.h>
+#include <asm/memory.h>
+#include <asm/pgtable.h>
+#include <asm/thread_info.h>
+
+/*
+ * To ensure that VMAP'd stack overflow detection works correctly, all VMAP'd
+ * stacks need to have the same alignment.
+ */
+static inline unsigned long *arch_alloc_vmap_stack(size_t stack_size, int node)
+{
+	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));
+
+	return __vmalloc_node_range(stack_size, THREAD_ALIGN,
+				    VMALLOC_START, VMALLOC_END,
+				    THREADINFO_GFP, PAGE_KERNEL, 0, node,
+				    __builtin_return_address(0));
+}
+
+#endif /* __ASM_VMAP_STACK_H */
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 713561e5bcab..60e5fc661f74 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -29,6 +29,7 @@
 #include <linux/irqchip.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
+#include <asm/vmap_stack.h>
 
 unsigned long irq_err_count;
 
@@ -58,17 +59,7 @@ static void init_irq_stacks(void)
 	unsigned long *p;
 
 	for_each_possible_cpu(cpu) {
-		/*
-		* To ensure that VMAP'd stack overflow detection works
-		* correctly, the IRQ stacks need to have the same
-		* alignment as other stacks.
-		*/
-		p = __vmalloc_node_range(IRQ_STACK_SIZE, THREAD_ALIGN,
-					 VMALLOC_START, VMALLOC_END,
-					 THREADINFO_GFP, PAGE_KERNEL,
-					 0, cpu_to_node(cpu),
-					 __builtin_return_address(0));
-
+		p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, cpu_to_node(cpu));
 		per_cpu(irq_stack_ptr, cpu) = p;
 	}
 }
-- 
2.15.0

  reply	other threads:[~2018-01-08 15:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 15:38 [PATCH v6 00/16] arm64/firmware: Software Delegated Exception Interface James Morse
2018-01-08 15:38 ` James Morse [this message]
     [not found] ` <20180108153818.22743-1-james.morse-5wv7dgnIgG8@public.gmane.org>
2018-01-08 15:38   ` [PATCH v6 01/16] KVM: arm64: Store vcpu on the stack during __guest_enter() James Morse
2018-01-08 15:38   ` [PATCH v6 02/16] KVM: arm/arm64: Convert kvm_host_cpu_state to a static per-cpu allocation James Morse
2018-01-08 15:38   ` [PATCH v6 03/16] KVM: arm64: Change hyp_panic()s dependency on tpidr_el2 James Morse
2018-01-08 15:38   ` [PATCH v6 04/16] arm64: alternatives: use tpidr_el2 on VHE hosts James Morse
2018-01-08 15:38   ` [PATCH v6 05/16] KVM: arm64: Stop save/restoring host tpidr_el1 on VHE James Morse
2018-01-08 15:38   ` [PATCH v6 06/16] Docs: dt: add devicetree binding for describing arm64 SDEI firmware James Morse
2018-01-08 15:38   ` [PATCH v6 07/16] firmware: arm_sdei: Add driver for Software Delegated Exceptions James Morse
2018-01-08 15:38   ` [PATCH v6 09/16] arm64: uaccess: Add PAN helper James Morse
2018-01-08 15:38   ` [PATCH v6 10/16] arm64: kernel: Add arch-specific SDEI entry code and CPU masking James Morse
2018-01-08 15:38   ` [PATCH v6 12/16] firmware: arm_sdei: add support for CPU private events James Morse
2018-01-08 15:38   ` [PATCH v6 15/16] arm64: mmu: add the entry trampolines start/end section markers into sections.h James Morse
2018-01-08 15:38   ` [PATCH v6 16/16] arm64: sdei: Add trampoline code for remapping the kernel James Morse
2018-01-08 15:38 ` [PATCH v6 11/16] firmware: arm_sdei: Add support for CPU and system power states James Morse
     [not found]   ` <20180108153818.22743-12-james.morse-5wv7dgnIgG8@public.gmane.org>
2018-01-08 17:22     ` Lorenzo Pieralisi
2018-01-13 12:00       ` Catalin Marinas
2018-01-14 12:20         ` Lorenzo Pieralisi
2018-01-17 12:01           ` James Morse
2018-01-08 15:38 ` [PATCH v6 13/16] arm64: acpi: Remove __init from acpi_psci_use_hvc() for use by SDEI James Morse
2018-01-08 15:51   ` Lorenzo Pieralisi
2018-01-08 15:38 ` [PATCH v6 14/16] firmware: arm_sdei: Discover SDEI support via ACPI James Morse
     [not found]   ` <20180108153818.22743-15-james.morse-5wv7dgnIgG8@public.gmane.org>
2018-01-08 17:56     ` Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180108153818.22743-9-james.morse@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=guoheyi@huawei.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=lho@apm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=marc.zyngier@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).