xref: /openbmc/linux/arch/powerpc/include/asm/kasan.h (revision 5497b23e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_KASAN_H
3 #define __ASM_KASAN_H
4 
5 #ifdef CONFIG_KASAN
6 #define _GLOBAL_KASAN(fn)	_GLOBAL(__##fn)
7 #define _GLOBAL_TOC_KASAN(fn)	_GLOBAL_TOC(__##fn)
8 #define EXPORT_SYMBOL_KASAN(fn)	EXPORT_SYMBOL(__##fn)
9 #else
10 #define _GLOBAL_KASAN(fn)	_GLOBAL(fn)
11 #define _GLOBAL_TOC_KASAN(fn)	_GLOBAL_TOC(fn)
12 #define EXPORT_SYMBOL_KASAN(fn)
13 #endif
14 
15 #ifndef __ASSEMBLY__
16 
17 #include <asm/page.h>
18 #include <linux/sizes.h>
19 
20 #define KASAN_SHADOW_SCALE_SHIFT	3
21 
22 #if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_MODULES) && defined(CONFIG_STRICT_KERNEL_RWX)
23 #define KASAN_KERN_START	ALIGN_DOWN(PAGE_OFFSET - SZ_256M, SZ_256M)
24 #else
25 #define KASAN_KERN_START	PAGE_OFFSET
26 #endif
27 
28 #define KASAN_SHADOW_START	(KASAN_SHADOW_OFFSET + \
29 				 (KASAN_KERN_START >> KASAN_SHADOW_SCALE_SHIFT))
30 
31 #define KASAN_SHADOW_OFFSET	ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET)
32 
33 #define KASAN_SHADOW_END	(-(-KASAN_SHADOW_START >> KASAN_SHADOW_SCALE_SHIFT))
34 
35 #ifdef CONFIG_KASAN
36 void kasan_early_init(void);
37 void kasan_mmu_init(void);
38 void kasan_init(void);
39 void kasan_late_init(void);
40 #else
41 static inline void kasan_init(void) { }
42 static inline void kasan_mmu_init(void) { }
43 static inline void kasan_late_init(void) { }
44 #endif
45 
46 void kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t pte);
47 int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end);
48 int kasan_init_region(void *start, size_t size);
49 
50 #endif /* __ASSEMBLY */
51 #endif
52