Commit 617bbcec authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

Simple temp implementation of vmcall (to be filled in for ipc).

parent 40de4ae2
......@@ -1582,6 +1582,11 @@ void lcd_arch_destroy(struct lcd_arch *vcpu)
/* VMX EXIT HANDLING -------------------------------------------------- */
/**
* Skips to next instruction in lcd. This should only be
* called when a vm exit occurs that sets the exit
* instruction length. See Intel SDM V3 27.2.4.
*/
static void vmx_step_instruction(void)
{
vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP) +
......@@ -1590,8 +1595,8 @@ static void vmx_step_instruction(void)
static void vmx_handle_vmcall(struct lcd_arch *vcpu)
{
/* not implemented yet until we get to ipc */
return -EIO;
}
/**
......@@ -1989,7 +1994,7 @@ int lcd_arch_run(struct lcd_arch *vcpu)
ret = vmx_handle_external_int(vcpu);
break;
case EXIT_REASON_VMCALL:
vmx_handle_vmcall(vcpu);
ret = vmx_handle_vmcall(vcpu);
break;
case EXIT_REASON_EPT_VIOLATION:
ret = vmx_handle_ept(vcpu);
......
......@@ -1805,61 +1805,61 @@ static void setup_idt(struct lcd* vcpu) {
/* return vcpu->exit_reason; */
/* } */
static void vmx_step_instruction(void) {
vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP) +
vmcs_read32(VM_EXIT_INSTRUCTION_LEN));
}
static int vmx_handle_ept_violation(struct lcd *vcpu) {
unsigned long gva, gpa;
int ret;
/* static void vmx_step_instruction(void) { */
/* vmcs_writel(GUEST_RIP, vmcs_readl(GUEST_RIP) + */
/* vmcs_read32(VM_EXIT_INSTRUCTION_LEN)); */
/* } */
vmx_get_cpu(vcpu);
gva = vmcs_readl(GUEST_LINEAR_ADDRESS);
gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS);
vmx_put_cpu(vcpu);
/* static int vmx_handle_ept_violation(struct lcd *vcpu) { */
/* unsigned long gva, gpa; */
/* int ret; */
if (vcpu->exit_qualification & (1 << 6)) {
printk(KERN_ERR "EPT: GPA 0x%lx exceeds GAW!\n", gpa);
return -EINVAL;
}
/* vmx_get_cpu(vcpu); */
/* gva = vmcs_readl(GUEST_LINEAR_ADDRESS); */
/* gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); */
/* vmx_put_cpu(vcpu); */
if (!(vcpu->exit_qualification & (1 << 7))) {
printk(KERN_ERR "EPT: linear address is not valid, GPA: 0x%lx!\n", gpa);
return -EINVAL;
}
/* if (vcpu->exit_qualification & (1 << 6)) { */
/* printk(KERN_ERR "EPT: GPA 0x%lx exceeds GAW!\n", gpa); */
/* return -EINVAL; */
/* } */
/*
* EPT Fault.
* TODO: lock page table?
*/
if (gpa < LCD_PHY_MEM_SIZE) {
u64 gpa_pg;
u64 pg = __get_free_page(GFP_KERNEL);
if (!pg)
ret = -ENOMEM;
else {
gpa_pg = round_down(gpa, PAGE_SIZE);
ret = lcd_map_gpa_to_hpa(vcpu, gpa_pg, __pa(pg), 0);
if (ret) {
printk(KERN_ERR "EPT: map page %p for %p failed\n",
(void*)pg, (void*)gpa_pg);
free_page(pg);
}
}
} else
ret = -EINVAL;
/* if (!(vcpu->exit_qualification & (1 << 7))) { */
/* printk(KERN_ERR "EPT: linear address is not valid, GPA: 0x%lx!\n", gpa); */
/* return -EINVAL; */
/* } */
if (ret) {
printk(KERN_ERR "vmx: EPT violation failure "
"GPA: 0x%lx, GVA: 0x%lx\n",
gpa, gva);
vcpu->ret_code = ((EFAULT) << 8);
vmx_dump_cpu(vcpu);
}
/* /\* */
/* * EPT Fault. */
/* * TODO: lock page table? */
/* *\/ */
/* if (gpa < LCD_PHY_MEM_SIZE) { */
/* u64 gpa_pg; */
/* u64 pg = __get_free_page(GFP_KERNEL); */
/* if (!pg) */
/* ret = -ENOMEM; */
/* else { */
/* gpa_pg = round_down(gpa, PAGE_SIZE); */
/* ret = lcd_map_gpa_to_hpa(vcpu, gpa_pg, __pa(pg), 0); */
/* if (ret) { */
/* printk(KERN_ERR "EPT: map page %p for %p failed\n", */
/* (void*)pg, (void*)gpa_pg); */
/* free_page(pg); */
/* } */
/* } */
/* } else */
/* ret = -EINVAL; */
/* if (ret) { */
/* printk(KERN_ERR "vmx: EPT violation failure " */
/* "GPA: 0x%lx, GVA: 0x%lx\n", */
/* gpa, gva); */
/* vcpu->ret_code = ((EFAULT) << 8); */
/* vmx_dump_cpu(vcpu); */
/* } */
return ret;
}
/* return ret; */
/* } */
/* static int __vmx_enable(struct vmcs *vmxon_buf) { */
/* u64 phys_addr = __pa(vmxon_buf); */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment