diff options
author | Paul Mackerras <paulus@ozlabs.org> | 2018-02-07 03:49:54 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@ozlabs.org> | 2018-02-08 23:35:24 -0500 |
commit | 05f2bb0313a2855e491dadfc8319b7da261d7074 (patch) | |
tree | 5e75fbfcc885ae5235eaaef4ef2ef310160ab56d | |
parent | 57ea5f161a7de5b1913c212d04f57a175b159fdf (diff) |
KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code
This fixes the computation of the HPTE index to use when the HPT
resizing code encounters a bolted HPTE which is stored in its
secondary HPTE group. The code inverts the HPTE group number, which
is correct, but doesn't then mask it with new_hash_mask. As a result,
new_pteg will be effectively negative, resulting in new_hptep
pointing before the new HPT, which will corrupt memory.
In addition, this removes two BUG_ON statements. The condition that
the BUG_ONs were testing -- that we have computed the hash value
incorrectly -- has never been observed in testing, and if it did
occur, would only affect the guest, not the host. Given that
BUG_ON should only be used in conditions where the kernel (i.e.
the host kernel, in this case) can't possibly continue execution,
it is not appropriate here.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r-- | arch/powerpc/kvm/book3s_64_mmu_hv.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 966097232d21..d19649960bbf 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c | |||
@@ -1329,12 +1329,8 @@ static unsigned long resize_hpt_rehash_hpte(struct kvm_resize_hpt *resize, | |||
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | new_pteg = hash & new_hash_mask; | 1331 | new_pteg = hash & new_hash_mask; |
1332 | if (vpte & HPTE_V_SECONDARY) { | 1332 | if (vpte & HPTE_V_SECONDARY) |
1333 | BUG_ON(~pteg != (hash & old_hash_mask)); | 1333 | new_pteg = ~hash & new_hash_mask; |
1334 | new_pteg = ~new_pteg; | ||
1335 | } else { | ||
1336 | BUG_ON(pteg != (hash & old_hash_mask)); | ||
1337 | } | ||
1338 | 1334 | ||
1339 | new_idx = new_pteg * HPTES_PER_GROUP + (idx % HPTES_PER_GROUP); | 1335 | new_idx = new_pteg * HPTES_PER_GROUP + (idx % HPTES_PER_GROUP); |
1340 | new_hptep = (__be64 *)(new->virt + (new_idx << 4)); | 1336 | new_hptep = (__be64 *)(new->virt + (new_idx << 4)); |