kasan.h 1.0 KB

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