| From: Ben Hutchings <ben@decadent.org.uk> |
| Date: Fri, 28 Sep 2018 01:15:29 +0100 |
| Subject: x86: mm: Add PUD functions |
| |
| 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> |
| --- |
| |
| --- a/arch/x86/include/asm/pgtable.h |
| +++ b/arch/x86/include/asm/pgtable.h |
| @@ -303,6 +303,25 @@ static inline pmd_t pmd_mknotpresent(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 lon |
| 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); |