KVM: Add host hypercall support for vmx

Signed-off-by: Avi Kivity <avi@qumranet.com>

authored by

Ingo Molnar and committed by
Avi Kivity
c21415e8 102d8325

+33
+15
drivers/kvm/vmx.c
··· 1657 1657 return 0; 1658 1658 } 1659 1659 1660 + static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1661 + { 1662 + kvm_run->exit_reason = KVM_EXIT_DEBUG; 1663 + printk(KERN_DEBUG "got vmcall at RIP %08lx\n", vmcs_readl(GUEST_RIP)); 1664 + printk(KERN_DEBUG "vmcall params: %08lx, %08lx, %08lx, %08lx\n", 1665 + vcpu->regs[VCPU_REGS_RAX], 1666 + vcpu->regs[VCPU_REGS_RCX], 1667 + vcpu->regs[VCPU_REGS_RDX], 1668 + vcpu->regs[VCPU_REGS_RBP]); 1669 + vcpu->regs[VCPU_REGS_RAX] = 0; 1670 + vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP)+3); 1671 + return 1; 1672 + } 1673 + 1660 1674 /* 1661 1675 * The exit handlers return 1 if the exit was handled fully and guest execution 1662 1676 * may resume. Otherwise they set the kvm_run parameter to indicate what needs ··· 1689 1675 [EXIT_REASON_MSR_WRITE] = handle_wrmsr, 1690 1676 [EXIT_REASON_PENDING_INTERRUPT] = handle_interrupt_window, 1691 1677 [EXIT_REASON_HLT] = handle_halt, 1678 + [EXIT_REASON_VMCALL] = handle_vmcall, 1692 1679 }; 1693 1680 1694 1681 static const int kvm_vmx_max_exit_handlers =
+18
include/linux/kvm_para.h
··· 52 52 53 53 #define KVM_EINVAL 1 54 54 55 + /* 56 + * Hypercall calling convention: 57 + * 58 + * Each hypercall may have 0-6 parameters. 59 + * 60 + * 64-bit hypercall index is in RAX, goes from 0 to __NR_hypercalls-1 61 + * 62 + * 64-bit parameters 1-6 are in the standard gcc x86_64 calling convention 63 + * order: RDI, RSI, RDX, RCX, R8, R9. 64 + * 65 + * 32-bit index is EBX, parameters are: EAX, ECX, EDX, ESI, EDI, EBP. 66 + * (the first 3 are according to the gcc regparm calling convention) 67 + * 68 + * No registers are clobbered by the hypercall, except that the 69 + * return value is in RAX. 70 + */ 71 + #define __NR_hypercalls 0 72 + 55 73 #endif