1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _ASM_RISCV_KFENCE_H
4 #define _ASM_RISCV_KFENCE_H
6 #include <linux/kfence.h>
8 #include <asm-generic/pgalloc.h>
9 #include <asm/pgtable.h>
11 static inline bool arch_kfence_init_pool(void)
16 static inline bool kfence_protect_page(unsigned long addr
, bool protect
)
18 pte_t
*pte
= virt_to_kpte(addr
);
21 set_pte(pte
, __pte(pte_val(ptep_get(pte
)) & ~_PAGE_PRESENT
));
23 set_pte(pte
, __pte(pte_val(ptep_get(pte
)) | _PAGE_PRESENT
));
25 flush_tlb_kernel_range(addr
, addr
+ PAGE_SIZE
);
30 #endif /* _ASM_RISCV_KFENCE_H */