Andrey Ryabinin | 39d114d | 2015-10-12 18:52:58 +0300 | [diff] [blame] | 1 | #ifndef __ASM_KASAN_H |
| 2 | #define __ASM_KASAN_H |
| 3 | |
| 4 | #ifndef __ASSEMBLY__ |
| 5 | |
| 6 | #ifdef CONFIG_KASAN |
| 7 | |
Will Deacon | 8304012 | 2015-10-13 14:01:06 +0100 | [diff] [blame] | 8 | #include <linux/linkage.h> |
Andrey Ryabinin | 39d114d | 2015-10-12 18:52:58 +0300 | [diff] [blame] | 9 | #include <asm/memory.h> |
Mark Rutland | 068a17a | 2016-01-25 11:45:12 +0000 | [diff] [blame^] | 10 | #include <asm/pgtable-types.h> |
Andrey Ryabinin | 39d114d | 2015-10-12 18:52:58 +0300 | [diff] [blame] | 11 | |
| 12 | /* |
| 13 | * KASAN_SHADOW_START: beginning of the kernel virtual addresses. |
| 14 | * KASAN_SHADOW_END: KASAN_SHADOW_START + 1/8 of kernel virtual addresses. |
| 15 | */ |
| 16 | #define KASAN_SHADOW_START (VA_START) |
| 17 | #define KASAN_SHADOW_END (KASAN_SHADOW_START + (1UL << (VA_BITS - 3))) |
| 18 | |
| 19 | /* |
| 20 | * This value is used to map an address to the corresponding shadow |
| 21 | * address by the following formula: |
| 22 | * shadow_addr = (address >> 3) + KASAN_SHADOW_OFFSET; |
| 23 | * |
| 24 | * (1 << 61) shadow addresses - [KASAN_SHADOW_OFFSET,KASAN_SHADOW_END] |
| 25 | * cover all 64-bits of virtual addresses. So KASAN_SHADOW_OFFSET |
| 26 | * should satisfy the following equation: |
| 27 | * KASAN_SHADOW_OFFSET = KASAN_SHADOW_END - (1ULL << 61) |
| 28 | */ |
| 29 | #define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << (64 - 3))) |
| 30 | |
| 31 | void kasan_init(void); |
Mark Rutland | 068a17a | 2016-01-25 11:45:12 +0000 | [diff] [blame^] | 32 | void kasan_copy_shadow(pgd_t *pgdir); |
Will Deacon | 8304012 | 2015-10-13 14:01:06 +0100 | [diff] [blame] | 33 | asmlinkage void kasan_early_init(void); |
Andrey Ryabinin | 39d114d | 2015-10-12 18:52:58 +0300 | [diff] [blame] | 34 | |
| 35 | #else |
| 36 | static inline void kasan_init(void) { } |
Mark Rutland | 068a17a | 2016-01-25 11:45:12 +0000 | [diff] [blame^] | 37 | static inline void kasan_copy_shadow(pgd_t *pgdir) { } |
Andrey Ryabinin | 39d114d | 2015-10-12 18:52:58 +0300 | [diff] [blame] | 38 | #endif |
| 39 | |
| 40 | #endif |
| 41 | #endif |