vmm: Export the TSC freq via a vmcall (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 22 Nov 2017 16:44:23 +0000 (11:44 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 22 Nov 2017 16:49:34 +0000 (11:49 -0500)
This reduces the changes we make to the guest outside of akaros.c and
simplifies the commandline processing on our end.

Reinstall your kernel headers.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/ros/vmm.h
tests/vmm/vmrunkernel.c
user/vmm/vmexit.c

index 6ac39a0..4a015c7 100644 (file)
@@ -11,6 +11,7 @@
 /* VMCALL FUNCTION NUMBERS */
 #define VMCALL_PRINTC          0x1
 #define VMCALL_SMPBOOT         0x2
+#define VMCALL_GET_TSCFREQ     0x3
 
 #define VMM_CTL_GET_EXITS              1
 #define VMM_CTL_SET_EXITS              2
index 874d61a..e7bb89e 100644 (file)
@@ -387,7 +387,6 @@ int main(int argc, char **argv)
        uint64_t entry = 0;
        int ret;
        struct vm_trapframe *vm_tf;
-       uint64_t tsc_freq_khz;
        char *cmdlinep;
        int cmdlinesz, len, cmdline_fd;
        char *disk_image_file = NULL;
@@ -646,9 +645,7 @@ int main(int argc, char **argv)
 
        bp->hdr.cmd_line_ptr = (uintptr_t) cmdline;
 
-       tsc_freq_khz = get_tsc_freq()/1000;
-       len = snprintf(cmdline, 4096, "%s tscfreq=%lld %s", cmdline_default,
-                      tsc_freq_khz, cmdline_extra);
+       len = snprintf(cmdline, 4096, "%s %s", cmdline_default, cmdline_extra);
 
        cmdlinesz = 4096 - len;
        cmdlinep = cmdline + len;
index 4c5db6a..dfef6c0 100644 (file)
@@ -221,6 +221,16 @@ static bool handle_vmcall_smpboot(struct guest_thread *gth)
        return TRUE;
 }
 
+static bool handle_vmcall_get_tscfreq(struct guest_thread *gth)
+{
+       struct vm_trapframe *vm_tf = gth_to_vmtf(gth);
+       struct vm_trapframe *vm_tf_ap;
+       struct virtual_machine *vm = gth_to_vm(gth);
+
+       vm_tf->tf_rax = get_tsc_freq() / 1000;
+       return TRUE;
+}
+
 static bool handle_vmcall(struct guest_thread *gth)
 {
        struct vm_trapframe *vm_tf = gth_to_vmtf(gth);
@@ -231,12 +241,15 @@ static bool handle_vmcall(struct guest_thread *gth)
                return vm->vmcall(gth, vm_tf);
 
        switch (vm_tf->tf_rax) {
-               case VMCALL_PRINTC:
-                       retval = handle_vmcall_printc(gth);
-                       break;
-               case VMCALL_SMPBOOT:
-                       retval = handle_vmcall_smpboot(gth);
-                       break;
+       case VMCALL_PRINTC:
+               retval = handle_vmcall_printc(gth);
+               break;
+       case VMCALL_SMPBOOT:
+               retval = handle_vmcall_smpboot(gth);
+               break;
+       case VMCALL_GET_TSCFREQ:
+               retval = handle_vmcall_get_tscfreq(gth);
+               break;
        }
 
        if (retval)