xref: /linux/arch/arm64/include/asm/kasan.h (revision 009f773836513960d3982e80c86e266d25528563)
1 #ifndef __ASM_KASAN_H
2 #define __ASM_KASAN_H
3 
4 #ifndef __ASSEMBLY__
5 
6 #ifdef CONFIG_KASAN
7 
8 #include <linux/linkage.h>
9 #include <asm/memory.h>
10 
11 /*
12  * KASAN_SHADOW_START: beginning of the kernel virtual addresses.
13  * KASAN_SHADOW_END: KASAN_SHADOW_START + 1/8 of kernel virtual addresses.
14  */
15 #define KASAN_SHADOW_START      (VA_START)
16 #define KASAN_SHADOW_END        (KASAN_SHADOW_START + (1UL << (VA_BITS - 3)))
17 
18 /*
19  * This value is used to map an address to the corresponding shadow
20  * address by the following formula:
21  *     shadow_addr = (address >> 3) + KASAN_SHADOW_OFFSET;
22  *
23  * (1 << 61) shadow addresses - [KASAN_SHADOW_OFFSET,KASAN_SHADOW_END]
24  * cover all 64-bits of virtual addresses. So KASAN_SHADOW_OFFSET
25  * should satisfy the following equation:
26  *      KASAN_SHADOW_OFFSET = KASAN_SHADOW_END - (1ULL << 61)
27  */
28 #define KASAN_SHADOW_OFFSET     (KASAN_SHADOW_END - (1ULL << (64 - 3)))
29 
30 void kasan_init(void);
31 asmlinkage void kasan_early_init(void);
32 
33 #else
34 static inline void kasan_init(void) { }
35 #endif
36 
37 #endif
38 #endif
39