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