aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/paging_tmpl.h
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-09-23 08:10:49 -0400
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:52:48 -0500
commit12b7d28fc102b772eb70f98491587ec5ee717baf (patch)
tree679077d072c9c0195a962a16f805bb228070a87c /drivers/kvm/paging_tmpl.h
parentc7addb902054195b995114df154e061c7d604f69 (diff)
KVM: MMU: Make flooding detection work when guest page faults are bypassed
When we allow guest page faults to reach the guests directly, we lose the fault tracking which allows us to detect demand paging. So we provide an alternate mechnism by clearing the accessed bit when we set a pte, and checking it later to see if the guest actually used it. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r--drivers/kvm/paging_tmpl.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index 99ac9b15f773..be0f85231da9 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -238,7 +238,12 @@ static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu,
238 FNAME(mark_pagetable_dirty)(vcpu->kvm, walker); 238 FNAME(mark_pagetable_dirty)(vcpu->kvm, walker);
239 } 239 }
240 240
241 spte = PT_PRESENT_MASK | PT_ACCESSED_MASK | PT_DIRTY_MASK; 241 /*
242 * We don't set the accessed bit, since we sometimes want to see
243 * whether the guest actually used the pte (in order to detect
244 * demand paging).
245 */
246 spte = PT_PRESENT_MASK | PT_DIRTY_MASK;
242 spte |= gpte & PT64_NX_MASK; 247 spte |= gpte & PT64_NX_MASK;
243 if (!dirty) 248 if (!dirty)
244 access_bits &= ~PT_WRITABLE_MASK; 249 access_bits &= ~PT_WRITABLE_MASK;
@@ -291,6 +296,8 @@ unshadowed:
291 page_header_update_slot(vcpu->kvm, shadow_pte, gaddr); 296 page_header_update_slot(vcpu->kvm, shadow_pte, gaddr);
292 if (!was_rmapped) 297 if (!was_rmapped)
293 rmap_add(vcpu, shadow_pte); 298 rmap_add(vcpu, shadow_pte);
299 if (!ptwrite || !*ptwrite)
300 vcpu->last_pte_updated = shadow_pte;
294} 301}
295 302
296static void FNAME(set_pte)(struct kvm_vcpu *vcpu, pt_element_t gpte, 303static void FNAME(set_pte)(struct kvm_vcpu *vcpu, pt_element_t gpte,