aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/kvm/kvm.h3
-rw-r--r--drivers/kvm/kvm_main.c24
-rw-r--r--drivers/kvm/x86.c22
3 files changed, 26 insertions, 23 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a7be0733bc48..e34e246eafec 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -642,6 +642,9 @@ void kvm_arch_destroy_vm(struct kvm *kvm);
642int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu); 642int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
643int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu); 643int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
644 644
645int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
646 struct kvm_translation *tr);
647
645int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs); 648int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
646int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs); 649int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
647int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, 650int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index c782f27265de..3946025f3d37 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -761,28 +761,6 @@ void kvm_resched(struct kvm_vcpu *vcpu)
761} 761}
762EXPORT_SYMBOL_GPL(kvm_resched); 762EXPORT_SYMBOL_GPL(kvm_resched);
763 763
764/*
765 * Translate a guest virtual address to a guest physical address.
766 */
767static int kvm_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
768 struct kvm_translation *tr)
769{
770 unsigned long vaddr = tr->linear_address;
771 gpa_t gpa;
772
773 vcpu_load(vcpu);
774 mutex_lock(&vcpu->kvm->lock);
775 gpa = vcpu->mmu.gva_to_gpa(vcpu, vaddr);
776 tr->physical_address = gpa;
777 tr->valid = gpa != UNMAPPED_GVA;
778 tr->writeable = 1;
779 tr->usermode = 0;
780 mutex_unlock(&vcpu->kvm->lock);
781 vcpu_put(vcpu);
782
783 return 0;
784}
785
786static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, 764static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
787 struct kvm_interrupt *irq) 765 struct kvm_interrupt *irq)
788{ 766{
@@ -986,7 +964,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
986 r = -EFAULT; 964 r = -EFAULT;
987 if (copy_from_user(&tr, argp, sizeof tr)) 965 if (copy_from_user(&tr, argp, sizeof tr))
988 goto out; 966 goto out;
989 r = kvm_vcpu_ioctl_translate(vcpu, &tr); 967 r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr);
990 if (r) 968 if (r)
991 goto out; 969 goto out;
992 r = -EFAULT; 970 r = -EFAULT;
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 609792637fb4..f1746afab9e5 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2318,6 +2318,28 @@ struct fxsave {
2318#endif 2318#endif
2319}; 2319};
2320 2320
2321/*
2322 * Translate a guest virtual address to a guest physical address.
2323 */
2324int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
2325 struct kvm_translation *tr)
2326{
2327 unsigned long vaddr = tr->linear_address;
2328 gpa_t gpa;
2329
2330 vcpu_load(vcpu);
2331 mutex_lock(&vcpu->kvm->lock);
2332 gpa = vcpu->mmu.gva_to_gpa(vcpu, vaddr);
2333 tr->physical_address = gpa;
2334 tr->valid = gpa != UNMAPPED_GVA;
2335 tr->writeable = 1;
2336 tr->usermode = 0;
2337 mutex_unlock(&vcpu->kvm->lock);
2338 vcpu_put(vcpu);
2339
2340 return 0;
2341}
2342
2321int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 2343int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
2322{ 2344{
2323 struct fxsave *fxsave = (struct fxsave *)&vcpu->guest_fx_image; 2345 struct fxsave *fxsave = (struct fxsave *)&vcpu->guest_fx_image;