kfence.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_KFENCE_H
  3. #define _ASM_S390_KFENCE_H
  4. #include <linux/mm.h>
  5. #include <linux/kfence.h>
  6. #include <asm/set_memory.h>
  7. #include <asm/page.h>
  8. void __kernel_map_pages(struct page *page, int numpages, int enable);
  9. static __always_inline bool arch_kfence_init_pool(void)
  10. {
  11. return true;
  12. }
  13. #define arch_kfence_test_address(addr) ((addr) & PAGE_MASK)
  14. /*
  15. * Do not split kfence pool to 4k mapping with arch_kfence_init_pool(),
  16. * but earlier where page table allocations still happen with memblock.
  17. * Reason is that arch_kfence_init_pool() gets called when the system
  18. * is still in a limbo state - disabling and enabling bottom halves is
  19. * not yet allowed, but that is what our page_table_alloc() would do.
  20. */
  21. static __always_inline void kfence_split_mapping(void)
  22. {
  23. #ifdef CONFIG_KFENCE
  24. unsigned long pool_pages = KFENCE_POOL_SIZE >> PAGE_SHIFT;
  25. set_memory_4k((unsigned long)__kfence_pool, pool_pages);
  26. #endif
  27. }
  28. static inline bool kfence_protect_page(unsigned long addr, bool protect)
  29. {
  30. __kernel_map_pages(virt_to_page(addr), 1, !protect);
  31. return true;
  32. }
  33. #endif /* _ASM_S390_KFENCE_H */