1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 #ifndef __ASM_KASAN_H 3 #define __ASM_KASAN_H 4 5 #ifndef __ASSEMBLY__ 6 7 #include <linux/linkage.h> 8 #include <linux/mmzone.h> 9 #include <asm/addrspace.h> 10 #include <asm/io.h> 11 #include <asm/pgtable.h> 12 13 #define KASAN_SHADOW_SCALE_SHIFT 3 14 #define KASAN_SHADOW_OFFSET _AC(CONFIG_KAS 15 16 #define XRANGE_SHIFT (48) 17 18 /* Valid address length */ 19 #define XRANGE_SHADOW_SHIFT (PGDIR_SHIFT + 20 /* Used for taking out the valid address */ 21 #define XRANGE_SHADOW_MASK GENMASK_ULL(XR 22 /* One segment whole address space size */ 23 #define XRANGE_SIZE (XRANGE_SHADOW 24 25 /* 64-bit segment value. */ 26 #define XKPRANGE_UC_SEG (0x8000) 27 #define XKPRANGE_CC_SEG (0x9000) 28 #define XKVRANGE_VC_SEG (0xffff) 29 30 /* Cached */ 31 #define XKPRANGE_CC_START CACHE_ 32 #define XKPRANGE_CC_SIZE XRANGE 33 #define XKPRANGE_CC_KASAN_OFFSET (0) 34 #define XKPRANGE_CC_SHADOW_SIZE (XKPRA 35 #define XKPRANGE_CC_SHADOW_END (XKPRA 36 37 /* UnCached */ 38 #define XKPRANGE_UC_START UNCACH 39 #define XKPRANGE_UC_SIZE XRANGE 40 #define XKPRANGE_UC_KASAN_OFFSET XKPRAN 41 #define XKPRANGE_UC_SHADOW_SIZE (XKPRA 42 #define XKPRANGE_UC_SHADOW_END (XKPRA 43 44 /* VMALLOC (Cached or UnCached) */ 45 #define XKVRANGE_VC_START MODULE 46 #define XKVRANGE_VC_SIZE round_ 47 #define XKVRANGE_VC_KASAN_OFFSET XKPRAN 48 #define XKVRANGE_VC_SHADOW_SIZE (XKVRA 49 #define XKVRANGE_VC_SHADOW_END (XKVRA 50 51 /* KAsan shadow memory start right after vmall 52 #define KASAN_SHADOW_START round_ 53 #define KASAN_SHADOW_SIZE (XKVRA 54 #define KASAN_SHADOW_END round_ 55 56 #define XKPRANGE_CC_SHADOW_OFFSET (KASAN 57 #define XKPRANGE_UC_SHADOW_OFFSET (KASAN 58 #define XKVRANGE_VC_SHADOW_OFFSET (KASAN 59 60 extern bool kasan_early_stage; 61 extern unsigned char kasan_early_shadow_page[P 62 63 #define kasan_mem_to_shadow kasan_mem_to_shado 64 void *kasan_mem_to_shadow(const void *addr); 65 66 #define kasan_shadow_to_mem kasan_shadow_to_me 67 const void *kasan_shadow_to_mem(const void *sh 68 69 #define kasan_arch_is_ready kasan_arch_is_read 70 static __always_inline bool kasan_arch_is_read 71 { 72 return !kasan_early_stage; 73 } 74 75 #define addr_has_metadata addr_has_metadata 76 static __always_inline bool addr_has_metadata( 77 { 78 return (kasan_mem_to_shadow((void *)ad 79 } 80 81 void kasan_init(void); 82 asmlinkage void kasan_early_init(void); 83 84 #endif 85 #endif 86
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.