aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm.h
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-09-14 13:26:06 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-09-14 16:59:55 -0400
commit22d95b1282810f5af599ee292b3fc443aefbdad0 (patch)
treedafe050aef12ea4bbac4ffb77070d8ec416a0838 /drivers/kvm/kvm.h
parent44e3ff32ac229a10a30b7b840f092f5b32a5f72a (diff)
KVM: MMU: Fix rare oops on guest context switch
A guest context switch to an uncached cr3 can require allocation of shadow pages, but we only recycle shadow pages in kvm_mmu_page_fault(). Move shadow page recycling to mmu_topup_memory_caches(), which is called from both the page fault handler and from guest cr3 reload. Signed-off-by: Avi Kivity <avi@qumranet.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/kvm/kvm.h')
-rw-r--r--drivers/kvm/kvm.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 3ac9cbce3369..336be86c6f5a 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -619,7 +619,7 @@ unsigned long segment_base(u16 selector);
619void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, 619void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
620 const u8 *old, const u8 *new, int bytes); 620 const u8 *old, const u8 *new, int bytes);
621int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva); 621int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
622void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu); 622void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
623int kvm_mmu_load(struct kvm_vcpu *vcpu); 623int kvm_mmu_load(struct kvm_vcpu *vcpu);
624void kvm_mmu_unload(struct kvm_vcpu *vcpu); 624void kvm_mmu_unload(struct kvm_vcpu *vcpu);
625 625
@@ -628,11 +628,15 @@ int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
628static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, 628static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
629 u32 error_code) 629 u32 error_code)
630{ 630{
631 if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES))
632 kvm_mmu_free_some_pages(vcpu);
633 return vcpu->mmu.page_fault(vcpu, gva, error_code); 631 return vcpu->mmu.page_fault(vcpu, gva, error_code);
634} 632}
635 633
634static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
635{
636 if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES))
637 __kvm_mmu_free_some_pages(vcpu);
638}
639
636static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu) 640static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
637{ 641{
638 if (likely(vcpu->mmu.root_hpa != INVALID_PAGE)) 642 if (likely(vcpu->mmu.root_hpa != INVALID_PAGE))