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.


Minor cleanups on time handling.
Patrick G. Bridges [Wed, 20 Oct 2010 19:27:37 +0000 (13:27 -0600)]
palacios/src/palacios/svm.c
palacios/src/palacios/vmm_time.c
palacios/src/palacios/vmx.c

index 775a379..3ac98d4 100644 (file)
@@ -97,6 +97,12 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) {
     ctrl_area->instrs.CPUID = 1;
 
     ctrl_area->instrs.HLT = 1;
+
+#ifdef CONFIG_TIME_VIRTUALIZE_TSC
+    ctrl_area->instrs.rdtsc = 1;
+    ctrl_area->svm_instrs.rdtscp = 1;
+#endif
+
     // guest_state->cr0 = 0x00000001;    // PE 
   
     /*
index 2d5c74e..e191e9f 100644 (file)
@@ -81,20 +81,23 @@ int v3_start_time(struct guest_info * info) {
 
 // If the guest is supposed to run slower than the host, yield out until
 // the host time is appropriately far along;
-int v3_adjust_time(struct guest_info * info)
-{
+int v3_adjust_time(struct guest_info * info) {
     struct vm_time * time_state = &(info->time_state);
-    uint64_t guest_time, host_time, target_host_time;
-    guest_time = v3_get_guest_time(time_state);
-    host_time = v3_get_host_time(time_state);
-    target_host_time = (host_time - time_state->initial_time) *
-       time_state->host_cpu_freq / time_state->guest_cpu_freq;
-
-    while (host_time < target_host_time) {
-       v3_yield(info);
+    if (time_state->host_cpu_freq == time_state->guest_cpu_freq) {
+       time_state->guest_host_offset = 0;
+    } else {
+       uint64_t guest_time, host_time, target_host_time;
+       guest_time = v3_get_guest_time(time_state);
        host_time = v3_get_host_time(time_state);
+       target_host_time = (host_time - time_state->initial_time) *
+           time_state->host_cpu_freq / time_state->guest_cpu_freq;
+       while (host_time < target_host_time) {
+           v3_yield(info);
+           host_time = v3_get_host_time(time_state);
+       }
+       time_state->guest_host_offset = guest_time - host_time;
+
     }
-    time_state->guest_host_offset = guest_time - host_time;
     return 0;
 }
 
@@ -113,7 +116,6 @@ int v3_add_timer(struct guest_info * info, struct vm_timer_ops * ops,
     return 0;
 }
 
-
 int v3_remove_timer(struct guest_info * info, struct vm_timer * timer) {
     list_del(&(timer->timer_link));
     info->time_state.num_timers--;
@@ -135,7 +137,6 @@ void v3_update_timers(struct guest_info * info) {
     }
 }
 
-
 /* 
  * Handle full virtualization of the time stamp counter.  As noted
  * above, we don't store the actual value of the TSC, only the guest's
index f12e17f..beb2437 100644 (file)
@@ -225,8 +225,8 @@ static int init_vmcs_bios(struct guest_info * info, struct vmx_data * vmx_state)
     vmx_state->pri_proc_ctrls.invlpg_exit = 1;
     vmx_state->pri_proc_ctrls.use_msr_bitmap = 1;
     vmx_state->pri_proc_ctrls.pause_exit = 1;
-#ifdef CONFIG_TIME_VIRTUALIZE_TSC
     vmx_state->pri_proc_ctrls.tsc_offset = 1;
+#ifdef CONFIG_TIME_VIRTUALIZE_TSC
     vmx_state->pri_proc_ctrls.rdtsc_exit = 1;
 #endif