aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/svm.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-10-28 12:48:59 -0400
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:52:57 -0500
commit3067714cf59bd4a6dbf788b709485bc62c1ff845 (patch)
tree4cdfba475258886666150e638568e6ad5e8c0e2f /drivers/kvm/svm.c
parentc7e75a3db4ecd952e7a5562cea1b27007bf0c01c (diff)
KVM: Move page fault processing to common code
The code that dispatches the page fault and emulates if we failed to map is duplicated across vmx and svm. Merge it to simplify further bugfixing. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/svm.c')
-rw-r--r--drivers/kvm/svm.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index fe2a5e8b0524..97863f8fd001 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -933,45 +933,14 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
933 struct kvm *kvm = svm->vcpu.kvm; 933 struct kvm *kvm = svm->vcpu.kvm;
934 u64 fault_address; 934 u64 fault_address;
935 u32 error_code; 935 u32 error_code;
936 enum emulation_result er;
937 int r;
938 936
939 if (!irqchip_in_kernel(kvm) && 937 if (!irqchip_in_kernel(kvm) &&
940 is_external_interrupt(exit_int_info)) 938 is_external_interrupt(exit_int_info))
941 push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK); 939 push_irq(&svm->vcpu, exit_int_info & SVM_EVTINJ_VEC_MASK);
942 940
943 mutex_lock(&kvm->lock);
944
945 fault_address = svm->vmcb->control.exit_info_2; 941 fault_address = svm->vmcb->control.exit_info_2;
946 error_code = svm->vmcb->control.exit_info_1; 942 error_code = svm->vmcb->control.exit_info_1;
947 r = kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code); 943 return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
948 if (r < 0) {
949 mutex_unlock(&kvm->lock);
950 return r;
951 }
952 if (!r) {
953 mutex_unlock(&kvm->lock);
954 return 1;
955 }
956 er = emulate_instruction(&svm->vcpu, kvm_run, fault_address,
957 error_code, 0);
958 mutex_unlock(&kvm->lock);
959
960 switch (er) {
961 case EMULATE_DONE:
962 return 1;
963 case EMULATE_DO_MMIO:
964 ++svm->vcpu.stat.mmio_exits;
965 return 0;
966 case EMULATE_FAIL:
967 kvm_report_emulation_failure(&svm->vcpu, "pagetable");
968 break;
969 default:
970 BUG();
971 }
972
973 kvm_run->exit_reason = KVM_EXIT_UNKNOWN;
974 return 0;
975} 944}
976 945
977static int ud_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run) 946static int ud_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)