1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright (C) 2019 Andes Technology Corporation */ 3 4#ifndef __ASM_KASAN_H 5#define __ASM_KASAN_H 6 7#ifndef __ASSEMBLY__ 8 9#ifdef CONFIG_KASAN 10 11/* 12 * The following comment was copied from arm64: 13 * KASAN_SHADOW_START: beginning of the kernel virtual addresses. 14 * KASAN_SHADOW_END: KASAN_SHADOW_START + 1/N of kernel virtual addresses, 15 * where N = (1 << KASAN_SHADOW_SCALE_SHIFT). 16 * 17 * KASAN_SHADOW_OFFSET: 18 * This value is used to map an address to the corresponding shadow 19 * address by the following formula: 20 * shadow_addr = (address >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET 21 * 22 * (1 << (64 - KASAN_SHADOW_SCALE_SHIFT)) shadow addresses that lie in range 23 * [KASAN_SHADOW_OFFSET, KASAN_SHADOW_END) cover all 64-bits of virtual 24 * addresses. So KASAN_SHADOW_OFFSET should satisfy the following equation: 25 * KASAN_SHADOW_OFFSET = KASAN_SHADOW_END - 26 * (1ULL << (64 - KASAN_SHADOW_SCALE_SHIFT)) 27 */ 28#define KASAN_SHADOW_SCALE_SHIFT 3 29 30#define KASAN_SHADOW_SIZE (UL(1) << ((CONFIG_VA_BITS - 1) - KASAN_SHADOW_SCALE_SHIFT)) 31#define KASAN_SHADOW_START KERN_VIRT_START 32#define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE) 33#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \ 34 (64 - KASAN_SHADOW_SCALE_SHIFT))) 35 36void kasan_init(void); 37asmlinkage void kasan_early_init(void); 38 39#endif 40#endif 41#endif /* __ASM_KASAN_H */ 42