1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2019 Andes Technology Corporation */
10 * The following comment was copied from arm64:
11 * KASAN_SHADOW_START: beginning of the kernel virtual addresses.
12 * KASAN_SHADOW_END: KASAN_SHADOW_START + 1/N of kernel virtual addresses,
13 * where N = (1 << KASAN_SHADOW_SCALE_SHIFT).
15 * KASAN_SHADOW_OFFSET:
16 * This value is used to map an address to the corresponding shadow
17 * address by the following formula:
18 * shadow_addr = (address >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET
20 * (1 << (64 - KASAN_SHADOW_SCALE_SHIFT)) shadow addresses that lie in range
21 * [KASAN_SHADOW_OFFSET, KASAN_SHADOW_END) cover all 64-bits of virtual
22 * addresses. So KASAN_SHADOW_OFFSET should satisfy the following equation:
23 * KASAN_SHADOW_OFFSET = KASAN_SHADOW_END -
24 * (1ULL << (64 - KASAN_SHADOW_SCALE_SHIFT))
26 #define KASAN_SHADOW_SCALE_SHIFT 3
28 #define KASAN_SHADOW_SIZE (UL(1) << ((VA_BITS - 1) - KASAN_SHADOW_SCALE_SHIFT))
30 * Depending on the size of the virtual address space, the region may not be
31 * aligned on PGDIR_SIZE, so force its alignment to ease its population.
33 #define KASAN_SHADOW_START ((KASAN_SHADOW_END - KASAN_SHADOW_SIZE) & PGDIR_MASK)
34 #define KASAN_SHADOW_END MODULES_LOWEST_VADDR
37 #define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
39 void kasan_init(void);
40 asmlinkage
void kasan_early_init(void);
41 void kasan_swapper_init(void);
45 #endif /* __ASM_KASAN_H */