[PATCH 0/2] KVM: MMU: Fix a refcount bug with ZONE_DEVICE pages

From: Sean Christopherson
Date: Wed Nov 06 2019 - 12:07:37 EST


This mini-series fixes a suspected, but technically unconfirmed, bug in
KVM related to ZONE_DEVICE pages. The suspected issue is that KVM treats
ZONE_DEVICE pages as reserved PFNs, and so doesn't put references to such
pages when dropping references via KVM's generic kvm_release_pfn_clean().

David Hildenbrand uncovered the bug during a discussion about removing
PG_reserved from ZONE_DEVICE pages, after Dan Williams pointed out[1] that
there was a bug report from Adam Borowski[2] that was likely related to
KVM's interaction with PageReserved().

Patch 1/2 contains the actual fix, patch 2/2 is a minor cleanup that is
mostly unrelated, but dependent and prompted by the fix in patch 1/2.

The fix itself is a bit more aggressive than what was proposed by David
and Dan, but I'm fairly confident it's the right direction for the long
term, and it also plays nice with the original PG_reserved removal series
that exposed the bug.

To be 100% clear, I haven't actually confirmed this fixes the bug reported
by Adam.

[1] http://lkml.kernel.org/r/20190919115547.GA17963@xxxxxxxxxx
[2] https://lkml.kernel.org/r/01adb4cb-6092-638c-0bab-e61322be7cf5@xxxxxxxxxx

Sean Christopherson (2):
KVM: MMU: Do not treat ZONE_DEVICE pages as being reserved
KVM: x86/mmu: Add helper to consolidate huge page promotion

arch/x86/kvm/mmu.c | 15 +++++++++------
include/linux/kvm_host.h | 1 +
virt/kvm/kvm_main.c | 19 +++++++++++++++----
3 files changed, 25 insertions(+), 10 deletions(-)

--
2.24.0