~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/loongarch/include/asm/kasan.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  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_KASAN_SHADOW_OFFSET, UL)
 15 
 16 #define XRANGE_SHIFT (48)
 17 
 18 /* Valid address length */
 19 #define XRANGE_SHADOW_SHIFT     (PGDIR_SHIFT + PAGE_SHIFT - 3)
 20 /* Used for taking out the valid address */
 21 #define XRANGE_SHADOW_MASK      GENMASK_ULL(XRANGE_SHADOW_SHIFT - 1, 0)
 22 /* One segment whole address space size */
 23 #define XRANGE_SIZE             (XRANGE_SHADOW_MASK + 1)
 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_BASE
 32 #define XKPRANGE_CC_SIZE                XRANGE_SIZE
 33 #define XKPRANGE_CC_KASAN_OFFSET        (0)
 34 #define XKPRANGE_CC_SHADOW_SIZE         (XKPRANGE_CC_SIZE >> KASAN_SHADOW_SCALE_SHIFT)
 35 #define XKPRANGE_CC_SHADOW_END          (XKPRANGE_CC_KASAN_OFFSET + XKPRANGE_CC_SHADOW_SIZE)
 36 
 37 /* UnCached */
 38 #define XKPRANGE_UC_START               UNCACHE_BASE
 39 #define XKPRANGE_UC_SIZE                XRANGE_SIZE
 40 #define XKPRANGE_UC_KASAN_OFFSET        XKPRANGE_CC_SHADOW_END
 41 #define XKPRANGE_UC_SHADOW_SIZE         (XKPRANGE_UC_SIZE >> KASAN_SHADOW_SCALE_SHIFT)
 42 #define XKPRANGE_UC_SHADOW_END          (XKPRANGE_UC_KASAN_OFFSET + XKPRANGE_UC_SHADOW_SIZE)
 43 
 44 /* VMALLOC (Cached or UnCached)  */
 45 #define XKVRANGE_VC_START               MODULES_VADDR
 46 #define XKVRANGE_VC_SIZE                round_up(KFENCE_AREA_END - MODULES_VADDR + 1, PGDIR_SIZE)
 47 #define XKVRANGE_VC_KASAN_OFFSET        XKPRANGE_UC_SHADOW_END
 48 #define XKVRANGE_VC_SHADOW_SIZE         (XKVRANGE_VC_SIZE >> KASAN_SHADOW_SCALE_SHIFT)
 49 #define XKVRANGE_VC_SHADOW_END          (XKVRANGE_VC_KASAN_OFFSET + XKVRANGE_VC_SHADOW_SIZE)
 50 
 51 /* KAsan shadow memory start right after vmalloc. */
 52 #define KASAN_SHADOW_START              round_up(KFENCE_AREA_END, PGDIR_SIZE)
 53 #define KASAN_SHADOW_SIZE               (XKVRANGE_VC_SHADOW_END - XKPRANGE_CC_KASAN_OFFSET)
 54 #define KASAN_SHADOW_END                round_up(KASAN_SHADOW_START + KASAN_SHADOW_SIZE, PGDIR_SIZE)
 55 
 56 #define XKPRANGE_CC_SHADOW_OFFSET       (KASAN_SHADOW_START + XKPRANGE_CC_KASAN_OFFSET)
 57 #define XKPRANGE_UC_SHADOW_OFFSET       (KASAN_SHADOW_START + XKPRANGE_UC_KASAN_OFFSET)
 58 #define XKVRANGE_VC_SHADOW_OFFSET       (KASAN_SHADOW_START + XKVRANGE_VC_KASAN_OFFSET)
 59 
 60 extern bool kasan_early_stage;
 61 extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
 62 
 63 #define kasan_mem_to_shadow kasan_mem_to_shadow
 64 void *kasan_mem_to_shadow(const void *addr);
 65 
 66 #define kasan_shadow_to_mem kasan_shadow_to_mem
 67 const void *kasan_shadow_to_mem(const void *shadow_addr);
 68 
 69 #define kasan_arch_is_ready kasan_arch_is_ready
 70 static __always_inline bool kasan_arch_is_ready(void)
 71 {
 72         return !kasan_early_stage;
 73 }
 74 
 75 #define addr_has_metadata addr_has_metadata
 76 static __always_inline bool addr_has_metadata(const void *addr)
 77 {
 78         return (kasan_mem_to_shadow((void *)addr) != NULL);
 79 }
 80 
 81 void kasan_init(void);
 82 asmlinkage void kasan_early_init(void);
 83 
 84 #endif
 85 #endif
 86 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php