diff options
author | Avi Kivity <avi@qumranet.com> | 2007-06-04 08:58:30 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-07-16 05:05:45 -0400 |
commit | 17c3ba9d37dbda490792a2b52953f09d0dee30d6 (patch) | |
tree | 44749b8658b61c7aa6cdb38d7823fa061d24b12c /drivers/kvm/kvm.h | |
parent | bd2b2baa5c5fbb08b4b0df7508ff419407f7ece6 (diff) |
KVM: Lazy guest cr3 switching
Switch guest paging context may require us to allocate memory, which
might fail. Instead of wiring up error paths everywhere, make context
switching lazy and actually do the switch before the next guest entry,
where we can return an error if allocation fails.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm.h')
-rw-r--r-- | drivers/kvm/kvm.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index 199e1e9bae2..3ec4e26b9bd 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -544,6 +544,8 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, | |||
544 | const u8 *old, const u8 *new, int bytes); | 544 | const u8 *old, const u8 *new, int bytes); |
545 | int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva); | 545 | int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva); |
546 | void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu); | 546 | void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu); |
547 | int kvm_mmu_load(struct kvm_vcpu *vcpu); | ||
548 | void kvm_mmu_unload(struct kvm_vcpu *vcpu); | ||
547 | 549 | ||
548 | int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run); | 550 | int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run); |
549 | 551 | ||
@@ -555,6 +557,14 @@ static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, | |||
555 | return vcpu->mmu.page_fault(vcpu, gva, error_code); | 557 | return vcpu->mmu.page_fault(vcpu, gva, error_code); |
556 | } | 558 | } |
557 | 559 | ||
560 | static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu) | ||
561 | { | ||
562 | if (likely(vcpu->mmu.root_hpa != INVALID_PAGE)) | ||
563 | return 0; | ||
564 | |||
565 | return kvm_mmu_load(vcpu); | ||
566 | } | ||
567 | |||
558 | static inline int is_long_mode(struct kvm_vcpu *vcpu) | 568 | static inline int is_long_mode(struct kvm_vcpu *vcpu) |
559 | { | 569 | { |
560 | #ifdef CONFIG_X86_64 | 570 | #ifdef CONFIG_X86_64 |