]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86: mm: Add PUD functions
authorBen Hutchings <ben@decadent.org.uk>
Fri, 28 Sep 2018 00:15:29 +0000 (01:15 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 3 Oct 2018 03:10:00 +0000 (04:10 +0100)
These are extracted from commit a00cc7d9dd93 "mm, x86: add support for
PUD-sized transparent hugepages" and will be used by later patches.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/x86/include/asm/pgtable.h

index 07861a758293ec1961bb19cff146df78bda56836..c59e22fac1d5cce28e5d68dc77145225e5f54fc9 100644 (file)
@@ -303,6 +303,25 @@ static inline pmd_t pmd_mknotpresent(pmd_t pmd)
        return pmd_clear_flags(pmd, _PAGE_PRESENT);
 }
 
+static inline pud_t pud_set_flags(pud_t pud, pudval_t set)
+{
+       pudval_t v = native_pud_val(pud);
+
+       return __pud(v | set);
+}
+
+static inline pud_t pud_clear_flags(pud_t pud, pudval_t clear)
+{
+       pudval_t v = native_pud_val(pud);
+
+       return __pud(v & ~clear);
+}
+
+static inline pud_t pud_mkhuge(pud_t pud)
+{
+       return pud_set_flags(pud, _PAGE_PSE);
+}
+
 #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
 static inline int pte_soft_dirty(pte_t pte)
 {
@@ -352,6 +371,12 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
                     massage_pgprot(pgprot));
 }
 
+static inline pud_t pfn_pud(unsigned long page_nr, pgprot_t pgprot)
+{
+       return __pud(((phys_addr_t)page_nr << PAGE_SHIFT) |
+                    massage_pgprot(pgprot));
+}
+
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
        pteval_t val = pte_val(pte);