Skip to content

Commit 75646c4

Browse files
kvaneeshmpe
authored andcommitted
arch/powerpc/mm/hash: validate the pte entries before handling the hash fault
Make sure we are operating on THP and hugetlb entries in the respective hash fault handling routines. No functional change in this patch. If we walked the table wrongly before, we will retry the access. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent ae28f17 commit 75646c4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arch/powerpc/mm/hugepage-hash64.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
5151
new_pmd |= _PAGE_DIRTY;
5252
} while (!pmd_xchg(pmdp, __pmd(old_pmd), __pmd(new_pmd)));
5353

54+
/*
55+
* Make sure this is thp or devmap entry
56+
*/
57+
if (!(old_pmd & (H_PAGE_THP_HUGE | _PAGE_DEVMAP)))
58+
return 0;
59+
5460
rflags = htab_convert_pte_flags(new_pmd);
5561

5662
#if 0

arch/powerpc/mm/hugetlbpage-hash64.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,
6262
new_pte |= _PAGE_DIRTY;
6363
} while(!pte_xchg(ptep, __pte(old_pte), __pte(new_pte)));
6464

65+
/* Make sure this is a hugetlb entry */
66+
if (old_pte & (H_PAGE_THP_HUGE | _PAGE_DEVMAP))
67+
return 0;
68+
6569
rflags = htab_convert_pte_flags(new_pte);
6670
if (unlikely(mmu_psize == MMU_PAGE_16G))
6771
offset = PTRS_PER_PUD;

0 commit comments

Comments
 (0)