Skip to content

Commit 9ab3ac2

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm/hash: Clear the invalid slot information correctly
We can get a hash pte fault with 4k base page size and find the pte already inserted with 64K base page size. In that case we need to clear the existing slot information from the old pte. Fix this correctly With THP, we also clear the slot information with respect to all the 64K hash pte mapping that 16MB page. They are all invalid now. This make sure we don't find the slot valid when we fault with 4k base page size. Finding the slot valid should not result in any wrong behavior because we do check again in hash page table for the validity. But we can avoid that check completely. Fixes: a43c0eb ("powerpc/mm: Convert 4k hash insert to C") Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent f6bf0fa commit 9ab3ac2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

arch/powerpc/mm/hash64_64k.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
111111
*/
112112
if (!(old_pte & _PAGE_COMBO)) {
113113
flush_hash_page(vpn, rpte, MMU_PAGE_64K, ssize, flags);
114-
old_pte &= ~_PAGE_HASHPTE | _PAGE_F_GIX | _PAGE_F_SECOND;
114+
/*
115+
* clear the old slot details from the old and new pte.
116+
* On hash insert failure we use old pte value and we don't
117+
* want slot information there if we have a insert failure.
118+
*/
119+
old_pte &= ~(_PAGE_HASHPTE | _PAGE_F_GIX | _PAGE_F_SECOND);
120+
new_pte &= ~(_PAGE_HASHPTE | _PAGE_F_GIX | _PAGE_F_SECOND);
115121
goto htab_insert_hpte;
116122
}
117123
/*

arch/powerpc/mm/hugepage-hash64.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,19 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
7878
* base page size. This is because demote_segment won't flush
7979
* hash page table entries.
8080
*/
81-
if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO))
81+
if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO)) {
8282
flush_hash_hugepage(vsid, ea, pmdp, MMU_PAGE_64K,
8383
ssize, flags);
84+
/*
85+
* With THP, we also clear the slot information with
86+
* respect to all the 64K hash pte mapping the 16MB
87+
* page. They are all invalid now. This make sure we
88+
* don't find the slot valid when we fault with 4k
89+
* base page size.
90+
*
91+
*/
92+
memset(hpte_slot_array, 0, PTE_FRAG_SIZE);
93+
}
8494
}
8595

8696
valid = hpte_valid(hpte_slot_array, index);

0 commit comments

Comments
 (0)