All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
To: James Morse <james.morse-5wv7dgnIgG8@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	kvmarm-FPEHb7Xf0XXUo1n7N8X6UoWGPAHP3yOg@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
	Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>,
	Christoffer Dall
	<christoffer.dall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Lorenzo Pieralisi
	<lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>,
	Loc Ho <lho-qTEPVZfXA3Y@public.gmane.org>,
	Heyi Guo <guoheyi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v5 08/16] arm64: Add vmap_stack header file
Date: Thu, 7 Dec 2017 10:54:06 +0000	[thread overview]
Message-ID: <20171207105405.n2uxzi5dtbw2435e@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20171206190142.9246-9-james.morse-5wv7dgnIgG8@public.gmane.org>

Hi James,

On Wed, Dec 06, 2017 at 07:01:34PM +0000, James Morse wrote:
> 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-5wv7dgnIgG8@public.gmane.org>
> Reviewed-by: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>
> ---
> 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 | 26 ++++++++++++++++++++++++++
>  arch/arm64/kernel/irq.c             | 13 ++-----------
>  2 files changed, 28 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..5465e4e65987
> --- /dev/null
> +++ b/arch/arm64/include/asm/vmap_stack.h
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2017 Arm Ltd.
> +#ifndef __ASM_VMAP_STACK_H
> +#define __ASM_VMAP_STACK_H
> +
> +#include <linux/gfp.h>
> +#include <linux/vmalloc.h>
> +#include <asm/memory.h>
> +#include <asm/pgtable.h>
> +#include <asm/thread_info.h>

I think we also need:

#include <linux/bug.h>		// for BUILD_BUG_ON()
#incldue <linux/kconfig.h>	// for IS_ENABLED()

Otherwise, this looks good to me. With those includes folded in:

Reviewed-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>

Thanks,
Mark.

> +
> +/*
> + * 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 08/16] arm64: Add vmap_stack header file
Date: Thu, 7 Dec 2017 10:54:06 +0000	[thread overview]
Message-ID: <20171207105405.n2uxzi5dtbw2435e@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <20171206190142.9246-9-james.morse@arm.com>

Hi James,

On Wed, Dec 06, 2017 at 07:01:34PM +0000, James Morse wrote:
> 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>
> ---
> 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 | 26 ++++++++++++++++++++++++++
>  arch/arm64/kernel/irq.c             | 13 ++-----------
>  2 files changed, 28 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..5465e4e65987
> --- /dev/null
> +++ b/arch/arm64/include/asm/vmap_stack.h
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2017 Arm Ltd.
> +#ifndef __ASM_VMAP_STACK_H
> +#define __ASM_VMAP_STACK_H
> +
> +#include <linux/gfp.h>
> +#include <linux/vmalloc.h>
> +#include <asm/memory.h>
> +#include <asm/pgtable.h>
> +#include <asm/thread_info.h>

I think we also need:

#include <linux/bug.h>		// for BUILD_BUG_ON()
#incldue <linux/kconfig.h>	// for IS_ENABLED()

Otherwise, this looks good to me. With those includes folded in:

Reviewed-by: Mark Rutland <mark.rutland@arm.com>

Thanks,
Mark.

> +
> +/*
> + * 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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-12-07 10:54 UTC|newest]

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

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=20171207105405.n2uxzi5dtbw2435e@lakrids.cambridge.arm.com \
    --to=mark.rutland-5wv7dgnigg8@public.gmane.org \
    --cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
    --cc=christoffer.dall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=guoheyi-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=james.morse-5wv7dgnIgG8@public.gmane.org \
    --cc=kvmarm-FPEHb7Xf0XXUo1n7N8X6UoWGPAHP3yOg@public.gmane.org \
    --cc=lho-qTEPVZfXA3Y@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org \
    --cc=marc.zyngier-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.