Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64: mm: Remove pmd_sect() and pud_sect()

The semantics of pXd_leaf() are very similar to pXd_sect(). The only
difference is that pXd_sect() only considers it a section if PTE_VALID
is set, whereas pXd_leaf() permits both "valid" and "present-invalid"
types.

Using pXd_sect() has caused issues now that large leaf entries can be
present-invalid since commit a166563e7ec37 ("arm64: mm: support large
block mapping when rodata=full"), so let's just remove the API and
standardize on pXd_leaf().

There are a few callsites of the form pXd_leaf(READ_ONCE(*pXdp)). This
was previously fine for the pXd_sect() macro because it only evaluated
its argument once. But pXd_leaf() evaluates its argument multiple times.
So let's avoid unintended side effects by reimplementing pXd_leaf() as
an inline function.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Ryan Roberts and committed by
Catalin Marinas
1d37713f 15bfba1a

+21 -16
+12 -7
arch/arm64/include/asm/pgtable.h
··· 784 784 785 785 #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ 786 786 PMD_TYPE_TABLE) 787 - #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ 788 - PMD_TYPE_SECT) 789 - #define pmd_leaf(pmd) (pmd_present(pmd) && !pmd_table(pmd)) 787 + 788 + #define pmd_leaf pmd_leaf 789 + static inline bool pmd_leaf(pmd_t pmd) 790 + { 791 + return pmd_present(pmd) && !pmd_table(pmd); 792 + } 793 + 790 794 #define pmd_bad(pmd) (!pmd_table(pmd)) 791 795 792 796 #define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE) ··· 808 804 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 809 805 810 806 #if defined(CONFIG_ARM64_64K_PAGES) || CONFIG_PGTABLE_LEVELS < 3 811 - static inline bool pud_sect(pud_t pud) { return false; } 812 807 static inline bool pud_table(pud_t pud) { return true; } 813 808 #else 814 - #define pud_sect(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \ 815 - PUD_TYPE_SECT) 816 809 #define pud_table(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \ 817 810 PUD_TYPE_TABLE) 818 811 #endif ··· 879 878 PUD_TYPE_TABLE) 880 879 #define pud_present(pud) pte_present(pud_pte(pud)) 881 880 #ifndef __PAGETABLE_PMD_FOLDED 882 - #define pud_leaf(pud) (pud_present(pud) && !pud_table(pud)) 881 + #define pud_leaf pud_leaf 882 + static inline bool pud_leaf(pud_t pud) 883 + { 884 + return pud_present(pud) && !pud_table(pud); 885 + } 883 886 #else 884 887 #define pud_leaf(pud) false 885 888 #endif
+9 -9
arch/arm64/mm/mmu.c
··· 204 204 pmd_t pmd = READ_ONCE(*pmdp); 205 205 pte_t *ptep; 206 206 207 - BUG_ON(pmd_sect(pmd)); 207 + BUG_ON(pmd_leaf(pmd)); 208 208 if (pmd_none(pmd)) { 209 209 pmdval_t pmdval = PMD_TYPE_TABLE | PMD_TABLE_UXN | PMD_TABLE_AF; 210 210 phys_addr_t pte_phys; ··· 303 303 /* 304 304 * Check for initial section mappings in the pgd/pud. 305 305 */ 306 - BUG_ON(pud_sect(pud)); 306 + BUG_ON(pud_leaf(pud)); 307 307 if (pud_none(pud)) { 308 308 pudval_t pudval = PUD_TYPE_TABLE | PUD_TABLE_UXN | PUD_TABLE_AF; 309 309 phys_addr_t pmd_phys; ··· 1503 1503 continue; 1504 1504 1505 1505 WARN_ON(!pmd_present(pmd)); 1506 - if (pmd_sect(pmd)) { 1506 + if (pmd_leaf(pmd)) { 1507 1507 pmd_clear(pmdp); 1508 1508 1509 1509 /* ··· 1536 1536 continue; 1537 1537 1538 1538 WARN_ON(!pud_present(pud)); 1539 - if (pud_sect(pud)) { 1539 + if (pud_leaf(pud)) { 1540 1540 pud_clear(pudp); 1541 1541 1542 1542 /* ··· 1650 1650 if (pmd_none(pmd)) 1651 1651 continue; 1652 1652 1653 - WARN_ON(!pmd_present(pmd) || !pmd_table(pmd) || pmd_sect(pmd)); 1653 + WARN_ON(!pmd_present(pmd) || !pmd_table(pmd)); 1654 1654 free_empty_pte_table(pmdp, addr, next, floor, ceiling); 1655 1655 } while (addr = next, addr < end); 1656 1656 ··· 1690 1690 if (pud_none(pud)) 1691 1691 continue; 1692 1692 1693 - WARN_ON(!pud_present(pud) || !pud_table(pud) || pud_sect(pud)); 1693 + WARN_ON(!pud_present(pud) || !pud_table(pud)); 1694 1694 free_empty_pmd_table(pudp, addr, next, floor, ceiling); 1695 1695 } while (addr = next, addr < end); 1696 1696 ··· 1786 1786 { 1787 1787 vmemmap_verify((pte_t *)pmdp, node, addr, next); 1788 1788 1789 - return pmd_sect(READ_ONCE(*pmdp)); 1789 + return pmd_leaf(READ_ONCE(*pmdp)); 1790 1790 } 1791 1791 1792 1792 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, ··· 1850 1850 1851 1851 int pud_clear_huge(pud_t *pudp) 1852 1852 { 1853 - if (!pud_sect(READ_ONCE(*pudp))) 1853 + if (!pud_leaf(READ_ONCE(*pudp))) 1854 1854 return 0; 1855 1855 pud_clear(pudp); 1856 1856 return 1; ··· 1858 1858 1859 1859 int pmd_clear_huge(pmd_t *pmdp) 1860 1860 { 1861 - if (!pmd_sect(READ_ONCE(*pmdp))) 1861 + if (!pmd_leaf(READ_ONCE(*pmdp))) 1862 1862 return 0; 1863 1863 pmd_clear(pmdp); 1864 1864 return 1;