drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / riscv / include / asm / kfence.h
blob7388edd88986f94b7167ba4b84f802ac5fba0b91
1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _ASM_RISCV_KFENCE_H
4 #define _ASM_RISCV_KFENCE_H
6 #include <linux/kfence.h>
7 #include <linux/pfn.h>
8 #include <asm-generic/pgalloc.h>
9 #include <asm/pgtable.h>
11 static inline bool arch_kfence_init_pool(void)
13 return true;
16 static inline bool kfence_protect_page(unsigned long addr, bool protect)
18 pte_t *pte = virt_to_kpte(addr);
20 if (protect)
21 set_pte(pte, __pte(pte_val(ptep_get(pte)) & ~_PAGE_PRESENT));
22 else
23 set_pte(pte, __pte(pte_val(ptep_get(pte)) | _PAGE_PRESENT));
25 flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
27 return true;
30 #endif /* _ASM_RISCV_KFENCE_H */