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.


s patch fixes some issues I've had when compiling Palacios 32-bit.
[palacios.git] / palacios / src / palacios / vmx.c
index 2526f3d..efc8e24 100644 (file)
@@ -494,7 +494,7 @@ static int update_irq_entry_state(struct guest_info * info) {
 
         int_info.valid = 1;
 #ifdef CONFIG_DEBUG_INTERRUPTS
-        PrintDebug("Injecting exception %d (EIP=%p)\n", int_info.vector, (void *)info->rip);
+        PrintDebug("Injecting exception %d (EIP=%p)\n", int_info.vector, (void *)(addr_t)info->rip);
 #endif
         check_vmcs_write(VMCS_ENTRY_INT_INFO, int_info.value);
 
@@ -536,7 +536,7 @@ static int update_irq_entry_state(struct guest_info * info) {
                     PrintDebug("Injecting Interrupt %d at exit %u(EIP=%p)\n", 
                               info->intr_state.irq_vector, 
                               (uint32_t)info->num_exits, 
-                              (void *)info->rip);
+                              (void *)(addr_t)info->rip);
 #endif
 
                     check_vmcs_write(VMCS_ENTRY_INT_INFO, ent_int.value);
@@ -652,6 +652,11 @@ int v3_vmx_enter(struct guest_info * info) {
     update_irq_entry_state(info);
 #endif
 
+    {
+       addr_t guest_cr3;
+       vmcs_read(VMCS_GUEST_CR3, &guest_cr3);
+       vmcs_write(VMCS_GUEST_CR3, guest_cr3);
+    }
 
     rdtscll(info->time_state.cached_host_tsc);
 
@@ -682,6 +687,8 @@ int v3_vmx_enter(struct guest_info * info) {
     /* Update guest state */
     v3_vmx_save_vmcs(info);
 
+    // info->cpl = info->segments.cs.selector & 0x3;
+
     info->mem_mode = v3_get_vm_mem_mode(info);
     info->cpu_mode = v3_get_vm_cpu_mode(info);
 
@@ -787,7 +794,7 @@ void v3_init_vmx_cpu(int cpu_id) {
     uint64_t ret = 0;
 
     v3_get_msr(VMX_CR4_FIXED0_MSR,&(tmp_msr.hi),&(tmp_msr.lo));
-    
+#ifdef __V3_64BIT__
     __asm__ __volatile__ (
                          "movq %%cr4, %%rbx;"
                          "orq  $0x00002000, %%rbx;"
@@ -816,6 +823,38 @@ void v3_init_vmx_cpu(int cpu_id) {
                          :
                          : "%rbx"
                          );
+#elif __V3_32BIT__
+    __asm__ __volatile__ (
+                         "movl %%cr4, %%ecx;"
+                         "orl  $0x00002000, %%ecx;"
+                         "movl %%ecx, %0;"
+                         : "=m"(ret) 
+                         :
+                         : "%ecx"
+                         );
+
+    if ((~ret & tmp_msr.value) == 0) {
+        __asm__ __volatile__ (
+                             "movl %0, %%cr4;"
+                             :
+                             : "q"(ret)
+                             );
+    } else {
+        PrintError("Invalid CR4 Settings!\n");
+        return;
+    }
+
+    __asm__ __volatile__ (
+                         "movl %%cr0, %%ecx; "
+                         "orl  $0x00000020,%%ecx; "
+                         "movl %%ecx, %%cr0;"
+                         :
+                         :
+                         : "%ecx"
+                         );
+
+#endif
+
     //
     // Should check and return Error here....