vmmcp: add higherkernbase, more debugging.
authorRonald G. Minnich <rminnich@gmail.com>
Mon, 29 Jun 2015 17:27:56 +0000 (10:27 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Nov 2015 23:24:25 +0000 (18:24 -0500)
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 c873093..8b4e60a 100644 (file)
@@ -1414,6 +1414,10 @@ int vmx_launch(uint64_t rip, uint64_t rsp, uint64_t cr3)
                if (ret == EXIT_REASON_VMCALL) {
                        if (current->vmm.flags & VMM_VMCALL_PRINTF) {
                                uint8_t byte = vcpu->regs.tf_rdi;
+                               printd("System call\n");
+#ifdef DEBUG
+                               vmx_dump_cpu(vcpu);
+#endif
                                printk("%c", byte);
                                // adjust the RIP
                                vmx_get_cpu(vcpu);
@@ -1457,7 +1461,7 @@ int vmx_launch(uint64_t rip, uint64_t rsp, uint64_t cr3)
 
        printd("RETURN. ip %016lx sp %016lx\n",
                vcpu->regs.tf_rip, vcpu->regs.tf_rsp);
-
+//     hexdump((void *)vcpu->regs.tf_rsp, 128 * 8);
        /*
         * Return both the reason for the shutdown and a status value.
         * The exit() and exit_group() system calls only need 8 bits for
index d878fa8..4640888 100644 (file)
@@ -48,13 +48,13 @@ int main(int argc, char **argv)
 {
        int amt;
        int vmmflags = VMM_VMCALL_PRINTF;
-       uint64_t entry = 0x101000c, kerneladdress = 0x1010000;
+       uint64_t entry = 0x1000000, kerneladdress = 0x1000000;
        int nr_gpcs = 1;
        int fd = open("#cons/sysctl", O_RDWR), ret;
        void * x;
        int kfd = -1;
        static char cmd[512];
-       void *coreboot_tables;
+       void *coreboot_tables = (void *) 0x1165000;
        /* kernel has to be in the range 16M to 64M for now. */
        // mmap is not working for us at present.
        if ((uint64_t)_kernel > 16*1048576) {
@@ -69,6 +69,7 @@ int main(int argc, char **argv)
        }
        argc--,argv++;
        // switches ...
+       // Sorry, I don't much like the gnu opt parsing code.
        while (1) {
                if (*argv[0] != '-')
                        break;
@@ -83,10 +84,11 @@ int main(int argc, char **argv)
                argc--,argv++;
        }
        if (argc < 1) {
-               fprintf(stderr, "Usage: %s vmimage coreboot_tables [loadaddress [entrypoint]]\n", argv[0]);
+               fprintf(stderr, "Usage: %s vmimage [-n (no vmcall printf)] [coreboot_tables [loadaddress [entrypoint]]]\n", argv[0]);
                exit(1);
        }
-       coreboot_tables = (void *) strtoull(argv[1], 0, 0);
+       if (argc > 1)
+               coreboot_tables = (void *) strtoull(argv[1], 0, 0);
        if (argc > 2)
                kerneladdress = strtoull(argv[2], 0, 0);
        if (argc > 3)
@@ -175,8 +177,11 @@ int main(int argc, char **argv)
        p1 = &p512[512];
        p2m = &p512[1024];
        uint64_t kernbase = 0; //0xffffffff80000000;
+       uint64_t highkernbase = 0xffffffff80000000;
        p512[PML4(kernbase)] = (unsigned long long)p1 | 7;
        p1[PML3(kernbase)] = /*0x87; */(unsigned long long)p2m | 7;
+       p512[PML4(highkernbase)] = (unsigned long long)p1 | 7;
+       p1[PML3(highkernbase)] = /*0x87; */(unsigned long long)p2m | 7;
 #define _2MiB (0x200000)
        int i;
        for (i = 0; i < 512; i++) {