linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Clément Léger" <cleger@rivosinc.com>
To: guoren@kernel.org, arnd@arndb.de, palmer@rivosinc.com,
	conor.dooley@microchip.com, heiko@sntech.de, jszhang@kernel.org,
	bjorn@kernel.org, greentime.hu@sifive.com,
	vincent.chen@sifive.com, andy.chiu@sifive.com,
	paul.walmsley@sifive.com
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org,
	Guo Ren <guoren@linux.alibaba.com>
Subject: Re: [PATCH -next V12 1/3] riscv: stack: Support HAVE_IRQ_EXIT_ON_IRQ_STACK
Date: Tue, 13 Jun 2023 15:01:07 +0200	[thread overview]
Message-ID: <f686f36b-4c09-5099-3ba4-90f87f914654@rivosinc.com> (raw)
In-Reply-To: <20230529084600.2878130-2-guoren@kernel.org>



On 29/05/2023 10:45, guoren@kernel.org wrote:
> From: Guo Ren <guoren@linux.alibaba.com>
> 
> Add independent irq stacks for percpu to prevent kernel stack overflows.
> It is also compatible with VMAP_STACK by arch_alloc_vmap_stack.
> 
> Tested-by: Jisheng Zhang <jszhang@kernel.org>
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Signed-off-by: Guo Ren <guoren@kernel.org>
> Cc: Conor Dooley <conor.dooley@microchip.com>
> ---
>   arch/riscv/Kconfig                   |  7 ++++++
>   arch/riscv/include/asm/irq_stack.h   | 32 +++++++++++++++++++++++++
>   arch/riscv/include/asm/thread_info.h |  2 ++
>   arch/riscv/kernel/irq.c              | 33 ++++++++++++++++++++++++++
>   arch/riscv/kernel/traps.c            | 35 ++++++++++++++++++++++++++--
>   5 files changed, 107 insertions(+), 2 deletions(-)
>   create mode 100644 arch/riscv/include/asm/irq_stack.h
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index fa256f2e23c1..44b4c9690f94 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -588,6 +588,13 @@ config FPU
>   
>   	  If you don't know what to do here, say Y.
>   
> +config IRQ_STACKS
> +	bool "Independent irq stacks" if EXPERT
> +	default y
> +	select HAVE_IRQ_EXIT_ON_IRQ_STACK
> +	help
> +	  Add independent irq stacks for percpu to prevent kernel stack overflows.
> +
>   endmenu # "Platform type"
>   
>   menu "Kernel features"
> diff --git a/arch/riscv/include/asm/irq_stack.h b/arch/riscv/include/asm/irq_stack.h
> new file mode 100644
> index 000000000000..b0dcee9a3fa2
> --- /dev/null
> +++ b/arch/riscv/include/asm/irq_stack.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _ASM_RISCV_IRQ_STACK_H
> +#define _ASM_RISCV_IRQ_STACK_H
> +
> +#include <linux/bug.h>
> +#include <linux/gfp.h>
> +#include <linux/kconfig.h>
> +#include <linux/vmalloc.h>
> +#include <linux/pgtable.h>
> +#include <asm/thread_info.h>
> +
> +DECLARE_PER_CPU(ulong *, irq_stack_ptr);
> +
> +#ifdef CONFIG_VMAP_STACK
> +/*
> + * 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)
> +{
> +	void *p;
> +
> +	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));

Hi Guo,

Since this function is already guarded with #ifdef CONFIG_VMAP_STACK, I 
guess this BUILD_BUG_ON() is unnecessary).

Clément

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-06-13 13:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29  8:45 [PATCH -next V12 0/3] riscv: Add independent irq/softirq stacks guoren
2023-05-29  8:45 ` [PATCH -next V12 1/3] riscv: stack: Support HAVE_IRQ_EXIT_ON_IRQ_STACK guoren
2023-06-13 13:01   ` Clément Léger [this message]
2023-06-13 15:21     ` Guo Ren
2023-05-29  8:45 ` [PATCH -next V12 2/3] riscv: stack: Support HAVE_SOFTIRQ_ON_OWN_STACK guoren
2023-05-29  8:46 ` [PATCH -next V12 3/3] riscv: stack: Add config of thread stack size guoren

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=f686f36b-4c09-5099-3ba4-90f87f914654@rivosinc.com \
    --to=cleger@rivosinc.com \
    --cc=andy.chiu@sifive.com \
    --cc=arnd@arndb.de \
    --cc=bjorn@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=greentime.hu@sifive.com \
    --cc=guoren@kernel.org \
    --cc=guoren@linux.alibaba.com \
    --cc=heiko@sntech.de \
    --cc=jszhang@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=vincent.chen@sifive.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).