powerpc/64s: __find_linux_pte synchronization vs pmdp_invalidate
Nicholas Piggin
reviewerRFC PATCH 1/1 powerpc/64s: __find_linux_pte synchronization vs pmdp_invalidate
The pmd_none check does not catch hugepage collapse, nor does the pmd_present check in pmd_trans_huge, because hugepage collapse sets !_PAGE_PRESENT && _PAGE_INVALID (which results in !pmd_none and pmd_present).
Aneesh noticed we might need this check as well.
--- arch/powerpc/mm/pgtable.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
arch/powerpc/mm/pgtable.c +11 -4
@@ -372,13 +372,20 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, pdshift =PMD_SHIFT ; pmdp =pmd_offset (&pud, ea); pmd =READ_ONCE (*pmdp); -/* -* A hugepage collapse is captured by pmd_none, because -* it mark the pmd none and do a hpte invalidate. -*/ +if (pmd_none (pmd))return NULL ; +#ifdef CONFIG_PPC_BOOK3S_64 +if (pmd_val (pmd) & (_PAGE_PRESENT|_PAGE_INVALID) == _PAGE_INVALID) { +/* +* A hugepage collapse is captured by this condition, see +* pmdp_invalidate. +*/ +return NULL ; + } +#endif +if (pmd_trans_huge (pmd) ||pmd_devmap (pmd)) {if (is_thp) *is_thp = true;
Signature · 1 line
2.20.1
Le 03/06/2019 à 08:44, Nicholas Piggin a écrit :
Quoted 18 lines
The
pmd_nonecheck does not catch hugepage collapse, nor does thepmd_presentcheck inpmd_trans_huge, because hugepage collapse sets !_PAGE_PRESENT &&_PAGE_INVALID(which results in !pmd_none andpmd_present).Aneesh noticed we might need this check as well.
--- arch/powerpc/mm/pgtable.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)arch/powerpc/mm/pgtable.c +0
-0@@ -372,13 +372,20 @@ pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, pdshift =PMD_SHIFT ; pmdp =pmd_offset (&pud, ea);
arch/powerpc/mm/pgtable.c pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, · line 379
Quoted 10 lines
arch/powerpc/mm/pgtable.c +2
-4pmd =READ_ONCE (*pmdp); -/* -* A hugepage collapse is captured by pmd_none, because -* it mark the pmd none and do a hpte invalidate. -*/ +if (pmd_none (pmd))return NULL ; +#ifdef CONFIG_PPC_BOOK3S_64
I can't see anything that would build fail on other subarches. Wouldn't be better to use
if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_INVALID) == _PAGE_INVALID))
arch/powerpc/mm/pgtable.c pte_t *__find_linux_pte(pgd_t *pgdir, unsigned long ea, · line 380
Quoted 1 line
arch/powerpc/mm/pgtable.c +1
-0+if (pmd_val (pmd) & (_PAGE_PRESENT|_PAGE_INVALID) == _PAGE_INVALID) {
Maybe using pmd_raw() instead as in all the book3s64 helpers ?
Christophe
Quoted 12 lines
arch/powerpc/mm/pgtable.c +8
-0+/* +* A hugepage collapse is captured by this condition, see +* pmdp_invalidate. +*/ + return NULL; + } +#endif +if (pmd_trans_huge (pmd) ||pmd_devmap (pmd)) {if (is_thp) *is_thp = true;