[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200416035358.261056-1-david@gibson.dropbear.id.au>
Date: Thu, 16 Apr 2020 13:53:58 +1000
From: David Gibson <david@...son.dropbear.id.au>
To: paulus@...ba.org, mpe@...erman.id.au
Cc: clg@...d.org, kvm-ppc@...r.kernel.org, benh@...nel.crashing.org,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
groug@...d.org, David Gibson <david@...son.dropbear.id.au>
Subject: [PATCH] KVM: PPC: Handle non-present PTEs in kvmppc_book3s_hv_page_fault()
Since cd758a9b57ee "KVM: PPC: Book3S HV: Use __gfn_to_pfn_memslot in HPT
page fault handler", it's been possible in fairly rare circumstances to
load a non-present PTE in kvmppc_book3s_hv_page_fault() when running a
guest on a POWER8 host.
Because that case wasn't checked for, we could misinterpret the non-present
PTE as being a cache-inhibited PTE. That could mismatch with the
corresponding hash PTE, which would cause the function to fail with -EFAULT
a little further down. That would propagate up to the KVM_RUN ioctl()
generally causing the KVM userspace (usually qemu) to fall over.
This addresses the problem by catching that case and returning to the guest
instead.
Fixes: cd758a9b57ee "KVM: PPC: Book3S HV: Use __gfn_to_pfn_memslot in HPT page fault handler"
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1820402
Suggested-by: Paul Mackerras <paulus@...ba.org>
Signed-off-by: David Gibson <david@...son.dropbear.id.au>
---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 6404df613ea3..394fca8e630a 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -616,6 +616,11 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
}
pte = *ptep;
local_irq_enable();
+ if (!pte_present(pte)) {
+ if (page)
+ put_page(page);
+ return RESUME_GUEST;
+ }
hpa = pte_pfn(pte) << PAGE_SHIFT;
pte_size = PAGE_SIZE;
if (shift)
--
2.25.2
Powered by blists - more mailing lists