Begin work on true virtio mmio Kill tests/vmrunkernel.c Our makefiles, plus emacs...
[akaros.git] / kern / arch / x86 / vmm / intel / vmx.c
index cd46ff7..e4198fc 100644 (file)
@@ -1591,13 +1591,17 @@ static int vmx_handle_ept_violation(struct vmx_vcpu *vcpu, struct vmctl *v) {
        prot |= exit_qual & VMX_EPT_FAULT_INS ? PROT_EXEC : 0;
        ret = handle_page_fault(current, gpa, prot);
 
-       if (ret) {
+       // Some of these get fixed in the vmm; be less chatty now.
+       if (0 && ret) {
                printk("EPT page fault failure %d, GPA: %p, GVA: %p\n", ret, gpa,
                       gva);
                vmx_dump_cpu(vcpu);
        }
 
-       return ret;
+       /* we let the vmm handle the failure cases. So return
+        * the VMX exit violation, not what handle_page_fault returned.
+        */
+       return EXIT_REASON_EPT_VIOLATION;
 }
 
 static void vmx_handle_cpuid(struct vmx_vcpu *vcpu) {
@@ -1658,13 +1662,16 @@ int vmx_launch(struct vmctl *v) {
                printk("REG_ALL\n");
                // fallthrough
                vcpu->regs = v->regs;
+               vmcs_writel(GUEST_RSP, v->regs.tf_rsp);
+               vmcs_writel(GUEST_RIP, v->regs.tf_rip);
+               break;
        case REG_RSP_RIP_CR3:
                printk("REG_RSP_RIP_CR3\n");
                vmcs_writel(GUEST_RSP, v->regs.tf_rsp);
                vmcs_writel(GUEST_CR3, v->cr3);
                // fallthrough
        case REG_RIP:
-               printk("REG_RIP\n");
+               printk("REG_RIP %p\n", v->regs.tf_rip);
                vmcs_writel(GUEST_RIP, v->regs.tf_rip);
                break;
        case RESUME:
@@ -1673,6 +1680,7 @@ int vmx_launch(struct vmctl *v) {
        default: 
                error(EINVAL, "Bad command in vmx_launch");
        }
+       vcpu->shutdown = 0;
        vmx_put_cpu(vcpu);
        vcpu->ret_code = -1;
 
@@ -1743,7 +1751,7 @@ int vmx_launch(struct vmctl *v) {
                } else {
                        printk("unhandled exit: reason 0x%x, exit qualification 0x%x\n",
                               ret, vmcs_read32(EXIT_QUALIFICATION));
-                       vmx_dump_cpu(vcpu);
+                       //vmx_dump_cpu(vcpu);
                        vcpu->shutdown = SHUTDOWN_UNHANDLED_EXIT_REASON;
                }
 
@@ -1760,11 +1768,11 @@ int vmx_launch(struct vmctl *v) {
                }
        }
 
-       printd("RETURN. ip %016lx sp %016lx\n",
-              vcpu->regs.tf_rip, vcpu->regs.tf_rsp);
+       printk("RETURN. ip %016lx sp %016lx, shutdown 0x%lx ret 0x%lx\n",
+              vcpu->regs.tf_rip, vcpu->regs.tf_rsp, vcpu->shutdown, vcpu->shutdown);
        v->regs = vcpu->regs;
        v->shutdown = vcpu->shutdown;
-       v->ret_code = vcpu->ret_code;
+       v->ret_code = ret;
 //  hexdump((void *)vcpu->regs.tf_rsp, 128 * 8);
        /*
         * Return both the reason for the shutdown and a status value.