summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>2012-07-17 21:52:52 +0800
committerMarcelo Tosatti <mtosatti@redhat.com>2012-07-19 21:09:10 -0300
commit86fde74cf5b829627b37ca86322acfdd99b524b8 (patch)
tree0a30f492d7326f8fcb0fbb17c530e57166ab6d29 /arch/x86/kvm/mmu.c
parent9d3c92af47d853d4e31ee971dba7bc086275b7b3 (diff)
downloadop-kernel-dev-86fde74cf5b829627b37ca86322acfdd99b524b8.zip
op-kernel-dev-86fde74cf5b829627b37ca86322acfdd99b524b8.tar.gz
KVM: MMU: track the refcount when unmap the page
It will trigger a WARN_ON if the page has been freed but it is still used in mmu, it can help us to detect mm bug early Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a5d6ef7..685a485 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -556,6 +556,14 @@ static int mmu_spte_clear_track_bits(u64 *sptep)
return 0;
pfn = spte_to_pfn(old_spte);
+
+ /*
+ * KVM does not hold the refcount of the page used by
+ * kvm mmu, before reclaiming the page, we should
+ * unmap it from mmu first.
+ */
+ WARN_ON(!kvm_is_mmio_pfn(pfn) && !page_count(pfn_to_page(pfn)));
+
if (!shadow_accessed_mask || old_spte & shadow_accessed_mask)
kvm_set_pfn_accessed(pfn);
if (!shadow_dirty_mask || (old_spte & shadow_dirty_mask))
OpenPOWER on IntegriCloud