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, unsigned long addr,
19 void __page_table_check_pmd_clear(struct mm_struct *mm, unsigned long addr,
21 void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr,
23 void __page_table_check_pte_set(struct mm_struct *mm, unsigned long addr,
24 pte_t *ptep, pte_t pte);
25 void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr,
26 pmd_t *pmdp, pmd_t pmd);
27 void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr,
28 pud_t *pudp, pud_t pud);
30 static inline void page_table_check_alloc(struct page *page, unsigned int order)
32 if (static_branch_likely(&page_table_check_disabled))
35 __page_table_check_zero(page, order);
38 static inline void page_table_check_free(struct page *page, unsigned int order)
40 if (static_branch_likely(&page_table_check_disabled))
43 __page_table_check_zero(page, order);
46 static inline void page_table_check_pte_clear(struct mm_struct *mm,
47 unsigned long addr, pte_t pte)
49 if (static_branch_likely(&page_table_check_disabled))
52 __page_table_check_pte_clear(mm, addr, pte);
55 static inline void page_table_check_pmd_clear(struct mm_struct *mm,
56 unsigned long addr, pmd_t pmd)
58 if (static_branch_likely(&page_table_check_disabled))
61 __page_table_check_pmd_clear(mm, addr, pmd);
64 static inline void page_table_check_pud_clear(struct mm_struct *mm,
65 unsigned long addr, pud_t pud)
67 if (static_branch_likely(&page_table_check_disabled))
70 __page_table_check_pud_clear(mm, addr, pud);
73 static inline void page_table_check_pte_set(struct mm_struct *mm,
74 unsigned long addr, pte_t *ptep,
77 if (static_branch_likely(&page_table_check_disabled))
80 __page_table_check_pte_set(mm, addr, ptep, pte);
83 static inline void page_table_check_pmd_set(struct mm_struct *mm,
84 unsigned long addr, pmd_t *pmdp,
87 if (static_branch_likely(&page_table_check_disabled))
90 __page_table_check_pmd_set(mm, addr, pmdp, pmd);
93 static inline void page_table_check_pud_set(struct mm_struct *mm,
94 unsigned long addr, pud_t *pudp,
97 if (static_branch_likely(&page_table_check_disabled))
100 __page_table_check_pud_set(mm, addr, pudp, pud);
105 static inline void page_table_check_alloc(struct page *page, unsigned int order)
109 static inline void page_table_check_free(struct page *page, unsigned int order)
113 static inline void page_table_check_pte_clear(struct mm_struct *mm,
114 unsigned long addr, pte_t pte)
118 static inline void page_table_check_pmd_clear(struct mm_struct *mm,
119 unsigned long addr, pmd_t pmd)
123 static inline void page_table_check_pud_clear(struct mm_struct *mm,
124 unsigned long addr, pud_t pud)
128 static inline void page_table_check_pte_set(struct mm_struct *mm,
129 unsigned long addr, pte_t *ptep,
134 static inline void page_table_check_pmd_set(struct mm_struct *mm,
135 unsigned long addr, pmd_t *pmdp,
140 static inline void page_table_check_pud_set(struct mm_struct *mm,
141 unsigned long addr, pud_t *pudp,
146 #endif /* CONFIG_PAGE_TABLE_CHECK */
147 #endif /* __LINUX_PAGE_TABLE_CHECK_H */