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.


updated msr map to allow early hooking
Jack Lange [Mon, 14 Sep 2009 19:18:44 +0000 (14:18 -0500)]
palacios/include/palacios/vmm_msr.h
palacios/src/palacios/svm_msr.c
palacios/src/palacios/vmm_msr.c
palacios/src/palacios/vmx_msr.c

index f7e3202..717d2ba 100644 (file)
@@ -32,11 +32,11 @@ struct guest_info;
 struct v3_msr {
 
     union {
-       ullong_t value;
+       uint64_t value;
 
        struct {
-           uint_t lo;
-           uint_t hi;
+           uint32_t lo;
+           uint32_t hi;
        } __attribute__((packed));
     } __attribute__((packed));
 } __attribute__((packed));
@@ -81,6 +81,8 @@ int v3_hook_msr(struct guest_info * info, uint_t msr,
 
 struct v3_msr_hook * v3_get_msr_hook(struct guest_info * info, uint_t msr);
 
+void v3_refresh_msr_map(struct guest_info * info);
+
 void v3_print_msr_map(struct guest_info * info);
 
 int v3_handle_msr_write(struct guest_info * info);
index 8e59658..22807a1 100644 (file)
@@ -84,6 +84,8 @@ int v3_init_svm_msr_map(struct guest_info * info) {
     msr_map->arch_data = V3_VAddr(V3_AllocPages(2));  
     memset(msr_map->arch_data, 0, PAGE_SIZE_4KB * 2);
 
+    v3_refresh_msr_map(info);
+
     return 0;
 }
 
index 99ebf15..8b70dd2 100644 (file)
@@ -110,14 +110,18 @@ int v3_hook_msr(struct guest_info * info, uint_t msr,
 
     list_add(&(hook->link), &(msr_map->hook_list));
 
-    msr_map->update_map(info, msr, 
-                       (read == NULL) ? 0 : 1,
-                       (write == NULL) ? 0 : 1);
+    if (msr_map->update_map) {
+       msr_map->update_map(info, msr, 
+                           (read == NULL) ? 0 : 1,
+                           (write == NULL) ? 0 : 1);
+    }
+
     return 0;
 }
 
 
 int v3_unhook_msr(struct guest_info * info, uint_t msr) {
+    PrintError("Unhooking MSRs currently not supported\n");
     return -1;
 }
 
@@ -137,6 +141,22 @@ struct v3_msr_hook * v3_get_msr_hook(struct guest_info * info, uint_t msr) {
 }
 
 
+void v3_refresh_msr_map(struct guest_info * info) {
+    struct v3_msr_map * msr_map = &(info->msr_map);
+    struct v3_msr_hook * hook = NULL;
+
+    if (msr_map->update_map == NULL) {
+       PrintError("Trying to refresh an MSR map with no backend\n");
+       return;
+    }
+
+    list_for_each_entry(hook, &(msr_map->hook_list), link) {
+       msr_map->update_map(info, hook->msr,    
+                           (hook->read == NULL) ? 0 : 1,
+                           (hook->write == NULL) ? 0 : 1);
+    }
+}
+
 void v3_print_msr_map(struct guest_info * info) {
     struct v3_msr_map * msr_map = &(info->msr_map);
     struct v3_msr_hook * hook = NULL;
index 66995ac..2d9df85 100644 (file)
@@ -64,12 +64,14 @@ static int update_map(struct guest_info * info, uint_t msr, int hook_reads, int
 }
 
 int v3_init_vmx_msr_map(struct guest_info * info) {
-   struct v3_msr_map * msr_map = &(info->msr_map);
+    struct v3_msr_map * msr_map = &(info->msr_map);
 
-   msr_map->update_map = update_map;
-   
-   msr_map->arch_data = V3_VAddr(V3_AllocPages(1));
-   memset(msr_map->arch_data, 0, PAGE_SIZE_4KB);
-
-   return 0;
+    msr_map->update_map = update_map;
+    
+    msr_map->arch_data = V3_VAddr(V3_AllocPages(1));
+    memset(msr_map->arch_data, 0, PAGE_SIZE_4KB);
+    
+    v3_refresh_msr_map(info);
+    
+    return 0;
 }