arm64: hugetlb: fix the wrong address for several functions
authorHuang Shijie <shijie.huang@arm.com>
Tue, 8 Nov 2016 05:44:39 +0000 (13:44 +0800)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 9 Nov 2016 16:55:13 +0000 (16:55 +0000)
The libhugetlbfs meets several failures since the following functions
do not use the correct address:
   huge_ptep_get_and_clear()
   huge_ptep_set_access_flags()
   huge_ptep_set_wrprotect()
   huge_ptep_clear_flush()

This patch fixes the wrong address for them.

Signed-off-by: Huang Shijie <shijie.huang@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/mm/hugetlbpage.c

index 9a1069dd889f9dc57d2c6510ffb5bdc82b28bf84..964b7549af5cc7f827c57fe17709e7575a471c56 100644 (file)
@@ -200,7 +200,7 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
                ncontig = find_num_contig(mm, addr, cpte, *cpte, &pgsize);
                /* save the 1st pte to return */
                pte = ptep_get_and_clear(mm, addr, cpte);
-               for (i = 1; i < ncontig; ++i) {
+               for (i = 1, addr += pgsize; i < ncontig; ++i, addr += pgsize) {
                        /*
                         * If HW_AFDBM is enabled, then the HW could
                         * turn on the dirty bit for any of the page
@@ -238,7 +238,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
                pfn = pte_pfn(*cpte);
                ncontig = find_num_contig(vma->vm_mm, addr, cpte,
                                          *cpte, &pgsize);
-               for (i = 0; i < ncontig; ++i, ++cpte) {
+               for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize) {
                        changed = ptep_set_access_flags(vma, addr, cpte,
                                                        pfn_pte(pfn,
                                                                hugeprot),
@@ -261,7 +261,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm,
 
                cpte = huge_pte_offset(mm, addr);
                ncontig = find_num_contig(mm, addr, cpte, *cpte, &pgsize);
-               for (i = 0; i < ncontig; ++i, ++cpte)
+               for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize)
                        ptep_set_wrprotect(mm, addr, cpte);
        } else {
                ptep_set_wrprotect(mm, addr, ptep);
@@ -279,7 +279,7 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma,
                cpte = huge_pte_offset(vma->vm_mm, addr);
                ncontig = find_num_contig(vma->vm_mm, addr, cpte,
                                          *cpte, &pgsize);
-               for (i = 0; i < ncontig; ++i, ++cpte)
+               for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize)
                        ptep_clear_flush(vma, addr, cpte);
        } else {
                ptep_clear_flush(vma, addr, ptep);