]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: Add host hypercall support for vmx
authorIngo Molnar <mingo@elte.hu>
Mon, 19 Feb 2007 12:37:47 +0000 (14:37 +0200)
committerAvi Kivity <avi@qumranet.com>
Sun, 4 Mar 2007 09:12:40 +0000 (11:12 +0200)
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/vmx.c
include/linux/kvm_para.h

index 0198d400037f7196ee98e5cb54610e9ab559ff9b..ca79e594ea6e0669189b4ba8babfcdd7e83d7d0e 100644 (file)
@@ -1657,6 +1657,20 @@ static int handle_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        return 0;
 }
 
+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);
+       return 1;
+}
+
 /*
  * The exit handlers return 1 if the exit was handled fully and guest execution
  * may resume.  Otherwise they set the kvm_run parameter to indicate what needs
@@ -1675,6 +1689,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu,
        [EXIT_REASON_MSR_WRITE]               = handle_wrmsr,
        [EXIT_REASON_PENDING_INTERRUPT]       = handle_interrupt_window,
        [EXIT_REASON_HLT]                     = handle_halt,
+       [EXIT_REASON_VMCALL]                  = handle_vmcall,
 };
 
 static const int kvm_vmx_max_exit_handlers =
index 74be5c1002ec77ffc797babd914e1c7e2bfd68dc..3b292565a693c2363283b50fdac72880e5cca0b2 100644 (file)
@@ -52,4 +52,22 @@ struct kvm_vcpu_para_state {
 
 #define KVM_EINVAL 1
 
+/*
+ * Hypercall calling convention:
+ *
+ * Each hypercall may have 0-6 parameters.
+ *
+ * 64-bit hypercall index is in RAX, goes from 0 to __NR_hypercalls-1
+ *
+ * 64-bit parameters 1-6 are in the standard gcc x86_64 calling convention
+ * order: RDI, RSI, RDX, RCX, R8, R9.
+ *
+ * 32-bit index is EBX, parameters are: EAX, ECX, EDX, ESI, EDI, EBP.
+ * (the first 3 are according to the gcc regparm calling convention)
+ *
+ * No registers are clobbered by the hypercall, except that the
+ * return value is in RAX.
+ */
+#define __NR_hypercalls                        0
+
 #endif