aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kvm/x86.c21
-rw-r--r--include/asm-x86/kvm_host.h3
2 files changed, 17 insertions, 7 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1b9e695cc641..03ba402c476a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1840,22 +1840,29 @@ mmio:
1840 return X86EMUL_UNHANDLEABLE; 1840 return X86EMUL_UNHANDLEABLE;
1841} 1841}
1842 1842
1843static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, 1843int __emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1844 const void *val, int bytes) 1844 const void *val, int bytes)
1845{ 1845{
1846 int ret; 1846 int ret;
1847 1847
1848 down_read(&vcpu->kvm->slots_lock);
1849 ret = kvm_write_guest(vcpu->kvm, gpa, val, bytes); 1848 ret = kvm_write_guest(vcpu->kvm, gpa, val, bytes);
1850 if (ret < 0) { 1849 if (ret < 0)
1851 up_read(&vcpu->kvm->slots_lock);
1852 return 0; 1850 return 0;
1853 }
1854 kvm_mmu_pte_write(vcpu, gpa, val, bytes); 1851 kvm_mmu_pte_write(vcpu, gpa, val, bytes);
1855 up_read(&vcpu->kvm->slots_lock);
1856 return 1; 1852 return 1;
1857} 1853}
1858 1854
1855static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1856 const void *val, int bytes)
1857{
1858 int ret;
1859
1860 down_read(&vcpu->kvm->slots_lock);
1861 ret =__emulator_write_phys(vcpu, gpa, val, bytes);
1862 up_read(&vcpu->kvm->slots_lock);
1863 return ret;
1864}
1865
1859static int emulator_write_emulated_onepage(unsigned long addr, 1866static int emulator_write_emulated_onepage(unsigned long addr,
1860 const void *val, 1867 const void *val,
1861 unsigned int bytes, 1868 unsigned int bytes,
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 26a313a09472..99d31f5ed9ff 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -432,6 +432,9 @@ void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
432 432
433int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 433int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
434 434
435int __emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
436 const void *val, int bytes);
437
435enum emulation_result { 438enum emulation_result {
436 EMULATE_DONE, /* no further processing */ 439 EMULATE_DONE, /* no further processing */
437 EMULATE_DO_MMIO, /* kvm_run filled with mmio request */ 440 EMULATE_DO_MMIO, /* kvm_run filled with mmio request */