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.


deinitialization fixes
[palacios.git] / palacios / src / palacios / vmx_ctrl_regs.c
index 7aa7361..d83d51f 100644 (file)
 #include <palacios/vmm_direct_paging.h>
 #include <palacios/vmm_ctrl_regs.h>
 
-#if 0
-#ifndef CONFIG_DEBUG_VMX
+#ifndef V3_CONFIG_DEBUG_VMX
 #undef PrintDebug
 #define PrintDebug(fmt, args...)
 #endif
-#endif
 
 static v3_reg_t * get_reg_ptr(struct guest_info * info, struct vmx_exit_cr_qual * cr_qual);
 static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_val, struct vmx_exit_info * exit_info);
@@ -79,6 +77,29 @@ int v3_vmx_handle_cr3_access(struct guest_info * info, struct vmx_exit_cr_qual *
     return -1;
 }
 
+int v3_vmx_handle_cr4_access(struct guest_info * info, struct vmx_exit_cr_qual * cr_qual) {
+    if (cr_qual->access_type < 2) {
+
+       if (cr_qual->access_type == 0) {
+           if (v3_handle_cr4_write(info) != 0) {
+               PrintError("Could not handle CR4 write\n");
+               return -1;
+           }
+           info->ctrl_regs.cr4 |= 0x2000; // no VMX allowed in guest, so mask CR4.VMXE
+       } else {
+           if (v3_handle_cr4_read(info) != 0) {
+               PrintError("Could not handle CR4 read\n");
+               return -1;
+           }
+       }
+
+       return 0;
+    }
+
+    PrintError("Invalid CR4 Access type?? (type=%d)\n", cr_qual->access_type);
+    return -1;
+}
+
 static int handle_mov_to_cr3(struct guest_info * info, v3_reg_t * cr3_reg) {
 
     if (info->shdw_pg_mode == SHADOW_PAGING) {
@@ -198,13 +219,14 @@ static int handle_mov_to_cr0(struct guest_info * info, v3_reg_t * new_cr0, struc
            // Paging transition
            
            if (v3_get_vm_mem_mode(info) == VIRTUAL_MEM) {
-               struct efer_64 * guest_efer = (struct efer_64 *)&(info->ctrl_regs.efer);
+               struct efer_64 * vm_efer = (struct efer_64 *)&(info->shdw_pg_state.guest_efer);
+               struct efer_64 * hw_efer = (struct efer_64 *)&(info->ctrl_regs.efer);
                
-               if (guest_efer->lme == 1) {
+               if (vm_efer->lme) {
                    //     PrintDebug("Enabling long mode\n");
                    
-                   guest_efer->lma = 1;
-                   guest_efer->lme = 1;
+                   hw_efer->lma = 1;
+                   hw_efer->lme = 1;
                    
                    vmx_info->entry_ctrls.guest_ia32e = 1;
                }