VMM: init the vmexit counters when initing the VMM
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 25 Jan 2016 16:42:08 +0000 (11:42 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 2 Feb 2016 22:43:52 +0000 (17:43 -0500)
Previously, this was just done during the first vmctl command
(REG_RSP_RIP_CR3).  It's really a "once per VMM per process" thing.  In the
future, we could add commands to reset the counters or something.  Still,
the initial initialization should be when setting up the VMM in the first
place.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/vmm/intel/vmx.c
kern/arch/x86/vmm/vmm.c
kern/arch/x86/vmm/vmm.h

index 1ba3b65..cb100e3 100644 (file)
@@ -1858,10 +1858,6 @@ int vmx_launch(struct vmctl *v) {
                vmcs_writel(EOI_EXIT_BITMAP3_HIGH, 0);
 
                printk("v->apic %p v->pir %p\n", (void *)v->vapic, (void *)v->pir);
-
-               // Initialize vmexits counter
-               for (int i = 0; i < 65; i++)
-                       current_proc->vmm.vmexits[i] = 0;
                // fallthrough
        case REG_RIP:
                printd("REG_RIP %p\n", v->regs.tf_rip);
index c078b04..d75e48a 100644 (file)
@@ -129,6 +129,8 @@ int vmm_struct_init(struct proc *p, unsigned int nr_guest_pcores, int flags)
                }
        }
        vmm->nr_guest_pcores = i;
+       for (int i = 0; i < VMM_VMEXIT_NR_TYPES; i++)
+               vmm->vmexits[i] = 0;
        qunlock(&vmm->qlock);
        return i;
 }
index 17a06e3..d36abf0 100644 (file)
@@ -14,6 +14,8 @@ static inline int cpu_has_svm(const char **msg)
        return 0;
 }
 
+#define VMM_VMEXIT_NR_TYPES            65
+
 struct vmm {
        qlock_t qlock;
        // always false.
@@ -38,7 +40,7 @@ struct vmm {
                void *svm;
                struct vmx_vcpu **guest_pcores;
        };
-       unsigned long vmexits[65];      /* TODO: use a #define from a header */
+       unsigned long vmexits[VMM_VMEXIT_NR_TYPES];
 };
 
 void vmm_init(void);