]> git.hungrycats.org Git - linux/commit
KVM: PPC: Book3S HV: Avoid crash from THP collapse during radix page fault
authorPaul Mackerras <paulus@ozlabs.org>
Thu, 4 Oct 2018 04:51:11 +0000 (14:51 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Oct 2018 07:18:20 +0000 (09:18 +0200)
commit4a15f8a1de5912592045af0d30d1800f866837e3
tree1815be86236d4ce9e7fcc56c400f444a3fc15906
parent726c11216e33f06762349153a0f4e0111dce869b
KVM: PPC: Book3S HV: Avoid crash from THP collapse during radix page fault

commit 6579804c431712d56956a63b1a01509441cc6800 upstream.

Commit 71d29f43b633 ("KVM: PPC: Book3S HV: Don't use compound_order to
determine host mapping size", 2018-09-11) added a call to
__find_linux_pte() and a dereference of the returned PTE pointer to the
radix page fault path in the common case where the page is normal
system memory.  Previously, __find_linux_pte() was only called for
mappings to physical addresses which don't have a page struct (e.g.
memory-mapped I/O) or where the page struct is marked as reserved
memory.

This exposes us to the possibility that the returned PTE pointer
could be NULL, for example in the case of a concurrent THP collapse
operation.  Dereferencing the returned NULL pointer causes a host
crash.

To fix this, we check for NULL, and if it is NULL, we retry the
operation by returning to the guest, with the expectation that it
will generate the same page fault again (unless of course it has
been fixed up by another CPU in the meantime).

Fixes: 71d29f43b633 ("KVM: PPC: Book3S HV: Don't use compound_order to determine host mapping size")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/book3s_64_mmu_radix.c