aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm.h
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-01-05 19:36:47 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2007-01-06 02:55:25 -0500
commitebeace8609205bf5e1b96fe325b7dea148042232 (patch)
tree863991639d7df2a4aa5fd8b20b6b3a28c2cc2cda /drivers/kvm/kvm.h
parentcc4529efc7b730b596d9c7d5a917c00a357e92aa (diff)
[PATCH] KVM: MMU: oom handling
When beginning to process a page fault, make sure we have enough shadow pages available to service the fault. If not, free some pages. Signed-off-by: Avi Kivity <avi@qumranet.com> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/kvm/kvm.h')
-rw-r--r--drivers/kvm/kvm.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 34c43bb4d348..1d0be85651f5 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -52,6 +52,8 @@
52#define KVM_MAX_VCPUS 1 52#define KVM_MAX_VCPUS 1
53#define KVM_MEMORY_SLOTS 4 53#define KVM_MEMORY_SLOTS 4
54#define KVM_NUM_MMU_PAGES 256 54#define KVM_NUM_MMU_PAGES 256
55#define KVM_MIN_FREE_MMU_PAGES 5
56#define KVM_REFILL_PAGES 25
55 57
56#define FX_IMAGE_SIZE 512 58#define FX_IMAGE_SIZE 512
57#define FX_IMAGE_ALIGN 16 59#define FX_IMAGE_ALIGN 16
@@ -278,6 +280,7 @@ struct kvm {
278 * Hash table of struct kvm_mmu_page. 280 * Hash table of struct kvm_mmu_page.
279 */ 281 */
280 struct list_head active_mmu_pages; 282 struct list_head active_mmu_pages;
283 int n_free_mmu_pages;
281 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; 284 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
282 struct kvm_vcpu vcpus[KVM_MAX_VCPUS]; 285 struct kvm_vcpu vcpus[KVM_MAX_VCPUS];
283 int memory_config_version; 286 int memory_config_version;
@@ -451,6 +454,15 @@ unsigned long segment_base(u16 selector);
451void kvm_mmu_pre_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes); 454void kvm_mmu_pre_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes);
452void kvm_mmu_post_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes); 455void kvm_mmu_post_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes);
453int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva); 456int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
457void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
458
459static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
460 u32 error_code)
461{
462 if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES))
463 kvm_mmu_free_some_pages(vcpu);
464 return vcpu->mmu.page_fault(vcpu, gva, error_code);
465}
454 466
455static inline struct page *_gfn_to_page(struct kvm *kvm, gfn_t gfn) 467static inline struct page *_gfn_to_page(struct kvm *kvm, gfn_t gfn)
456{ 468{