1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _ASM_S390_KFENCE_H
4 #define _ASM_S390_KFENCE_H
5 
6 #include <linux/mm.h>
7 #include <linux/kfence.h>
8 #include <asm/set_memory.h>
9 #include <asm/page.h>
10 
11 void __kernel_map_pages(struct page *page, int numpages, int enable);
12 
13 static __always_inline bool arch_kfence_init_pool(void)
14 {
15 #ifdef CONFIG_KFENCE
16 	unsigned long pool_pages = KFENCE_POOL_SIZE >> PAGE_SHIFT;
17 
18 	set_memory_4k((unsigned long)__kfence_pool, pool_pages);
19 #endif
20 	return true;
21 }
22 
23 #define arch_kfence_test_address(addr) ((addr) & PAGE_MASK)
24 
25 static inline bool kfence_protect_page(unsigned long addr, bool protect)
26 {
27 	__kernel_map_pages(virt_to_page((void *)addr), 1, !protect);
28 	return true;
29 }
30 
31 #endif /* _ASM_S390_KFENCE_H */
32