KVM: Provide unlocked version of emulator_write_phys()
authorAvi Kivity <avi@qumranet.com>
Sun, 2 Mar 2008 12:06:05 +0000 (14:06 +0200)
committerAvi Kivity <avi@qumranet.com>
Sun, 27 Apr 2008 09:00:26 +0000 (12:00 +0300)
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/x86.c
include/asm-x86/kvm_host.h

index 1b9e695cc64116f34270da7be083a0c53094e98d..03ba402c476ad202c857eb9aa5e26652ba44b483 100644 (file)
@@ -1840,22 +1840,29 @@ mmio:
        return X86EMUL_UNHANDLEABLE;
 }
 
-static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
-                              const void *val, int bytes)
+int __emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
+                         const void *val, int bytes)
 {
        int ret;
 
-       down_read(&vcpu->kvm->slots_lock);
        ret = kvm_write_guest(vcpu->kvm, gpa, val, bytes);
-       if (ret < 0) {
-               up_read(&vcpu->kvm->slots_lock);
+       if (ret < 0)
                return 0;
-       }
        kvm_mmu_pte_write(vcpu, gpa, val, bytes);
-       up_read(&vcpu->kvm->slots_lock);
        return 1;
 }
 
+static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
+                       const void *val, int bytes)
+{
+       int ret;
+
+       down_read(&vcpu->kvm->slots_lock);
+       ret =__emulator_write_phys(vcpu, gpa, val, bytes);
+       up_read(&vcpu->kvm->slots_lock);
+       return ret;
+}
+
 static int emulator_write_emulated_onepage(unsigned long addr,
                                           const void *val,
                                           unsigned int bytes,
index 26a313a09472e3833b78aafd4c2b4ba147029da3..99d31f5ed9ff14f90e0ed3078c7bb6be4e3c4b5a 100644 (file)
@@ -432,6 +432,9 @@ void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
 
 int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
 
+int __emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
+                         const void *val, int bytes);
+
 enum emulation_result {
        EMULATE_DONE,       /* no further processing */
        EMULATE_DO_MMIO,      /* kvm_run filled with mmio request */