VMMCP: upgrade for newer cpu.
authorRonald G. Minnich <rminnich@gmail.com>
Tue, 1 Sep 2015 22:20:20 +0000 (15:20 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Nov 2015 23:53:51 +0000 (18:53 -0500)
We will allow monitor/mwait.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/vmm/intel/vmx.c
tests/vmm/vmrunkernel.c

index 57994b7..31e37bc 100644 (file)
@@ -517,17 +517,18 @@ static const struct vmxec cbec = {
        .msr = MSR_IA32_VMX_PROCBASED_CTLS,
        .truemsr = MSR_IA32_VMX_TRUE_PROCBASED_CTLS,
 
-       .must_be_1 = (CPU_BASED_HLT_EXITING |
-                    CPU_BASED_MWAIT_EXITING |
+       .must_be_1 = (CPU_BASED_MWAIT_EXITING |
+                       CPU_BASED_HLT_EXITING |
+                    CPU_BASED_TPR_SHADOW |
                     CPU_BASED_RDPMC_EXITING |
                     CPU_BASED_CR8_LOAD_EXITING |
                     CPU_BASED_CR8_STORE_EXITING |
                     CPU_BASED_USE_MSR_BITMAPS |
-                    CPU_BASED_MONITOR_EXITING |
                     CPU_BASED_USE_IO_BITMAPS |
                     CPU_BASED_ACTIVATE_SECONDARY_CONTROLS),
 
-       .must_be_0 = (CPU_BASED_VIRTUAL_INTR_PENDING |
+       .must_be_0 = (
+                       CPU_BASED_VIRTUAL_INTR_PENDING |
                     CPU_BASED_INVLPG_EXITING |
                     CPU_BASED_USE_TSC_OFFSETING |
                     CPU_BASED_RDTSC_EXITING |
@@ -537,10 +538,9 @@ static const struct vmxec cbec = {
                     CPU_BASED_VIRTUAL_NMI_PENDING |
                     CPU_BASED_MONITOR_TRAP |
                     CPU_BASED_PAUSE_EXITING |
-
-                    CPU_BASED_TPR_SHADOW |
-
                     CPU_BASED_UNCOND_IO_EXITING),
+
+       .try_set_0 = (CPU_BASED_MONITOR_EXITING)
 };
 
 static const struct vmxec cb2ec = {
@@ -549,14 +549,14 @@ static const struct vmxec cb2ec = {
        .truemsr = MSR_IA32_VMX_PROCBASED_CTLS2,
 
        .must_be_1 = (SECONDARY_EXEC_ENABLE_EPT |
-                    //SECONDARY_EXEC_APIC_REGISTER_VIRT |
-                    //SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
+                    SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
+                    SECONDARY_EXEC_APIC_REGISTER_VIRT |
+                    SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
                     SECONDARY_EXEC_WBINVD_EXITING),
 
        .must_be_0 = (
-                       SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
-                    SECONDARY_EXEC_APIC_REGISTER_VIRT |
-                    SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
+                    //SECONDARY_EXEC_APIC_REGISTER_VIRT |
+                    //SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
                     SECONDARY_EXEC_DESCRIPTOR_EXITING |
                     SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
                     SECONDARY_EXEC_ENABLE_VPID |
@@ -570,7 +570,10 @@ static const struct vmxec cb2ec = {
                     SECONDARY_EPT_VE |
                     SECONDARY_ENABLE_XSAV_RESTORE),
 
-       .try_set_1 = SECONDARY_EXEC_RDTSCP
+       .try_set_1 = SECONDARY_EXEC_RDTSCP,
+
+       // mystery bit.
+       .try_set_0 = 0x2000000
 
 };
 
@@ -1748,8 +1751,8 @@ int vmx_launch(struct vmctl *v) {
                 */
                if (v->interrupt) {
                        printk("Set VM_ENTRY_INFTR_INFO_FIELD to 0x%x\n", v->interrupt);
-                       vmcs_writel(VM_ENTRY_INTR_INFO_FIELD, v->interrupt);
-                       //vmx_set_rvi(v->interrupt);
+                       //vmcs_writel(VM_ENTRY_INTR_INFO_FIELD, v->interrupt);
+                       vmx_set_rvi(v->interrupt);
                        v->interrupt = 0;
                        interrupting = 1;
                }
index 409e349..7a50fc0 100644 (file)
@@ -662,6 +662,22 @@ fprintf(stderr, "%p %p %p %p\n", PGSIZE, PGSHIFT, PML1_SHIFT, PML1_PTE_REACH);
                                        showstatus(stderr, &vmctl);
                                }
                                break;
+                       case EXIT_REASON_MWAIT_INSTRUCTION:
+                         fflush(stdout);
+                               if (debug)fprintf(stderr, "\n================== Guest MWAIT. =======================\n");
+                               if (debug)fprintf(stderr, "Wait for cons data\n");
+                               while (!consdata)
+                                       ;
+                               //debug = 1;
+                               if (debug)fprintf(stderr, "Resume with consdata ...\n");
+                               vmctl.regs.tf_rip += 3;
+                               ret = write(fd, &vmctl, sizeof(vmctl));
+                               if (ret != sizeof(vmctl)) {
+                                       perror(cmd);
+                               }
+                               //fprintf(stderr, "RIP %p, shutdown 0x%x\n", vmctl.regs.tf_rip, vmctl.shutdown);
+                               //showstatus(stderr, &vmctl);
+                               break;
                        case EXIT_REASON_HLT:
                                fflush(stdout);
                                if (debug)fprintf(stderr, "\n================== Guest halted. =======================\n");