162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __ASM_UM_KASAN_H
362306a36Sopenharmony_ci#define __ASM_UM_KASAN_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/init.h>
662306a36Sopenharmony_ci#include <linux/const.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* used in kasan_mem_to_shadow to divide by 8 */
1162306a36Sopenharmony_ci#define KASAN_SHADOW_SCALE_SHIFT 3
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifdef CONFIG_X86_64
1462306a36Sopenharmony_ci#define KASAN_HOST_USER_SPACE_END_ADDR 0x00007fffffffffffUL
1562306a36Sopenharmony_ci/* KASAN_SHADOW_SIZE is the size of total address space divided by 8 */
1662306a36Sopenharmony_ci#define KASAN_SHADOW_SIZE ((KASAN_HOST_USER_SPACE_END_ADDR + 1) >> \
1762306a36Sopenharmony_ci			KASAN_SHADOW_SCALE_SHIFT)
1862306a36Sopenharmony_ci#else
1962306a36Sopenharmony_ci#error "KASAN_SHADOW_SIZE is not defined for this sub-architecture"
2062306a36Sopenharmony_ci#endif /* CONFIG_X86_64 */
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET)
2362306a36Sopenharmony_ci#define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE)
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#ifdef CONFIG_KASAN
2662306a36Sopenharmony_civoid kasan_init(void);
2762306a36Sopenharmony_civoid kasan_map_memory(void *start, unsigned long len);
2862306a36Sopenharmony_ciextern int kasan_um_is_ready;
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#ifdef CONFIG_STATIC_LINK
3162306a36Sopenharmony_ci#define kasan_arch_is_ready() (kasan_um_is_ready)
3262306a36Sopenharmony_ci#endif
3362306a36Sopenharmony_ci#else
3462306a36Sopenharmony_cistatic inline void kasan_init(void) { }
3562306a36Sopenharmony_ci#endif /* CONFIG_KASAN */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#endif /* __ASM_UM_KASAN_H */
38