From 58846c3cca2cef13716f07730de1a439bbfd3188 Mon Sep 17 00:00:00 2001 From: Gu Yuchen Date: Thu, 21 Aug 2025 13:49:36 +0800 Subject: [PATCH] anolis: sw64: mm: provide mm_struct and address to huge_ptep_get() ANBZ: #4688 On powerpc 8xx huge_ptep_get() will need to know whether the given ptep is a PTE entry or a PMD entry. This cannot be known with the PMD entry itself because there is no easy way to know it from the content of the entry. So huge_ptep_get() will need to know either the size of the page or get the pmd. In order to be consistent with huge_ptep_get_and_clear(), give mm and address to huge_ptep_get(). Signed-off-by: Gu Yuchen Reviewed-by: He Sheng Signed-off-by: Gu Zitao --- arch/sw_64/mm/hugetlbpage_c4.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/sw_64/mm/hugetlbpage_c4.c b/arch/sw_64/mm/hugetlbpage_c4.c index eaeeaadb6546..094fdf941b6f 100644 --- a/arch/sw_64/mm/hugetlbpage_c4.c +++ b/arch/sw_64/mm/hugetlbpage_c4.c @@ -72,7 +72,7 @@ static pte_t get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long pgsize, unsigned long ncontig) { - pte_t orig_pte = huge_ptep_get(ptep); + pte_t orig_pte = huge_ptep_get(mm, addr, ptep); unsigned long i; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) { @@ -285,7 +285,7 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, { int ncontig; size_t pgsize; - pte_t orig_pte = huge_ptep_get(ptep); + pte_t orig_pte = huge_ptep_get(mm, addr, ptep); if (!pte_cont(orig_pte)) return ptep_get_and_clear(mm, addr, ptep); @@ -309,15 +309,16 @@ pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, return get_clear_contig_flush(mm, addr, ptep, pgsize, ncontig); } -static int __cont_access_flags_changed(pte_t *ptep, pte_t pte, int ncontig) +static int __cont_access_flags_changed(struct mm_struct *mm, + unsigned long addr, pte_t *ptep, pte_t pte, int ncontig) { int i; - if (pte_write(pte) != pte_write(huge_ptep_get(ptep))) + if (pte_write(pte) != pte_write(huge_ptep_get(mm, addr, ptep))) return 1; for (i = 0; i < ncontig; i++) { - pte_t orig_pte = huge_ptep_get(ptep + i); + pte_t orig_pte = huge_ptep_get(mm, addr, ptep + i); if (pte_dirty(pte) != pte_dirty(orig_pte)) return 1; @@ -336,6 +337,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, int ncontig, i; size_t pgsize = 0; unsigned long pfn = pte_pfn(pte), dpfn; + struct mm_struct *mm = vma->vm_mm; pgprot_t hugeprot; pte_t orig_pte; @@ -345,7 +347,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, ncontig = CONT_PMDS; dpfn = PMD_SIZE >> PAGE_SHIFT; - if (!__cont_access_flags_changed(ptep, pte, ncontig)) + if (!__cont_access_flags_changed(mm, addr, ptep, pte, ncontig)) return 0; orig_pte = get_and_clear(vma->vm_mm, addr, ptep, pgsize, ncontig); -- Gitee