1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef _ASM_RISCV_IRQ_STACK_H
4#define _ASM_RISCV_IRQ_STACK_H
5
6#include <linux/bug.h>
7#include <linux/gfp.h>
8#include <linux/kconfig.h>
9#include <linux/vmalloc.h>
10#include <linux/pgtable.h>
11#include <asm/thread_info.h>
12
13DECLARE_PER_CPU(ulong *, irq_stack_ptr);
14
15asmlinkage void call_on_irq_stack(struct pt_regs *regs,
16				  void (*func)(struct pt_regs *));
17
18#ifdef CONFIG_VMAP_STACK
19/*
20 * To ensure that VMAP'd stack overflow detection works correctly, all VMAP'd
21 * stacks need to have the same alignment.
22 */
23static inline unsigned long *arch_alloc_vmap_stack(size_t stack_size, int node)
24{
25	void *p;
26
27	p = __vmalloc_node(stack_size, THREAD_ALIGN, THREADINFO_GFP, node,
28			__builtin_return_address(0));
29	return kasan_reset_tag(p);
30}
31#endif /* CONFIG_VMAP_STACK */
32
33#endif /* _ASM_RISCV_IRQ_STACK_H */
34