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.


fixed cr0 reads from long mode
Jack Lange [Thu, 12 Mar 2009 02:41:12 +0000 (21:41 -0500)]
palacios/src/palacios/vmm_ctrl_regs.c

index e36b2fe..75d11f0 100644 (file)
@@ -229,20 +229,35 @@ int v3_handle_cr0_read(struct guest_info * info) {
     }
     
     if (dec_instr.op_type == V3_OP_MOVCR2) {
-       struct cr0_32 * dst_reg = (struct cr0_32 *)(dec_instr.dst_operand.operand);
-       struct cr0_32 * shadow_cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0);
-       
        PrintDebug("MOVCR2 (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode));
+
+       if ((v3_get_cpu_mode(info) == LONG) || 
+           (v3_get_cpu_mode(info) == LONG_32_COMPAT)) {
+           struct cr0_64 * dst_reg = (struct cr0_64 *)(dec_instr.dst_operand.operand);
        
-       if (info->shdw_pg_mode == SHADOW_PAGING) {
-           struct cr0_32 * guest_cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0);
-           *dst_reg = *guest_cr0;
+           if (info->shdw_pg_mode == SHADOW_PAGING) {
+               struct cr0_64 * guest_cr0 = (struct cr0_64 *)&(info->shdw_pg_state.guest_cr0);
+               *dst_reg = *guest_cr0;
+           } else {
+               struct cr0_64 * shadow_cr0 = (struct cr0_64 *)&(info->ctrl_regs.cr0);
+               *dst_reg = *shadow_cr0;
+           }
+
+           PrintDebug("returned CR0: %p\n", (void *)*dst_reg);
        } else {
-           *dst_reg = *shadow_cr0;
-       }
+           struct cr0_32 * dst_reg = (struct cr0_32 *)(dec_instr.dst_operand.operand);
        
-       PrintDebug("Shadow CR0: %x\n", *(uint_t*)shadow_cr0);    
-       PrintDebug("returned CR0: %x\n", *(uint_t*)dst_reg);
+           if (info->shdw_pg_mode == SHADOW_PAGING) {
+               struct cr0_32 * guest_cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0);
+               *dst_reg = *guest_cr0;
+           } else {
+               struct cr0_32 * shadow_cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0);
+               *dst_reg = *shadow_cr0;
+           }
+
+           PrintDebug("returned CR0: %x\n", *(uint_t*)dst_reg);
+       }
+
     } else if (dec_instr.op_type == V3_OP_SMSW) {
        struct cr0_real * shadow_cr0 = (struct cr0_real *)&(info->ctrl_regs.cr0);
        struct cr0_real * dst_reg = (struct cr0_real *)(dec_instr.dst_operand.operand);