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 address width calculations
Jack Lange [Wed, 25 Feb 2009 23:15:43 +0000 (17:15 -0600)]
palacios/include/palacios/vm_guest.h
palacios/src/palacios/vm_guest.c

index d7fcdeb..8b2104e 100644 (file)
@@ -149,6 +149,7 @@ struct guest_info {
 
   v3_vm_cpu_mode_t cpu_mode;
   v3_vm_mem_mode_t mem_mode;
+  uint_t addr_width;
 
 
   struct v3_gprs vm_regs;
@@ -183,6 +184,7 @@ struct guest_info {
 };
 
 
+uint_t v3_get_addr_width(struct guest_info * info);
 v3_vm_cpu_mode_t v3_get_cpu_mode(struct guest_info * info);
 v3_vm_mem_mode_t v3_get_mem_mode(struct guest_info * info);
 
index a0a0889..5406e7a 100644 (file)
@@ -56,6 +56,37 @@ v3_vm_cpu_mode_t v3_get_cpu_mode(struct guest_info * info) {
   }
 }
 
+// Get address width in bytes
+uint_t v3_get_addr_width(struct guest_info * info) {
+  struct cr0_32 * cr0;
+  struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4);
+  struct efer_64 * efer = (struct efer_64 *)&(info->guest_efer);
+  struct v3_segment * cs = &(info->segments.cs);
+
+  if (info->shdw_pg_mode == SHADOW_PAGING) {
+    cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0);
+  } else if (info->shdw_pg_mode == NESTED_PAGING) {
+    cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0);
+  } else {
+    PrintError("Invalid Paging Mode...\n");
+    V3_ASSERT(0);
+    return -1;
+  }
+
+  if (cr0->pe == 0) {
+    return 2;
+  } else if ((cr4->pae == 0) && (efer->lme == 0)) {
+    return 4;
+  } else if (efer->lme == 0) {
+    return 4;
+  } else if ((efer->lme == 1) && (cs->long_mode == 1)) {
+    return 8;
+  } else {
+    // What about LONG_16_COMPAT???
+    return 4;
+  }
+}
+
 
 static const uchar_t REAL_STR[] = "Real";
 static const uchar_t PROTECTED_STR[] = "Protected";