1.. SPDX-License-Identifier: GPL-2.0 2 3=============================== 4Architecture Page Table Helpers 5=============================== 6 7Generic MM expects architectures (with MMU) to provide helpers to create, access 8and modify page table entries at various level for different memory functions. 9These page table helpers need to conform to a common semantics across platforms. 10Following tables describe the expected semantics which can also be tested during 11boot via CONFIG_DEBUG_VM_PGTABLE option. All future changes in here or the debug 12test need to be in sync. 13 14 15PTE Page Table Helpers 16====================== 17 18+---------------------------+--------------------------------------------------+ 19| pte_same | Tests whether both PTE entries are the same | 20+---------------------------+--------------------------------------------------+ 21| pte_bad | Tests a non-table mapped PTE | 22+---------------------------+--------------------------------------------------+ 23| pte_present | Tests a valid mapped PTE | 24+---------------------------+--------------------------------------------------+ 25| pte_young | Tests a young PTE | 26+---------------------------+--------------------------------------------------+ 27| pte_dirty | Tests a dirty PTE | 28+---------------------------+--------------------------------------------------+ 29| pte_write | Tests a writable PTE | 30+---------------------------+--------------------------------------------------+ 31| pte_special | Tests a special PTE | 32+---------------------------+--------------------------------------------------+ 33| pte_protnone | Tests a PROT_NONE PTE | 34+---------------------------+--------------------------------------------------+ 35| pte_devmap | Tests a ZONE_DEVICE mapped PTE | 36+---------------------------+--------------------------------------------------+ 37| pte_soft_dirty | Tests a soft dirty PTE | 38+---------------------------+--------------------------------------------------+ 39| pte_swp_soft_dirty | Tests a soft dirty swapped PTE | 40+---------------------------+--------------------------------------------------+ 41| pte_mkyoung | Creates a young PTE | 42+---------------------------+--------------------------------------------------+ 43| pte_mkold | Creates an old PTE | 44+---------------------------+--------------------------------------------------+ 45| pte_mkdirty | Creates a dirty PTE | 46+---------------------------+--------------------------------------------------+ 47| pte_mkclean | Creates a clean PTE | 48+---------------------------+--------------------------------------------------+ 49| pte_mkwrite | Creates a writable PTE of the type specified by | 50| | the VMA. | 51+---------------------------+--------------------------------------------------+ 52| pte_mkwrite_novma | Creates a writable PTE, of the conventional type | 53| | of writable. | 54+---------------------------+--------------------------------------------------+ 55| pte_wrprotect | Creates a write protected PTE | 56+---------------------------+--------------------------------------------------+ 57| pte_mkspecial | Creates a special PTE | 58+---------------------------+--------------------------------------------------+ 59| pte_mkdevmap | Creates a ZONE_DEVICE mapped PTE | 60+---------------------------+--------------------------------------------------+ 61| pte_mksoft_dirty | Creates a soft dirty PTE | 62+---------------------------+--------------------------------------------------+ 63| pte_clear_soft_dirty | Clears a soft dirty PTE | 64+---------------------------+--------------------------------------------------+ 65| pte_swp_mksoft_dirty | Creates a soft dirty swapped PTE | 66+---------------------------+--------------------------------------------------+ 67| pte_swp_clear_soft_dirty | Clears a soft dirty swapped PTE | 68+---------------------------+--------------------------------------------------+ 69| pte_mknotpresent | Invalidates a mapped PTE | 70+---------------------------+--------------------------------------------------+ 71| ptep_clear | Clears a PTE | 72+---------------------------+--------------------------------------------------+ 73| ptep_get_and_clear | Clears and returns PTE | 74+---------------------------+--------------------------------------------------+ 75| ptep_get_and_clear_full | Clears and returns PTE (batched PTE unmap) | 76+---------------------------+--------------------------------------------------+ 77| ptep_test_and_clear_young | Clears young from a PTE | 78+---------------------------+--------------------------------------------------+ 79| ptep_set_wrprotect | Converts into a write protected PTE | 80+---------------------------+--------------------------------------------------+ 81| ptep_set_access_flags | Converts into a more permissive PTE | 82+---------------------------+--------------------------------------------------+ 83 84 85PMD Page Table Helpers 86====================== 87 88+---------------------------+--------------------------------------------------+ 89| pmd_same | Tests whether both PMD entries are the same | 90+---------------------------+--------------------------------------------------+ 91| pmd_bad | Tests a non-table mapped PMD | 92+---------------------------+--------------------------------------------------+ 93| pmd_leaf | Tests a leaf mapped PMD | 94+---------------------------+--------------------------------------------------+ 95| pmd_huge | Tests a HugeTLB mapped PMD | 96+---------------------------+--------------------------------------------------+ 97| pmd_trans_huge | Tests a Transparent Huge Page (THP) at PMD | 98+---------------------------+--------------------------------------------------+ 99| pmd_present | Tests whether pmd_page() points to valid memory | 100+---------------------------+--------------------------------------------------+ 101| pmd_young | Tests a young PMD | 102+---------------------------+--------------------------------------------------+ 103| pmd_dirty | Tests a dirty PMD | 104+---------------------------+--------------------------------------------------+ 105| pmd_write | Tests a writable PMD | 106+---------------------------+--------------------------------------------------+ 107| pmd_special | Tests a special PMD | 108+---------------------------+--------------------------------------------------+ 109| pmd_protnone | Tests a PROT_NONE PMD | 110+---------------------------+--------------------------------------------------+ 111| pmd_devmap | Tests a ZONE_DEVICE mapped PMD | 112+---------------------------+--------------------------------------------------+ 113| pmd_soft_dirty | Tests a soft dirty PMD | 114+---------------------------+--------------------------------------------------+ 115| pmd_swp_soft_dirty | Tests a soft dirty swapped PMD | 116+---------------------------+--------------------------------------------------+ 117| pmd_mkyoung | Creates a young PMD | 118+---------------------------+--------------------------------------------------+ 119| pmd_mkold | Creates an old PMD | 120+---------------------------+--------------------------------------------------+ 121| pmd_mkdirty | Creates a dirty PMD | 122+---------------------------+--------------------------------------------------+ 123| pmd_mkclean | Creates a clean PMD | 124+---------------------------+--------------------------------------------------+ 125| pmd_mkwrite | Creates a writable PMD of the type specified by | 126| | the VMA. | 127+---------------------------+--------------------------------------------------+ 128| pmd_mkwrite_novma | Creates a writable PMD, of the conventional type | 129| | of writable. | 130+---------------------------+--------------------------------------------------+ 131| pmd_wrprotect | Creates a write protected PMD | 132+---------------------------+--------------------------------------------------+ 133| pmd_mkspecial | Creates a special PMD | 134+---------------------------+--------------------------------------------------+ 135| pmd_mkdevmap | Creates a ZONE_DEVICE mapped PMD | 136+---------------------------+--------------------------------------------------+ 137| pmd_mksoft_dirty | Creates a soft dirty PMD | 138+---------------------------+--------------------------------------------------+ 139| pmd_clear_soft_dirty | Clears a soft dirty PMD | 140+---------------------------+--------------------------------------------------+ 141| pmd_swp_mksoft_dirty | Creates a soft dirty swapped PMD | 142+---------------------------+--------------------------------------------------+ 143| pmd_swp_clear_soft_dirty | Clears a soft dirty swapped PMD | 144+---------------------------+--------------------------------------------------+ 145| pmd_mkinvalid | Invalidates a present PMD; do not call for | 146| | non-present PMD [1] | 147+---------------------------+--------------------------------------------------+ 148| pmd_set_huge | Creates a PMD huge mapping | 149+---------------------------+--------------------------------------------------+ 150| pmd_clear_huge | Clears a PMD huge mapping | 151+---------------------------+--------------------------------------------------+ 152| pmdp_get_and_clear | Clears a PMD | 153+---------------------------+--------------------------------------------------+ 154| pmdp_get_and_clear_full | Clears a PMD | 155+---------------------------+--------------------------------------------------+ 156| pmdp_test_and_clear_young | Clears young from a PMD | 157+---------------------------+--------------------------------------------------+ 158| pmdp_set_wrprotect | Converts into a write protected PMD | 159+---------------------------+--------------------------------------------------+ 160| pmdp_set_access_flags | Converts into a more permissive PMD | 161+---------------------------+--------------------------------------------------+ 162 163 164PUD Page Table Helpers 165====================== 166 167+---------------------------+--------------------------------------------------+ 168| pud_same | Tests whether both PUD entries are the same | 169+---------------------------+--------------------------------------------------+ 170| pud_bad | Tests a non-table mapped PUD | 171+---------------------------+--------------------------------------------------+ 172| pud_leaf | Tests a leaf mapped PUD | 173+---------------------------+--------------------------------------------------+ 174| pud_huge | Tests a HugeTLB mapped PUD | 175+---------------------------+--------------------------------------------------+ 176| pud_trans_huge | Tests a Transparent Huge Page (THP) at PUD | 177+---------------------------+--------------------------------------------------+ 178| pud_present | Tests a valid mapped PUD | 179+---------------------------+--------------------------------------------------+ 180| pud_young | Tests a young PUD | 181+---------------------------+--------------------------------------------------+ 182| pud_dirty | Tests a dirty PUD | 183+---------------------------+--------------------------------------------------+ 184| pud_write | Tests a writable PUD | 185+---------------------------+--------------------------------------------------+ 186| pud_devmap | Tests a ZONE_DEVICE mapped PUD | 187+---------------------------+--------------------------------------------------+ 188| pud_mkyoung | Creates a young PUD | 189+---------------------------+--------------------------------------------------+ 190| pud_mkold | Creates an old PUD | 191+---------------------------+--------------------------------------------------+ 192| pud_mkdirty | Creates a dirty PUD | 193+---------------------------+--------------------------------------------------+ 194| pud_mkclean | Creates a clean PUD | 195+---------------------------+--------------------------------------------------+ 196| pud_mkwrite | Creates a writable PUD | 197+---------------------------+--------------------------------------------------+ 198| pud_wrprotect | Creates a write protected PUD | 199+---------------------------+--------------------------------------------------+ 200| pud_mkdevmap | Creates a ZONE_DEVICE mapped PUD | 201+---------------------------+--------------------------------------------------+ 202| pud_mkinvalid | Invalidates a present PUD; do not call for | 203| | non-present PUD [1] | 204+---------------------------+--------------------------------------------------+ 205| pud_set_huge | Creates a PUD huge mapping | 206+---------------------------+--------------------------------------------------+ 207| pud_clear_huge | Clears a PUD huge mapping | 208+---------------------------+--------------------------------------------------+ 209| pudp_get_and_clear | Clears a PUD | 210+---------------------------+--------------------------------------------------+ 211| pudp_get_and_clear_full | Clears a PUD | 212+---------------------------+--------------------------------------------------+ 213| pudp_test_and_clear_young | Clears young from a PUD | 214+---------------------------+--------------------------------------------------+ 215| pudp_set_wrprotect | Converts into a write protected PUD | 216+---------------------------+--------------------------------------------------+ 217| pudp_set_access_flags | Converts into a more permissive PUD | 218+---------------------------+--------------------------------------------------+ 219 220 221HugeTLB Page Table Helpers 222========================== 223 224+---------------------------+--------------------------------------------------+ 225| pte_huge | Tests a HugeTLB | 226+---------------------------+--------------------------------------------------+ 227| arch_make_huge_pte | Creates a HugeTLB | 228+---------------------------+--------------------------------------------------+ 229| huge_pte_dirty | Tests a dirty HugeTLB | 230+---------------------------+--------------------------------------------------+ 231| huge_pte_write | Tests a writable HugeTLB | 232+---------------------------+--------------------------------------------------+ 233| huge_pte_mkdirty | Creates a dirty HugeTLB | 234+---------------------------+--------------------------------------------------+ 235| huge_pte_mkwrite | Creates a writable HugeTLB | 236+---------------------------+--------------------------------------------------+ 237| huge_pte_wrprotect | Creates a write protected HugeTLB | 238+---------------------------+--------------------------------------------------+ 239| huge_ptep_get_and_clear | Clears a HugeTLB | 240+---------------------------+--------------------------------------------------+ 241| huge_ptep_set_wrprotect | Converts into a write protected HugeTLB | 242+---------------------------+--------------------------------------------------+ 243| huge_ptep_set_access_flags | Converts into a more permissive HugeTLB | 244+---------------------------+--------------------------------------------------+ 245 246 247SWAP Page Table Helpers 248======================== 249 250+---------------------------+--------------------------------------------------+ 251| __pte_to_swp_entry | Creates a swapped entry (arch) from a mapped PTE | 252+---------------------------+--------------------------------------------------+ 253| __swp_to_pte_entry | Creates a mapped PTE from a swapped entry (arch) | 254+---------------------------+--------------------------------------------------+ 255| __pmd_to_swp_entry | Creates a swapped entry (arch) from a mapped PMD | 256+---------------------------+--------------------------------------------------+ 257| __swp_to_pmd_entry | Creates a mapped PMD from a swapped entry (arch) | 258+---------------------------+--------------------------------------------------+ 259| is_migration_entry | Tests a migration (read or write) swapped entry | 260+-------------------------------+----------------------------------------------+ 261| is_writable_migration_entry | Tests a write migration swapped entry | 262+-------------------------------+----------------------------------------------+ 263| make_readable_migration_entry | Creates a read migration swapped entry | 264+-------------------------------+----------------------------------------------+ 265| make_writable_migration_entry | Creates a write migration swapped entry | 266+-------------------------------+----------------------------------------------+ 267 268[1] https://lore.kernel.org/linux-mm/20181017020930.GN30832@redhat.com/ 269