Commit 53f45ecc authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Michael Ellerman

powerpc/mm: Move setting PTE specific flags to pfn_pmd()

powerpc used to set the PTE specific flags in set_pte_at(). That is
different from other architectures. To be consistent with other
architectures powerpc updated pfn_pte() to set _PAGE_PTE in commit
379c926d ("powerpc/mm: move setting pte specific flags to
pfn_pte")

That commit didn't do the same for pfn_pmd() because we expect
pmd_mkhuge() to do that. But as per Linus that is a bad rule:

  The rule that you must use "pmd_mkhuge()" seems _completely_ wrong.
  The only valid use to ever make a pmd out of a pfn is to make a
  huge-page.

Hence update pfn_pmd() to set _PAGE_PTE.
Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201022091115.39568-1-aneesh.kumar@linux.ibm.com
parent 1891ef21
...@@ -1231,13 +1231,28 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b) ...@@ -1231,13 +1231,28 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
return hash__pmd_same(pmd_a, pmd_b); return hash__pmd_same(pmd_a, pmd_b);
} }
static inline pmd_t pmd_mkhuge(pmd_t pmd) static inline pmd_t __pmd_mkhuge(pmd_t pmd)
{ {
if (radix_enabled()) if (radix_enabled())
return radix__pmd_mkhuge(pmd); return radix__pmd_mkhuge(pmd);
return hash__pmd_mkhuge(pmd); return hash__pmd_mkhuge(pmd);
} }
/*
* pfn_pmd return a pmd_t that can be used as pmd pte entry.
*/
static inline pmd_t pmd_mkhuge(pmd_t pmd)
{
#ifdef CONFIG_DEBUG_VM
if (radix_enabled())
WARN_ON((pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)) == 0);
else
WARN_ON((pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE | H_PAGE_THP_HUGE)) !=
cpu_to_be64(_PAGE_PTE | H_PAGE_THP_HUGE));
#endif
return pmd;
}
#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
extern int pmdp_set_access_flags(struct vm_area_struct *vma, extern int pmdp_set_access_flags(struct vm_area_struct *vma,
unsigned long address, pmd_t *pmdp, unsigned long address, pmd_t *pmdp,
......
...@@ -136,12 +136,18 @@ static pmd_t pmd_set_protbits(pmd_t pmd, pgprot_t pgprot) ...@@ -136,12 +136,18 @@ static pmd_t pmd_set_protbits(pmd_t pmd, pgprot_t pgprot)
return __pmd(pmd_val(pmd) | pgprot_val(pgprot)); return __pmd(pmd_val(pmd) | pgprot_val(pgprot));
} }
/*
* At some point we should be able to get rid of
* pmd_mkhuge() and mk_huge_pmd() when we update all the
* other archs to mark the pmd huge in pfn_pmd()
*/
pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot) pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot)
{ {
unsigned long pmdv; unsigned long pmdv;
pmdv = (pfn << PAGE_SHIFT) & PTE_RPN_MASK; pmdv = (pfn << PAGE_SHIFT) & PTE_RPN_MASK;
return pmd_set_protbits(__pmd(pmdv), pgprot);
return __pmd_mkhuge(pmd_set_protbits(__pmd(pmdv), pgprot));
} }
pmd_t mk_pmd(struct page *page, pgprot_t pgprot) pmd_t mk_pmd(struct page *page, pgprot_t pgprot)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment