From: Jack Lange Date: Mon, 14 Sep 2009 19:18:44 +0000 (-0500) Subject: updated msr map to allow early hooking X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=c3714b74821dffe63b2fdcf10d8fe614c5ac9bb1 updated msr map to allow early hooking --- diff --git a/palacios/include/palacios/vmm_msr.h b/palacios/include/palacios/vmm_msr.h index f7e3202..717d2ba 100644 --- a/palacios/include/palacios/vmm_msr.h +++ b/palacios/include/palacios/vmm_msr.h @@ -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); diff --git a/palacios/src/palacios/svm_msr.c b/palacios/src/palacios/svm_msr.c index 8e59658..22807a1 100644 --- a/palacios/src/palacios/svm_msr.c +++ b/palacios/src/palacios/svm_msr.c @@ -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; } diff --git a/palacios/src/palacios/vmm_msr.c b/palacios/src/palacios/vmm_msr.c index 99ebf15..8b70dd2 100644 --- a/palacios/src/palacios/vmm_msr.c +++ b/palacios/src/palacios/vmm_msr.c @@ -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; diff --git a/palacios/src/palacios/vmx_msr.c b/palacios/src/palacios/vmx_msr.c index 66995ac..2d9df85 100644 --- a/palacios/src/palacios/vmx_msr.c +++ b/palacios/src/palacios/vmx_msr.c @@ -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; }