Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Added NMI handler for SVM
[palacios.git] / palacios / src / palacios / vmm_time.c
index dea7cdb..fc2e37e 100644 (file)
@@ -22,7 +22,7 @@
 #include <palacios/vmm_time.h>
 #include <palacios/vm_guest.h>
 
-#ifndef CONFIG_DEBUG_TIME
+#ifndef V3_CONFIG_DEBUG_TIME
 #undef PrintDebug
 #define PrintDebug(fmt, args...)
 #endif
@@ -86,11 +86,21 @@ int v3_start_time(struct guest_info * info) {
     uint64_t t = v3_get_host_time(&info->time_state); 
 
     PrintDebug("Starting initial guest time as %llu\n", t);
+
     info->time_state.enter_time = 0;
     info->time_state.exit_time = t; 
     info->time_state.last_update = t;
     info->time_state.initial_time = t;
     info->yield_start_cycle = t;
+
+    return 0;
+}
+
+int v3_offset_time( struct guest_info * info, sint64_t offset )
+{
+    struct vm_time * time_state = &(info->time_state);
+//    PrintDebug("Adding additional offset of %lld to guest time.\n", offset);
+    time_state->guest_host_offset += offset;
     return 0;
 }
 
@@ -113,11 +123,14 @@ int v3_adjust_time(struct guest_info * info) {
      * sync up. */
     host_time = v3_get_host_time(time_state);
     old_guest_time = v3_get_guest_time(time_state);
+
     while (target_host_time > host_time) {
        v3_yield(info);
        host_time = v3_get_host_time(time_state);
     }
+
     guest_time = v3_get_guest_time(time_state);
+
     // We do *not* assume the guest timer was paused in the VM. If it was
     // this offseting is 0. If it wasn't we need this.
     v3_offset_time(info, (sint64_t)old_guest_time - (sint64_t)guest_time);
@@ -136,10 +149,11 @@ int v3_adjust_time(struct guest_info * info) {
        uint64_t max_skew, desired_skew, skew;
 
        if (time_state->enter_time) {
-           max_skew = (time_state->exit_time - time_state->enter_time)/10;
+           max_skew = (time_state->exit_time - time_state->enter_time) / 10;
        } else {
            max_skew = 0;
        }
+
        desired_skew = target_guest_time - guest_time;
        skew = desired_skew > max_skew ? max_skew : desired_skew;
 /*     PrintDebug("Guest %llu cycles behind where it should be.\n",
@@ -184,13 +198,7 @@ v3_time_enter_vm( struct guest_info * info )
     return 0;
 }
        
-int v3_offset_time( struct guest_info * info, sint64_t offset )
-{
-    struct vm_time * time_state = &(info->time_state);
-//    PrintDebug("Adding additional offset of %lld to guest time.\n", offset);
-    time_state->guest_host_offset += offset;
-    return 0;
-}
+
           
 struct v3_timer * v3_add_timer(struct guest_info * info, 
                               struct v3_timer_ops * ops, 
@@ -241,8 +249,10 @@ void v3_update_timers(struct guest_info * info) {
 
 int v3_rdtsc(struct guest_info * info) {
     uint64_t tscval = v3_get_guest_tsc(&info->time_state);
+
     info->vm_regs.rdx = tscval >> 32;
     info->vm_regs.rax = tscval & 0xffffffffLL;
+
     return 0;
 }
 
@@ -389,17 +399,19 @@ void v3_init_time_core(struct guest_info * info) {
 
     if (khz) {
        time_state->guest_cpu_freq = atoi(khz);
-       PrintDebug("Core %d CPU frequency requested at %d khz.\n", 
-                  info->cpu_id, time_state->guest_cpu_freq);
+       PrintDebug("Logical Core %d (vcpu=%d) CPU frequency requested at %d khz.\n", 
+                  info->pcpu_id, info->vcpu_id, time_state->guest_cpu_freq);
     } 
     
-    if ((khz == NULL) || (time_state->guest_cpu_freq <= 0) 
-       || (time_state->guest_cpu_freq > time_state->host_cpu_freq)) {
+    if ( (khz == NULL) || 
+        (time_state->guest_cpu_freq <= 0)  || 
+        (time_state->guest_cpu_freq > time_state->host_cpu_freq) ) {
+
        time_state->guest_cpu_freq = time_state->host_cpu_freq;
     }
 
-    PrintDebug("Core %d CPU frequency set to %d KHz (host CPU frequency = %d KHz).\n", 
-              info->cpu_id, 
+    PrintDebug("Logical Core %d (vcpu=%d) CPU frequency set to %d KHz (host CPU frequency = %d KHz).\n", 
+              info->pcpu_id, info->vcpu_id,
               time_state->guest_cpu_freq, 
               time_state->host_cpu_freq);
 
@@ -413,8 +425,6 @@ void v3_init_time_core(struct guest_info * info) {
     
     time_state->tsc_aux.lo = 0;
     time_state->tsc_aux.hi = 0;
-
-
 }
 
 
@@ -428,9 +438,3 @@ void v3_deinit_time_core(struct guest_info * core) {
     }
 
 }
-
-
-
-
-
-