aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2015-09-15 03:00:08 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2015-09-16 08:06:03 -0400
commit36b35d5d807b7e57aff7d08e63de8b17731ee211 (patch)
tree1629b6259078a9ef2b0e6eaeeee930a0fb456e57
parent655471f54c2e395ba29ae4156ba0f49928177cc1 (diff)
powerpc/mm: Recompute hash value after a failed update
If we had secondary hash flag set, we ended up modifying hash value in the updatepp code path. Hence with a failed updatepp we will be using a wrong hash value for the following hash insert. Fix this by recomputing hash before insert. Without this patch we can end up with using wrong slot number in linux pte. That can result in us missing an hash pte update or invalidate which can cause memory corruption or even machine check. Fixes: 6d492ecc6489 ("powerpc/THP: Add code to handle HPTE faults for hugepages") Cc: stable@vger.kernel.org # v3.11+ Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Reviewed-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/mm/hugepage-hash64.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/powerpc/mm/hugepage-hash64.c b/arch/powerpc/mm/hugepage-hash64.c
index 43dafb9d6a46..4d87122cf6a7 100644
--- a/arch/powerpc/mm/hugepage-hash64.c
+++ b/arch/powerpc/mm/hugepage-hash64.c
@@ -85,7 +85,6 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
85 BUG_ON(index >= 4096); 85 BUG_ON(index >= 4096);
86 86
87 vpn = hpt_vpn(ea, vsid, ssize); 87 vpn = hpt_vpn(ea, vsid, ssize);
88 hash = hpt_hash(vpn, shift, ssize);
89 hpte_slot_array = get_hpte_slot_array(pmdp); 88 hpte_slot_array = get_hpte_slot_array(pmdp);
90 if (psize == MMU_PAGE_4K) { 89 if (psize == MMU_PAGE_4K) {
91 /* 90 /*
@@ -101,6 +100,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
101 valid = hpte_valid(hpte_slot_array, index); 100 valid = hpte_valid(hpte_slot_array, index);
102 if (valid) { 101 if (valid) {
103 /* update the hpte bits */ 102 /* update the hpte bits */
103 hash = hpt_hash(vpn, shift, ssize);
104 hidx = hpte_hash_index(hpte_slot_array, index); 104 hidx = hpte_hash_index(hpte_slot_array, index);
105 if (hidx & _PTEIDX_SECONDARY) 105 if (hidx & _PTEIDX_SECONDARY)
106 hash = ~hash; 106 hash = ~hash;
@@ -126,6 +126,7 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
126 if (!valid) { 126 if (!valid) {
127 unsigned long hpte_group; 127 unsigned long hpte_group;
128 128
129 hash = hpt_hash(vpn, shift, ssize);
129 /* insert new entry */ 130 /* insert new entry */
130 pa = pmd_pfn(__pmd(old_pmd)) << PAGE_SHIFT; 131 pa = pmd_pfn(__pmd(old_pmd)) << PAGE_SHIFT;
131 new_pmd |= _PAGE_HASHPTE; 132 new_pmd |= _PAGE_HASHPTE;