xref: /openbmc/linux/arch/um/include/asm/kasan.h (revision 2a598d0b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_UM_KASAN_H
3 #define __ASM_UM_KASAN_H
4 
5 #include <linux/init.h>
6 #include <linux/const.h>
7 
8 #define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
9 
10 /* used in kasan_mem_to_shadow to divide by 8 */
11 #define KASAN_SHADOW_SCALE_SHIFT 3
12 
13 #ifdef CONFIG_X86_64
14 #define KASAN_HOST_USER_SPACE_END_ADDR 0x00007fffffffffffUL
15 /* KASAN_SHADOW_SIZE is the size of total address space divided by 8 */
16 #define KASAN_SHADOW_SIZE ((KASAN_HOST_USER_SPACE_END_ADDR + 1) >> \
17 			KASAN_SHADOW_SCALE_SHIFT)
18 #else
19 #error "KASAN_SHADOW_SIZE is not defined for this sub-architecture"
20 #endif /* CONFIG_X86_64 */
21 
22 #define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET)
23 #define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE)
24 
25 #ifdef CONFIG_KASAN
26 void kasan_init(void);
27 void kasan_map_memory(void *start, unsigned long len);
28 extern int kasan_um_is_ready;
29 
30 #ifdef CONFIG_STATIC_LINK
31 #define kasan_arch_is_ready() (kasan_um_is_ready)
32 #endif
33 #else
34 static inline void kasan_init(void) { }
35 #endif /* CONFIG_KASAN */
36 
37 #endif /* __ASM_UM_KASAN_H */
38