aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/vmx.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/vmx.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/vmx.c')
-rw-r--r--drivers/kvm/vmx.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 2d7d638d72d0..7fe834cb0d81 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1796,7 +1796,6 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1796 unsigned long cr2, rip; 1796 unsigned long cr2, rip;
1797 u32 vect_info; 1797 u32 vect_info;
1798 enum emulation_result er; 1798 enum emulation_result er;
1799 int r;
1800 1799
1801 vect_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); 1800 vect_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
1802 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); 1801 intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
@@ -1834,33 +1833,7 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1834 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE); 1833 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
1835 if (is_page_fault(intr_info)) { 1834 if (is_page_fault(intr_info)) {
1836 cr2 = vmcs_readl(EXIT_QUALIFICATION); 1835 cr2 = vmcs_readl(EXIT_QUALIFICATION);
1837 1836 return kvm_mmu_page_fault(vcpu, cr2, error_code);
1838 mutex_lock(&vcpu->kvm->lock);
1839 r = kvm_mmu_page_fault(vcpu, cr2, error_code);
1840 if (r < 0) {
1841 mutex_unlock(&vcpu->kvm->lock);
1842 return r;
1843 }
1844 if (!r) {
1845 mutex_unlock(&vcpu->kvm->lock);
1846 return 1;
1847 }
1848
1849 er = emulate_instruction(vcpu, kvm_run, cr2, error_code, 0);
1850 mutex_unlock(&vcpu->kvm->lock);
1851
1852 switch (er) {
1853 case EMULATE_DONE:
1854 return 1;
1855 case EMULATE_DO_MMIO:
1856 ++vcpu->stat.mmio_exits;
1857 return 0;
1858 case EMULATE_FAIL:
1859 kvm_report_emulation_failure(vcpu, "pagetable");
1860 break;
1861 default:
1862 BUG();
1863 }
1864 } 1837 }
1865 1838
1866 if (vcpu->rmode.active && 1839 if (vcpu->rmode.active &&