0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 .. _arch_page_table_helpers:
0004
0005 ===============================
0006 Architecture Page Table Helpers
0007 ===============================
0008
0009 Generic MM expects architectures (with MMU) to provide helpers to create, access
0010 and modify page table entries at various level for different memory functions.
0011 These page table helpers need to conform to a common semantics across platforms.
0012 Following tables describe the expected semantics which can also be tested during
0013 boot via CONFIG_DEBUG_VM_PGTABLE option. All future changes in here or the debug
0014 test need to be in sync.
0015
0016
0017 PTE Page Table Helpers
0018 ======================
0019
0020 +---------------------------+--------------------------------------------------+
0021 | pte_same | Tests whether both PTE entries are the same |
0022 +---------------------------+--------------------------------------------------+
0023 | pte_bad | Tests a non-table mapped PTE |
0024 +---------------------------+--------------------------------------------------+
0025 | pte_present | Tests a valid mapped PTE |
0026 +---------------------------+--------------------------------------------------+
0027 | pte_young | Tests a young PTE |
0028 +---------------------------+--------------------------------------------------+
0029 | pte_dirty | Tests a dirty PTE |
0030 +---------------------------+--------------------------------------------------+
0031 | pte_write | Tests a writable PTE |
0032 +---------------------------+--------------------------------------------------+
0033 | pte_special | Tests a special PTE |
0034 +---------------------------+--------------------------------------------------+
0035 | pte_protnone | Tests a PROT_NONE PTE |
0036 +---------------------------+--------------------------------------------------+
0037 | pte_devmap | Tests a ZONE_DEVICE mapped PTE |
0038 +---------------------------+--------------------------------------------------+
0039 | pte_soft_dirty | Tests a soft dirty PTE |
0040 +---------------------------+--------------------------------------------------+
0041 | pte_swp_soft_dirty | Tests a soft dirty swapped PTE |
0042 +---------------------------+--------------------------------------------------+
0043 | pte_mkyoung | Creates a young PTE |
0044 +---------------------------+--------------------------------------------------+
0045 | pte_mkold | Creates an old PTE |
0046 +---------------------------+--------------------------------------------------+
0047 | pte_mkdirty | Creates a dirty PTE |
0048 +---------------------------+--------------------------------------------------+
0049 | pte_mkclean | Creates a clean PTE |
0050 +---------------------------+--------------------------------------------------+
0051 | pte_mkwrite | Creates a writable PTE |
0052 +---------------------------+--------------------------------------------------+
0053 | pte_wrprotect | Creates a write protected PTE |
0054 +---------------------------+--------------------------------------------------+
0055 | pte_mkspecial | Creates a special PTE |
0056 +---------------------------+--------------------------------------------------+
0057 | pte_mkdevmap | Creates a ZONE_DEVICE mapped PTE |
0058 +---------------------------+--------------------------------------------------+
0059 | pte_mksoft_dirty | Creates a soft dirty PTE |
0060 +---------------------------+--------------------------------------------------+
0061 | pte_clear_soft_dirty | Clears a soft dirty PTE |
0062 +---------------------------+--------------------------------------------------+
0063 | pte_swp_mksoft_dirty | Creates a soft dirty swapped PTE |
0064 +---------------------------+--------------------------------------------------+
0065 | pte_swp_clear_soft_dirty | Clears a soft dirty swapped PTE |
0066 +---------------------------+--------------------------------------------------+
0067 | pte_mknotpresent | Invalidates a mapped PTE |
0068 +---------------------------+--------------------------------------------------+
0069 | ptep_clear | Clears a PTE |
0070 +---------------------------+--------------------------------------------------+
0071 | ptep_get_and_clear | Clears and returns PTE |
0072 +---------------------------+--------------------------------------------------+
0073 | ptep_get_and_clear_full | Clears and returns PTE (batched PTE unmap) |
0074 +---------------------------+--------------------------------------------------+
0075 | ptep_test_and_clear_young | Clears young from a PTE |
0076 +---------------------------+--------------------------------------------------+
0077 | ptep_set_wrprotect | Converts into a write protected PTE |
0078 +---------------------------+--------------------------------------------------+
0079 | ptep_set_access_flags | Converts into a more permissive PTE |
0080 +---------------------------+--------------------------------------------------+
0081
0082
0083 PMD Page Table Helpers
0084 ======================
0085
0086 +---------------------------+--------------------------------------------------+
0087 | pmd_same | Tests whether both PMD entries are the same |
0088 +---------------------------+--------------------------------------------------+
0089 | pmd_bad | Tests a non-table mapped PMD |
0090 +---------------------------+--------------------------------------------------+
0091 | pmd_leaf | Tests a leaf mapped PMD |
0092 +---------------------------+--------------------------------------------------+
0093 | pmd_huge | Tests a HugeTLB mapped PMD |
0094 +---------------------------+--------------------------------------------------+
0095 | pmd_trans_huge | Tests a Transparent Huge Page (THP) at PMD |
0096 +---------------------------+--------------------------------------------------+
0097 | pmd_present | Tests a valid mapped PMD |
0098 +---------------------------+--------------------------------------------------+
0099 | pmd_young | Tests a young PMD |
0100 +---------------------------+--------------------------------------------------+
0101 | pmd_dirty | Tests a dirty PMD |
0102 +---------------------------+--------------------------------------------------+
0103 | pmd_write | Tests a writable PMD |
0104 +---------------------------+--------------------------------------------------+
0105 | pmd_special | Tests a special PMD |
0106 +---------------------------+--------------------------------------------------+
0107 | pmd_protnone | Tests a PROT_NONE PMD |
0108 +---------------------------+--------------------------------------------------+
0109 | pmd_devmap | Tests a ZONE_DEVICE mapped PMD |
0110 +---------------------------+--------------------------------------------------+
0111 | pmd_soft_dirty | Tests a soft dirty PMD |
0112 +---------------------------+--------------------------------------------------+
0113 | pmd_swp_soft_dirty | Tests a soft dirty swapped PMD |
0114 +---------------------------+--------------------------------------------------+
0115 | pmd_mkyoung | Creates a young PMD |
0116 +---------------------------+--------------------------------------------------+
0117 | pmd_mkold | Creates an old PMD |
0118 +---------------------------+--------------------------------------------------+
0119 | pmd_mkdirty | Creates a dirty PMD |
0120 +---------------------------+--------------------------------------------------+
0121 | pmd_mkclean | Creates a clean PMD |
0122 +---------------------------+--------------------------------------------------+
0123 | pmd_mkwrite | Creates a writable PMD |
0124 +---------------------------+--------------------------------------------------+
0125 | pmd_wrprotect | Creates a write protected PMD |
0126 +---------------------------+--------------------------------------------------+
0127 | pmd_mkspecial | Creates a special PMD |
0128 +---------------------------+--------------------------------------------------+
0129 | pmd_mkdevmap | Creates a ZONE_DEVICE mapped PMD |
0130 +---------------------------+--------------------------------------------------+
0131 | pmd_mksoft_dirty | Creates a soft dirty PMD |
0132 +---------------------------+--------------------------------------------------+
0133 | pmd_clear_soft_dirty | Clears a soft dirty PMD |
0134 +---------------------------+--------------------------------------------------+
0135 | pmd_swp_mksoft_dirty | Creates a soft dirty swapped PMD |
0136 +---------------------------+--------------------------------------------------+
0137 | pmd_swp_clear_soft_dirty | Clears a soft dirty swapped PMD |
0138 +---------------------------+--------------------------------------------------+
0139 | pmd_mkinvalid | Invalidates a mapped PMD [1] |
0140 +---------------------------+--------------------------------------------------+
0141 | pmd_set_huge | Creates a PMD huge mapping |
0142 +---------------------------+--------------------------------------------------+
0143 | pmd_clear_huge | Clears a PMD huge mapping |
0144 +---------------------------+--------------------------------------------------+
0145 | pmdp_get_and_clear | Clears a PMD |
0146 +---------------------------+--------------------------------------------------+
0147 | pmdp_get_and_clear_full | Clears a PMD |
0148 +---------------------------+--------------------------------------------------+
0149 | pmdp_test_and_clear_young | Clears young from a PMD |
0150 +---------------------------+--------------------------------------------------+
0151 | pmdp_set_wrprotect | Converts into a write protected PMD |
0152 +---------------------------+--------------------------------------------------+
0153 | pmdp_set_access_flags | Converts into a more permissive PMD |
0154 +---------------------------+--------------------------------------------------+
0155
0156
0157 PUD Page Table Helpers
0158 ======================
0159
0160 +---------------------------+--------------------------------------------------+
0161 | pud_same | Tests whether both PUD entries are the same |
0162 +---------------------------+--------------------------------------------------+
0163 | pud_bad | Tests a non-table mapped PUD |
0164 +---------------------------+--------------------------------------------------+
0165 | pud_leaf | Tests a leaf mapped PUD |
0166 +---------------------------+--------------------------------------------------+
0167 | pud_huge | Tests a HugeTLB mapped PUD |
0168 +---------------------------+--------------------------------------------------+
0169 | pud_trans_huge | Tests a Transparent Huge Page (THP) at PUD |
0170 +---------------------------+--------------------------------------------------+
0171 | pud_present | Tests a valid mapped PUD |
0172 +---------------------------+--------------------------------------------------+
0173 | pud_young | Tests a young PUD |
0174 +---------------------------+--------------------------------------------------+
0175 | pud_dirty | Tests a dirty PUD |
0176 +---------------------------+--------------------------------------------------+
0177 | pud_write | Tests a writable PUD |
0178 +---------------------------+--------------------------------------------------+
0179 | pud_devmap | Tests a ZONE_DEVICE mapped PUD |
0180 +---------------------------+--------------------------------------------------+
0181 | pud_mkyoung | Creates a young PUD |
0182 +---------------------------+--------------------------------------------------+
0183 | pud_mkold | Creates an old PUD |
0184 +---------------------------+--------------------------------------------------+
0185 | pud_mkdirty | Creates a dirty PUD |
0186 +---------------------------+--------------------------------------------------+
0187 | pud_mkclean | Creates a clean PUD |
0188 +---------------------------+--------------------------------------------------+
0189 | pud_mkwrite | Creates a writable PUD |
0190 +---------------------------+--------------------------------------------------+
0191 | pud_wrprotect | Creates a write protected PUD |
0192 +---------------------------+--------------------------------------------------+
0193 | pud_mkdevmap | Creates a ZONE_DEVICE mapped PUD |
0194 +---------------------------+--------------------------------------------------+
0195 | pud_mkinvalid | Invalidates a mapped PUD [1] |
0196 +---------------------------+--------------------------------------------------+
0197 | pud_set_huge | Creates a PUD huge mapping |
0198 +---------------------------+--------------------------------------------------+
0199 | pud_clear_huge | Clears a PUD huge mapping |
0200 +---------------------------+--------------------------------------------------+
0201 | pudp_get_and_clear | Clears a PUD |
0202 +---------------------------+--------------------------------------------------+
0203 | pudp_get_and_clear_full | Clears a PUD |
0204 +---------------------------+--------------------------------------------------+
0205 | pudp_test_and_clear_young | Clears young from a PUD |
0206 +---------------------------+--------------------------------------------------+
0207 | pudp_set_wrprotect | Converts into a write protected PUD |
0208 +---------------------------+--------------------------------------------------+
0209 | pudp_set_access_flags | Converts into a more permissive PUD |
0210 +---------------------------+--------------------------------------------------+
0211
0212
0213 HugeTLB Page Table Helpers
0214 ==========================
0215
0216 +---------------------------+--------------------------------------------------+
0217 | pte_huge | Tests a HugeTLB |
0218 +---------------------------+--------------------------------------------------+
0219 | pte_mkhuge | Creates a HugeTLB |
0220 +---------------------------+--------------------------------------------------+
0221 | huge_pte_dirty | Tests a dirty HugeTLB |
0222 +---------------------------+--------------------------------------------------+
0223 | huge_pte_write | Tests a writable HugeTLB |
0224 +---------------------------+--------------------------------------------------+
0225 | huge_pte_mkdirty | Creates a dirty HugeTLB |
0226 +---------------------------+--------------------------------------------------+
0227 | huge_pte_mkwrite | Creates a writable HugeTLB |
0228 +---------------------------+--------------------------------------------------+
0229 | huge_pte_wrprotect | Creates a write protected HugeTLB |
0230 +---------------------------+--------------------------------------------------+
0231 | huge_ptep_get_and_clear | Clears a HugeTLB |
0232 +---------------------------+--------------------------------------------------+
0233 | huge_ptep_set_wrprotect | Converts into a write protected HugeTLB |
0234 +---------------------------+--------------------------------------------------+
0235 | huge_ptep_set_access_flags | Converts into a more permissive HugeTLB |
0236 +---------------------------+--------------------------------------------------+
0237
0238
0239 SWAP Page Table Helpers
0240 ========================
0241
0242 +---------------------------+--------------------------------------------------+
0243 | __pte_to_swp_entry | Creates a swapped entry (arch) from a mapped PTE |
0244 +---------------------------+--------------------------------------------------+
0245 | __swp_to_pte_entry | Creates a mapped PTE from a swapped entry (arch) |
0246 +---------------------------+--------------------------------------------------+
0247 | __pmd_to_swp_entry | Creates a swapped entry (arch) from a mapped PMD |
0248 +---------------------------+--------------------------------------------------+
0249 | __swp_to_pmd_entry | Creates a mapped PMD from a swapped entry (arch) |
0250 +---------------------------+--------------------------------------------------+
0251 | is_migration_entry | Tests a migration (read or write) swapped entry |
0252 +-------------------------------+----------------------------------------------+
0253 | is_writable_migration_entry | Tests a write migration swapped entry |
0254 +-------------------------------+----------------------------------------------+
0255 | make_readable_migration_entry | Creates a read migration swapped entry |
0256 +-------------------------------+----------------------------------------------+
0257 | make_writable_migration_entry | Creates a write migration swapped entry |
0258 +-------------------------------+----------------------------------------------+
0259
0260 [1] https://lore.kernel.org/linux-mm/20181017020930.GN30832@redhat.com/