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.


VMX is working for a 32-bit Linux kernel. It should also work for a 64-bit kernel...
[palacios.git] / palacios / src / palacios / vmx_msr.c
index fa53ffc..66995ac 100644 (file)
 
 #include <palacios/vmm.h>
 #include <palacios/vm_guest.h>
+#include <palacios/vmm_msr.h>
+
+#define LOW_MSR_START   0x00000000
+#define LOW_MSR_END     0x1fff
+#define HIGH_MSR_START  0xc0000000
+#define HIGH_MSR_END    0xc0001fff
+
+#define LOW_MSR_INDEX   0
+#define HIGH_MSR_INDEX  1024
+
+static int get_bitmap_index(uint_t msr)
+{
+    if( (msr >= LOW_MSR_START) && msr <= LOW_MSR_END) {
+        return LOW_MSR_INDEX + msr;
+    } else if (( msr >= HIGH_MSR_START ) && (msr <= HIGH_MSR_END)) {
+        return HIGH_MSR_INDEX + (msr - HIGH_MSR_START);
+    } else {
+        PrintError("MSR out of range: 0x%x\n", msr);
+        return -1;
+    }
+}
 
 /* Same as SVM */
 static int update_map(struct guest_info * info, uint_t msr, int hook_reads, int hook_writes) {
 
-#if 0
     int index = get_bitmap_index(msr);
-    uint_t major = index / 4;
-    uint_t minor = (index % 4) * 2;
-    uchar_t val = 0;
-    uchar_t mask = 0x3;
+    uint_t major = index / 8;
+    uint_t minor = (index % 8);
+    uchar_t mask = 0x1;
+    uint8_t read_val = (hook_reads) ? 0x1 : 0x0;
+    uint8_t write_val = (hook_writes) ? 0x1 : 0x0;
     uint8_t * bitmap = (uint8_t *)(info->msr_map.arch_data);
 
-    if (hook_reads) {
-       val |= 0x1;
-    } 
-    
-    if (hook_writes) {
-       val |= 0x2;
-    }
 
     *(bitmap + major) &= ~(mask << minor);
-    *(bitmap + major) |= (val << minor);
-#endif
+    *(bitmap + major) |= (read_val << minor);
+    
+
+    *(bitmap + 2048 + major) &= ~(mask << minor);
+    *(bitmap + 2048 + major) |= (write_val << minor);
     
     return 0;
 }