kasan.h 1.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
A
Andrey Ryabinin 已提交
2 3 4
#ifndef _ASM_X86_KASAN_H
#define _ASM_X86_KASAN_H

5 6
#include <linux/const.h>
#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
7
#define KASAN_SHADOW_SCALE_SHIFT 3
8

A
Andrey Ryabinin 已提交
9 10 11 12 13 14 15
/*
 * Compiler uses shadow offset assuming that addresses start
 * from 0. Kernel addresses don't start from 0, so shadow
 * for kernel really starts from compiler's shadow offset +
 * 'kernel address space start' >> KASAN_SHADOW_SCALE_SHIFT
 */
#define KASAN_SHADOW_START      (KASAN_SHADOW_OFFSET + \
16 17
					((-1UL << __VIRTUAL_MASK_SHIFT) >> \
						KASAN_SHADOW_SCALE_SHIFT))
18
/*
19 20
 * 47 bits for kernel address -> (47 - KASAN_SHADOW_SCALE_SHIFT) bits for shadow
 * 56 bits for kernel address -> (56 - KASAN_SHADOW_SCALE_SHIFT) bits for shadow
21
 */
22 23 24
#define KASAN_SHADOW_END        (KASAN_SHADOW_START + \
					(1ULL << (__VIRTUAL_MASK_SHIFT - \
						  KASAN_SHADOW_SCALE_SHIFT)))
A
Andrey Ryabinin 已提交
25 26 27 28

#ifndef __ASSEMBLY__

#ifdef CONFIG_KASAN
29
void __init kasan_early_init(void);
A
Andrey Ryabinin 已提交
30 31
void __init kasan_init(void);
#else
32
static inline void kasan_early_init(void) { }
A
Andrey Ryabinin 已提交
33 34 35 36 37 38
static inline void kasan_init(void) { }
#endif

#endif

#endif