blob: 71ad0f93eb7153226a43d78e909d3e7c3690bf92 [file] [log] [blame]
Andrey Ryabinin39d114d2015-10-12 18:52:58 +03001#ifndef __ASM_KASAN_H
2#define __ASM_KASAN_H
3
4#ifndef __ASSEMBLY__
5
6#ifdef CONFIG_KASAN
7
Will Deacon83040122015-10-13 14:01:06 +01008#include <linux/linkage.h>
Andrey Ryabinin39d114d2015-10-12 18:52:58 +03009#include <asm/memory.h>
Mark Rutland068a17a2016-01-25 11:45:12 +000010#include <asm/pgtable-types.h>
Andrey Ryabinin39d114d2015-10-12 18:52:58 +030011
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)
Ard Biesheuvelf9040772016-02-16 13:52:40 +010017#define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE)
Andrey Ryabinin39d114d2015-10-12 18:52:58 +030018
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
31void kasan_init(void);
Mark Rutland068a17a2016-01-25 11:45:12 +000032void kasan_copy_shadow(pgd_t *pgdir);
Will Deacon83040122015-10-13 14:01:06 +010033asmlinkage void kasan_early_init(void);
Andrey Ryabinin39d114d2015-10-12 18:52:58 +030034
35#else
36static inline void kasan_init(void) { }
Mark Rutland068a17a2016-01-25 11:45:12 +000037static inline void kasan_copy_shadow(pgd_t *pgdir) { }
Andrey Ryabinin39d114d2015-10-12 18:52:58 +030038#endif
39
40#endif
41#endif