VAPIC page is now actually enabled and active.
authorGanShun <ganshun@gmail.com>
Mon, 21 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)
Changed APIC_ACCESS_ADDR to be the physical address that's translated from guest physical address 0xfee00000 instead of being 0xfee00000

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

index 2aceaf3..c63508b 100644 (file)
@@ -1779,8 +1779,8 @@ int vmx_launch(struct vmctl *v) {
        int errors = 0;
        int advance;
        int interrupting = 0;
-       uintptr_t pir_kva, vapic_kva;
-       uint64_t pir_physical, vapic_physical;
+       uintptr_t pir_kva, vapic_kva, apic_kva;
+       uint64_t pir_physical, vapic_physical, apic_physical;
        struct proc * current_proc = current;
 
        /* TODO: dirty hack til we have VMM contexts */
@@ -1828,18 +1828,23 @@ int vmx_launch(struct vmctl *v) {
                        printk("Low order 12 bits of vapic address is not 0, value: %p\n", vapic_physical);
                }
 
-               vmcs_writel(APIC_ACCESS_ADDR, 0xfee00000);
-               vmcs_writel(APIC_ACCESS_ADDR_HIGH, 0);
+               printk("VAPIC PHYSICAL ADDRESS: %p\n", vapic_physical);
+
+               apic_kva = uva2kva(current_proc, (void *)0xfee00000);
+               apic_physical = (uint64_t)PADDR(apic_kva);
+
+               vmcs_writel(APIC_ACCESS_ADDR, apic_physical);
+               vmcs_writel(APIC_ACCESS_ADDR_HIGH, apic_physical>>32);
 
                // Clear the EOI exit bitmap(Gan)
-               vmcs_writel(EOI_EXIT_BITMAP0, 0);
-               vmcs_writel(EOI_EXIT_BITMAP0_HIGH, 0);
-               vmcs_writel(EOI_EXIT_BITMAP1, 0);
-               vmcs_writel(EOI_EXIT_BITMAP1_HIGH, 0);
-               vmcs_writel(EOI_EXIT_BITMAP2, 0);
-               vmcs_writel(EOI_EXIT_BITMAP2_HIGH, 0);
-               vmcs_writel(EOI_EXIT_BITMAP3, 0);
-               vmcs_writel(EOI_EXIT_BITMAP3_HIGH, 0);
+               vmcs_writel(EOI_EXIT_BITMAP0, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP0_HIGH, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP1, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP1_HIGH, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP2, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP2_HIGH, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP3, 0xFFFFFFFF);
+               vmcs_writel(EOI_EXIT_BITMAP3_HIGH, 0xFFFFFFFF);
 
                printk("v->apic %p v->pir %p\n", (void *)v->vapic, (void *)v->pir);
                // fallthrough
index 9630419..a169f59 100644 (file)
@@ -581,10 +581,10 @@ fprintf(stderr, "%p %p %p %p\n", PGSIZE, PGSHIFT, PML1_SHIFT, PML1_PTE_REACH);
        vmctl.pir = (uint64_t) a;
        memset(a, 0, 4096);
        a += 4096;
-       //vmctl.vapic = (uint64_t) a;
-       vmctl.vapic = (uint64_t) a_page;        
+       vmctl.vapic = (uint64_t) a;
+       //vmctl.vapic = (uint64_t) a_page;      
        memset(a, 0, 4096);
-       //((uint32_t *)a)[0x30/4] = 0x01060015;
+       ((uint32_t *)a)[0x30/4] = 0x01060014;
        p64 = a;
        // set up apic values? do we need to?
        // qemu does this.