Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 /*
0004  * Copyright (c) 2021, Google LLC.
0005  * Pasha Tatashin <pasha.tatashin@soleen.com>
0006  */
0007 #ifndef __LINUX_PAGE_TABLE_CHECK_H
0008 #define __LINUX_PAGE_TABLE_CHECK_H
0009 
0010 #ifdef CONFIG_PAGE_TABLE_CHECK
0011 #include <linux/jump_label.h>
0012 
0013 extern struct static_key_true page_table_check_disabled;
0014 extern struct page_ext_operations page_table_check_ops;
0015 
0016 void __page_table_check_zero(struct page *page, unsigned int order);
0017 void __page_table_check_pte_clear(struct mm_struct *mm, unsigned long addr,
0018                   pte_t pte);
0019 void __page_table_check_pmd_clear(struct mm_struct *mm, unsigned long addr,
0020                   pmd_t pmd);
0021 void __page_table_check_pud_clear(struct mm_struct *mm, unsigned long addr,
0022                   pud_t pud);
0023 void __page_table_check_pte_set(struct mm_struct *mm, unsigned long addr,
0024                 pte_t *ptep, pte_t pte);
0025 void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr,
0026                 pmd_t *pmdp, pmd_t pmd);
0027 void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr,
0028                 pud_t *pudp, pud_t pud);
0029 void __page_table_check_pte_clear_range(struct mm_struct *mm,
0030                     unsigned long addr,
0031                     pmd_t pmd);
0032 
0033 static inline void page_table_check_alloc(struct page *page, unsigned int order)
0034 {
0035     if (static_branch_likely(&page_table_check_disabled))
0036         return;
0037 
0038     __page_table_check_zero(page, order);
0039 }
0040 
0041 static inline void page_table_check_free(struct page *page, unsigned int order)
0042 {
0043     if (static_branch_likely(&page_table_check_disabled))
0044         return;
0045 
0046     __page_table_check_zero(page, order);
0047 }
0048 
0049 static inline void page_table_check_pte_clear(struct mm_struct *mm,
0050                           unsigned long addr, pte_t pte)
0051 {
0052     if (static_branch_likely(&page_table_check_disabled))
0053         return;
0054 
0055     __page_table_check_pte_clear(mm, addr, pte);
0056 }
0057 
0058 static inline void page_table_check_pmd_clear(struct mm_struct *mm,
0059                           unsigned long addr, pmd_t pmd)
0060 {
0061     if (static_branch_likely(&page_table_check_disabled))
0062         return;
0063 
0064     __page_table_check_pmd_clear(mm, addr, pmd);
0065 }
0066 
0067 static inline void page_table_check_pud_clear(struct mm_struct *mm,
0068                           unsigned long addr, pud_t pud)
0069 {
0070     if (static_branch_likely(&page_table_check_disabled))
0071         return;
0072 
0073     __page_table_check_pud_clear(mm, addr, pud);
0074 }
0075 
0076 static inline void page_table_check_pte_set(struct mm_struct *mm,
0077                         unsigned long addr, pte_t *ptep,
0078                         pte_t pte)
0079 {
0080     if (static_branch_likely(&page_table_check_disabled))
0081         return;
0082 
0083     __page_table_check_pte_set(mm, addr, ptep, pte);
0084 }
0085 
0086 static inline void page_table_check_pmd_set(struct mm_struct *mm,
0087                         unsigned long addr, pmd_t *pmdp,
0088                         pmd_t pmd)
0089 {
0090     if (static_branch_likely(&page_table_check_disabled))
0091         return;
0092 
0093     __page_table_check_pmd_set(mm, addr, pmdp, pmd);
0094 }
0095 
0096 static inline void page_table_check_pud_set(struct mm_struct *mm,
0097                         unsigned long addr, pud_t *pudp,
0098                         pud_t pud)
0099 {
0100     if (static_branch_likely(&page_table_check_disabled))
0101         return;
0102 
0103     __page_table_check_pud_set(mm, addr, pudp, pud);
0104 }
0105 
0106 static inline void page_table_check_pte_clear_range(struct mm_struct *mm,
0107                             unsigned long addr,
0108                             pmd_t pmd)
0109 {
0110     if (static_branch_likely(&page_table_check_disabled))
0111         return;
0112 
0113     __page_table_check_pte_clear_range(mm, addr, pmd);
0114 }
0115 
0116 #else
0117 
0118 static inline void page_table_check_alloc(struct page *page, unsigned int order)
0119 {
0120 }
0121 
0122 static inline void page_table_check_free(struct page *page, unsigned int order)
0123 {
0124 }
0125 
0126 static inline void page_table_check_pte_clear(struct mm_struct *mm,
0127                           unsigned long addr, pte_t pte)
0128 {
0129 }
0130 
0131 static inline void page_table_check_pmd_clear(struct mm_struct *mm,
0132                           unsigned long addr, pmd_t pmd)
0133 {
0134 }
0135 
0136 static inline void page_table_check_pud_clear(struct mm_struct *mm,
0137                           unsigned long addr, pud_t pud)
0138 {
0139 }
0140 
0141 static inline void page_table_check_pte_set(struct mm_struct *mm,
0142                         unsigned long addr, pte_t *ptep,
0143                         pte_t pte)
0144 {
0145 }
0146 
0147 static inline void page_table_check_pmd_set(struct mm_struct *mm,
0148                         unsigned long addr, pmd_t *pmdp,
0149                         pmd_t pmd)
0150 {
0151 }
0152 
0153 static inline void page_table_check_pud_set(struct mm_struct *mm,
0154                         unsigned long addr, pud_t *pudp,
0155                         pud_t pud)
0156 {
0157 }
0158 
0159 static inline void page_table_check_pte_clear_range(struct mm_struct *mm,
0160                             unsigned long addr,
0161                             pmd_t pmd)
0162 {
0163 }
0164 
0165 #endif /* CONFIG_PAGE_TABLE_CHECK */
0166 #endif /* __LINUX_PAGE_TABLE_CHECK_H */