xref: /linux-6.15/arch/arm64/include/asm/vmap_stack.h (revision 51fb34de)
122e6c808SNishad Kamdar /* SPDX-License-Identifier: GPL-2.0 */
2ed8b20d4SJames Morse // Copyright (C) 2017 Arm Ltd.
3ed8b20d4SJames Morse #ifndef __ASM_VMAP_STACK_H
4ed8b20d4SJames Morse #define __ASM_VMAP_STACK_H
5ed8b20d4SJames Morse 
6ed8b20d4SJames Morse #include <linux/bug.h>
7ed8b20d4SJames Morse #include <linux/gfp.h>
8ed8b20d4SJames Morse #include <linux/kconfig.h>
9ed8b20d4SJames Morse #include <linux/vmalloc.h>
10ca5999fdSMike Rapoport #include <linux/pgtable.h>
1165fddcfcSMike Rapoport #include <asm/memory.h>
12ed8b20d4SJames Morse #include <asm/thread_info.h>
13ed8b20d4SJames Morse 
14ed8b20d4SJames Morse /*
15ed8b20d4SJames Morse  * To ensure that VMAP'd stack overflow detection works correctly, all VMAP'd
16ed8b20d4SJames Morse  * stacks need to have the same alignment.
17ed8b20d4SJames Morse  */
arch_alloc_vmap_stack(size_t stack_size,int node)18ed8b20d4SJames Morse static inline unsigned long *arch_alloc_vmap_stack(size_t stack_size, int node)
19ed8b20d4SJames Morse {
20*51fb34deSAndrey Konovalov 	void *p;
21*51fb34deSAndrey Konovalov 
22ed8b20d4SJames Morse 	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));
23ed8b20d4SJames Morse 
24*51fb34deSAndrey Konovalov 	p = __vmalloc_node(stack_size, THREAD_ALIGN, THREADINFO_GFP, node,
25ed8b20d4SJames Morse 			__builtin_return_address(0));
26*51fb34deSAndrey Konovalov 	return kasan_reset_tag(p);
27ed8b20d4SJames Morse }
28ed8b20d4SJames Morse 
29ed8b20d4SJames Morse #endif /* __ASM_VMAP_STACK_H */
30