]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: Wire up hypercall handlers to a central arch-independent location
authorAvi Kivity <avi@qumranet.com>
Mon, 19 Feb 2007 12:37:47 +0000 (14:37 +0200)
committerAvi Kivity <avi@qumranet.com>
Sun, 4 Mar 2007 09:12:41 +0000 (11:12 +0200)
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm.h
drivers/kvm/kvm_main.c
drivers/kvm/svm.c
drivers/kvm/vmx.c

index fd7746a2bc3ed3e72780469d4cfe9910d4cf25a6..41cc27de4d66013ae2d8f20eab5330f149913bf3 100644 (file)
@@ -482,6 +482,8 @@ void kvm_mmu_post_write(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes);
 int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
 void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
 
 int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
 void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
 
+int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
+
 static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
                                     u32 error_code)
 {
 static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
                                     u32 error_code)
 {
index 757a41f1db843cf2cc4c7b087a635f7333e1eddb..2be9738dfd7888bf90cdd5541a75fd7a6abda8ec 100644 (file)
@@ -1138,6 +1138,42 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
 }
 EXPORT_SYMBOL_GPL(emulate_instruction);
 
 }
 EXPORT_SYMBOL_GPL(emulate_instruction);
 
+int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run)
+{
+       unsigned long nr, a0, a1, a2, a3, a4, a5, ret;
+
+       kvm_arch_ops->decache_regs(vcpu);
+       ret = -KVM_EINVAL;
+#ifdef CONFIG_X86_64
+       if (is_long_mode(vcpu)) {
+               nr = vcpu->regs[VCPU_REGS_RAX];
+               a0 = vcpu->regs[VCPU_REGS_RDI];
+               a1 = vcpu->regs[VCPU_REGS_RSI];
+               a2 = vcpu->regs[VCPU_REGS_RDX];
+               a3 = vcpu->regs[VCPU_REGS_RCX];
+               a4 = vcpu->regs[VCPU_REGS_R8];
+               a5 = vcpu->regs[VCPU_REGS_R9];
+       } else
+#endif
+       {
+               nr = vcpu->regs[VCPU_REGS_RBX] & -1u;
+               a0 = vcpu->regs[VCPU_REGS_RAX] & -1u;
+               a1 = vcpu->regs[VCPU_REGS_RCX] & -1u;
+               a2 = vcpu->regs[VCPU_REGS_RDX] & -1u;
+               a3 = vcpu->regs[VCPU_REGS_RSI] & -1u;
+               a4 = vcpu->regs[VCPU_REGS_RDI] & -1u;
+               a5 = vcpu->regs[VCPU_REGS_RBP] & -1u;
+       }
+       switch (nr) {
+       default:
+               ;
+       }
+       vcpu->regs[VCPU_REGS_RAX] = ret;
+       kvm_arch_ops->cache_regs(vcpu);
+       return 1;
+}
+EXPORT_SYMBOL_GPL(kvm_hypercall);
+
 static u64 mk_cr_64(u64 curr_cr, u32 new_val)
 {
        return (curr_cr & ~((1ULL << 32) - 1)) | new_val;
 static u64 mk_cr_64(u64 curr_cr, u32 new_val)
 {
        return (curr_cr & ~((1ULL << 32) - 1)) | new_val;
index aaa6742089e55a78fd7b3fb6ce7c801041a4a6e9..711ea42370a8e0ea1f9e042c97d4bec10aa91436 100644 (file)
@@ -1078,16 +1078,8 @@ static int halt_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 
 static int vmmcall_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
 
 static int vmmcall_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
-       printk(KERN_DEBUG "got vmmcall at RIP %08llx\n",
-              vcpu->svm->vmcb->save.rip);
-       printk(KERN_DEBUG "vmmcall params: %08llx, %08lx, %08lx, %08lx\n",
-              vcpu->svm->vmcb->save.rax,
-              vcpu->regs[VCPU_REGS_RCX],
-              vcpu->regs[VCPU_REGS_RDX],
-              vcpu->regs[VCPU_REGS_RBP]);
-       vcpu->svm->vmcb->save.rax = 0;
        vcpu->svm->vmcb->save.rip += 3;
        vcpu->svm->vmcb->save.rip += 3;
-       return 1;
+       return kvm_hypercall(vcpu, kvm_run);
 }
 
 static int invalid_op_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 }
 
 static int invalid_op_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
index ca79e594ea6e0669189b4ba8babfcdd7e83d7d0e..ff956a6302ec3d0fc33cd8a4c7cf7f3ddbeb2b56 100644 (file)
@@ -1659,16 +1659,8 @@ static int handle_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 
 static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
 
 static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
-       kvm_run->exit_reason = KVM_EXIT_DEBUG;
-       printk(KERN_DEBUG "got vmcall at RIP %08lx\n", vmcs_readl(GUEST_RIP));
-       printk(KERN_DEBUG "vmcall params: %08lx, %08lx, %08lx, %08lx\n",
-               vcpu->regs[VCPU_REGS_RAX],
-               vcpu->regs[VCPU_REGS_RCX],
-               vcpu->regs[VCPU_REGS_RDX],
-               vcpu->regs[VCPU_REGS_RBP]);
-       vcpu->regs[VCPU_REGS_RAX] = 0;
        vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP)+3);
        vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP)+3);
-       return 1;
+       return kvm_hypercall(vcpu, kvm_run);
 }
 
 /*
 }
 
 /*