1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Copyright (c) 2021, Google LLC.
5 * Pasha Tatashin <pasha.tatashin@soleen.com>
7 #ifndef __LINUX_PAGE_TABLE_CHECK_H
8 #define __LINUX_PAGE_TABLE_CHECK_H
10 #ifdef CONFIG_PAGE_TABLE_CHECK
11 #include <linux/jump_label.h>
13 extern struct static_key_true page_table_check_disabled;
14 extern struct page_ext_operations page_table_check_ops;
16 void __page_table_check_zero(struct page *page, unsigned int order);
17 void __page_table_check_pte_clear(struct mm_struct *mm, pte_t pte);
18 void __page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd);
19 void __page_table_check_pud_clear(struct mm_struct *mm, pud_t pud);
20 void __page_table_check_ptes_set(struct mm_struct *mm, pte_t *ptep, pte_t pte,
22 void __page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp, pmd_t pmd);
23 void __page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, pud_t pud);
24 void __page_table_check_pte_clear_range(struct mm_struct *mm,
28 static inline void page_table_check_alloc(struct page *page, unsigned int order)
30 if (static_branch_likely(&page_table_check_disabled))
33 __page_table_check_zero(page, order);
36 static inline void page_table_check_free(struct page *page, unsigned int order)
38 if (static_branch_likely(&page_table_check_disabled))
41 __page_table_check_zero(page, order);
44 static inline void page_table_check_pte_clear(struct mm_struct *mm, pte_t pte)
46 if (static_branch_likely(&page_table_check_disabled))
49 __page_table_check_pte_clear(mm, pte);
52 static inline void page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd)
54 if (static_branch_likely(&page_table_check_disabled))
57 __page_table_check_pmd_clear(mm, pmd);
60 static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud)
62 if (static_branch_likely(&page_table_check_disabled))
65 __page_table_check_pud_clear(mm, pud);
68 static inline void page_table_check_ptes_set(struct mm_struct *mm,
69 pte_t *ptep, pte_t pte, unsigned int nr)
71 if (static_branch_likely(&page_table_check_disabled))
74 __page_table_check_ptes_set(mm, ptep, pte, nr);
77 static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp,
80 if (static_branch_likely(&page_table_check_disabled))
83 __page_table_check_pmd_set(mm, pmdp, pmd);
86 static inline void page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp,
89 if (static_branch_likely(&page_table_check_disabled))
92 __page_table_check_pud_set(mm, pudp, pud);
95 static inline void page_table_check_pte_clear_range(struct mm_struct *mm,
99 if (static_branch_likely(&page_table_check_disabled))
102 __page_table_check_pte_clear_range(mm, addr, pmd);
107 static inline void page_table_check_alloc(struct page *page, unsigned int order)
111 static inline void page_table_check_free(struct page *page, unsigned int order)
115 static inline void page_table_check_pte_clear(struct mm_struct *mm, pte_t pte)
119 static inline void page_table_check_pmd_clear(struct mm_struct *mm, pmd_t pmd)
123 static inline void page_table_check_pud_clear(struct mm_struct *mm, pud_t pud)
127 static inline void page_table_check_ptes_set(struct mm_struct *mm,
128 pte_t *ptep, pte_t pte, unsigned int nr)
132 static inline void page_table_check_pmd_set(struct mm_struct *mm, pmd_t *pmdp,
137 static inline void page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp,
142 static inline void page_table_check_pte_clear_range(struct mm_struct *mm,
148 #endif /* CONFIG_PAGE_TABLE_CHECK */
149 #endif /* __LINUX_PAGE_TABLE_CHECK_H */