Message ID | 20200327014007.1915-1-longpeng2@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v3] mm/hugetlb: fix a addressing exception caused by huge_pte_offset | expand |
On Fri, Mar 27, 2020 at 09:40:07AM +0800, Longpeng(Mike) wrote: > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index dd8737a..d4fab68 100644 > +++ b/mm/hugetlb.c > @@ -4909,29 +4909,33 @@ pte_t *huge_pte_offset(struct mm_struct *mm, > unsigned long addr, unsigned long sz) > { > pgd_t *pgd; > - p4d_t *p4d; > - pud_t *pud; > - pmd_t *pmd; > + p4d_t *p4g, p4d_entry; > + pud_t *pud, pud_entry; > + pmd_t *pmd, pmd_entry; > > pgd = pgd_offset(mm, addr); > if (!pgd_present(*pgd)) > return NULL; > - p4d = p4d_offset(pgd, addr); > - if (!p4d_present(*p4d)) > + > + p4g = p4d_offset(pgd, addr); Why p4g here? Shouldn't it be p4d? Jason
Hi [This is an automated email] This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all The bot has tested the following trees: v5.5.11, v5.4.27, v4.19.112, v4.14.174, v4.9.217, v4.4.217. v5.5.11: Build OK! v5.4.27: Build OK! v4.19.112: Build OK! v4.14.174: Build OK! v4.9.217: Failed to apply! Possible dependencies: 166f61b9435a ("mm: codgin-style fixes") 505a60e22560 ("asm-generic: introduce 5level-fixup.h") 82b0f8c39a38 ("mm: join struct fault_env and vm_fault") 953c66c2b22a ("mm: THP page cache support for ppc64") c2febafc6773 ("mm: convert generic code to 5-level paging") fd60775aea80 ("mm, thp: avoid unlikely branches for split_huge_pmd") v4.4.217: Failed to apply! Possible dependencies: 01c8f1c44b83 ("mm, dax, gpu: convert vm_insert_mixed to pfn_t") 0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations") 166f61b9435a ("mm: codgin-style fixes") 34c0fd540e79 ("mm, dax, pmem: introduce pfn_t") 505a60e22560 ("asm-generic: introduce 5level-fixup.h") 52db400fcd50 ("pmem, dax: clean up clear_pmem()") 5c6a84a3f455 ("mm/kasan: Switch to using __pa_symbol and lm_alias") 82b0f8c39a38 ("mm: join struct fault_env and vm_fault") 9973c98ecfda ("dax: add support for fsync/sync") aac453635549 ("mm, oom: introduce oom reaper") ac401cc78242 ("dax: New fault locking") b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()") bae473a423f6 ("mm: introduce fault_env") bc2466e42573 ("dax: Use radix tree entry lock to protect cow faults") c2febafc6773 ("mm: convert generic code to 5-level paging") e4b274915863 ("DAX: move RADIX_DAX_ definitions to dax.c") f9fe48bece3a ("dax: support dirty DAX entries in radix tree") NOTE: The patch will not be queued to stable trees until it is upstream. How should we proceed with this patch?
On 2020/3/27 20:11, Jason Gunthorpe wrote: > On Fri, Mar 27, 2020 at 09:40:07AM +0800, Longpeng(Mike) wrote: >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index dd8737a..d4fab68 100644 >> +++ b/mm/hugetlb.c >> @@ -4909,29 +4909,33 @@ pte_t *huge_pte_offset(struct mm_struct *mm, >> unsigned long addr, unsigned long sz) >> { >> pgd_t *pgd; >> - p4d_t *p4d; >> - pud_t *pud; >> - pmd_t *pmd; >> + p4d_t *p4g, p4d_entry; >> + pud_t *pud, pud_entry; >> + pmd_t *pmd, pmd_entry; >> >> pgd = pgd_offset(mm, addr); >> if (!pgd_present(*pgd)) >> return NULL; >> - p4d = p4d_offset(pgd, addr); >> - if (!p4d_present(*p4d)) >> + >> + p4g = p4d_offset(pgd, addr); > > Why p4g here? Shouldn't it be p4d? > Sorry, it's a typo, I'll send v4 > Jason > . > --- Regards, Longpeng(Mike)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index dd8737a..d4fab68 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4909,29 +4909,33 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, unsigned long sz) { pgd_t *pgd; - p4d_t *p4d; - pud_t *pud; - pmd_t *pmd; + p4d_t *p4g, p4d_entry; + pud_t *pud, pud_entry; + pmd_t *pmd, pmd_entry; pgd = pgd_offset(mm, addr); if (!pgd_present(*pgd)) return NULL; - p4d = p4d_offset(pgd, addr); - if (!p4d_present(*p4d)) + + p4g = p4d_offset(pgd, addr); + p4d_entry = READ_ONCE(*p4g); + if (!p4d_present(p4d_entry)) return NULL; - pud = pud_offset(p4d, addr); - if (sz != PUD_SIZE && pud_none(*pud)) + pud = pud_offset(&p4d_entry, addr); + pud_entry = READ_ONCE(*pud); + if (sz != PUD_SIZE && pud_none(pud_entry)) return NULL; /* hugepage or swap? */ - if (pud_huge(*pud) || !pud_present(*pud)) + if (pud_huge(pud_entry) || !pud_present(pud_entry)) return (pte_t *)pud; - pmd = pmd_offset(pud, addr); - if (sz != PMD_SIZE && pmd_none(*pmd)) + pmd = pmd_offset(&pud_entry, addr); + pmd_entry = READ_ONCE(*pmd); + if (sz != PMD_SIZE && pmd_none(pmd_entry)) return NULL; /* hugepage or swap? */ - if (pmd_huge(*pmd) || !pmd_present(*pmd)) + if (pmd_huge(pmd_entry) || !pmd_present(pmd_entry)) return (pte_t *)pmd; return NULL;