18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ASM_KASAN_H 38c2ecf20Sopenharmony_ci#define __ASM_KASAN_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifdef CONFIG_KASAN 68c2ecf20Sopenharmony_ci#define _GLOBAL_KASAN(fn) _GLOBAL(__##fn) 78c2ecf20Sopenharmony_ci#define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(__##fn) 88c2ecf20Sopenharmony_ci#define EXPORT_SYMBOL_KASAN(fn) EXPORT_SYMBOL(__##fn) 98c2ecf20Sopenharmony_ci#else 108c2ecf20Sopenharmony_ci#define _GLOBAL_KASAN(fn) _GLOBAL(fn) 118c2ecf20Sopenharmony_ci#define _GLOBAL_TOC_KASAN(fn) _GLOBAL_TOC(fn) 128c2ecf20Sopenharmony_ci#define EXPORT_SYMBOL_KASAN(fn) 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <asm/page.h> 188c2ecf20Sopenharmony_ci#include <linux/sizes.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define KASAN_SHADOW_SCALE_SHIFT 3 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_MODULES) && defined(CONFIG_STRICT_KERNEL_RWX) 238c2ecf20Sopenharmony_ci#define KASAN_KERN_START ALIGN_DOWN(PAGE_OFFSET - SZ_256M, SZ_256M) 248c2ecf20Sopenharmony_ci#else 258c2ecf20Sopenharmony_ci#define KASAN_KERN_START PAGE_OFFSET 268c2ecf20Sopenharmony_ci#endif 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET + \ 298c2ecf20Sopenharmony_ci (KASAN_KERN_START >> KASAN_SHADOW_SCALE_SHIFT)) 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define KASAN_SHADOW_OFFSET ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define KASAN_SHADOW_END (-(-KASAN_SHADOW_START >> KASAN_SHADOW_SCALE_SHIFT)) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#ifdef CONFIG_KASAN 368c2ecf20Sopenharmony_civoid kasan_early_init(void); 378c2ecf20Sopenharmony_civoid kasan_mmu_init(void); 388c2ecf20Sopenharmony_civoid kasan_init(void); 398c2ecf20Sopenharmony_civoid kasan_late_init(void); 408c2ecf20Sopenharmony_ci#else 418c2ecf20Sopenharmony_cistatic inline void kasan_init(void) { } 428c2ecf20Sopenharmony_cistatic inline void kasan_mmu_init(void) { } 438c2ecf20Sopenharmony_cistatic inline void kasan_late_init(void) { } 448c2ecf20Sopenharmony_ci#endif 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_civoid kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t pte); 478c2ecf20Sopenharmony_ciint kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end); 488c2ecf20Sopenharmony_ciint kasan_init_region(void *start, size_t size); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY */ 518c2ecf20Sopenharmony_ci#endif 52