X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_mem_hook.c;h=8ee243aa9c907989a6bd19cb741d216a38b1435d;hb=b25296b8b79d1964be81a4ebfa8262d4ca36a63f;hp=46203a44201d093c2cb9fced73b545d7e82cd7a0;hpb=b93aeabee44c82139a9afd065dfcaca8ac6688ad;p=palacios.git diff --git a/palacios/src/palacios/vmm_mem_hook.c b/palacios/src/palacios/vmm_mem_hook.c index 46203a4..8ee243a 100644 --- a/palacios/src/palacios/vmm_mem_hook.c +++ b/palacios/src/palacios/vmm_mem_hook.c @@ -21,6 +21,7 @@ #include #include #include +#include struct mem_hook { @@ -51,20 +52,22 @@ int v3_init_mem_hooks(struct v3_vm_info * vm) { static int handle_mem_hook(struct guest_info * info, addr_t guest_va, addr_t guest_pa, - struct v3_shadow_region * reg, pf_error_t access_info) { + struct v3_mem_region * reg, pf_error_t access_info) { struct mem_hook * hook = reg->priv_data; addr_t op_addr = 0; if (reg->flags.alloced == 0) { op_addr = hook->hook_hva; } else { - op_addr = (addr_t)V3_VAddr((void *)v3_get_shadow_addr(reg, info->cpu_id, guest_pa)); + if (v3_gpa_to_hva(info, guest_pa, &op_addr) == -1) { + PrintError("Could not translate hook address (%p)\n", (void *)guest_pa); + return -1; + } } if (access_info.write == 1) { // Write Operation - if (v3_emulate_write_op(info, guest_va, guest_pa, op_addr, hook->write, hook->priv_data) == -1) { PrintError("Write Full Hook emulation failed\n"); @@ -98,7 +101,7 @@ int v3_hook_write_mem(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr_start, addr_t guest_addr_end, addr_t host_addr, int (*write)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data), void * priv_data) { - struct v3_shadow_region * entry = NULL; + struct v3_mem_region * entry = NULL; struct mem_hook * hook = V3_Malloc(sizeof(struct mem_hook)); // struct v3_mem_hooks * hooks = &(vm->mem_hooks); @@ -119,7 +122,7 @@ int v3_hook_write_mem(struct v3_vm_info * vm, uint16_t core_id, entry->flags.exec = 1; entry->flags.alloced = 1; - if (v3_insert_shadow_region(vm, entry) == -1) { + if (v3_insert_mem_region(vm, entry) == -1) { V3_Free(entry); V3_Free(hook); return -1; @@ -136,7 +139,7 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, int (*write)(struct guest_info * core, addr_t guest_addr, void * src, uint_t length, void * priv_data), void * priv_data) { - struct v3_shadow_region * entry = NULL; + struct v3_mem_region * entry = NULL; struct mem_hook * hook = V3_Malloc(sizeof(struct mem_hook)); struct v3_mem_hooks * hooks = &(vm->mem_hooks); @@ -152,7 +155,7 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, entry->unhandled = handle_mem_hook; entry->priv_data = hook; - if (v3_insert_shadow_region(vm, entry)) { + if (v3_insert_mem_region(vm, entry)) { V3_Free(entry); V3_Free(hook); return -1; @@ -166,12 +169,12 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, // This will unhook the memory hook registered at start address // We do not support unhooking subregions int v3_unhook_mem(struct v3_vm_info * vm, uint16_t core_id, addr_t guest_addr_start) { - struct v3_shadow_region * reg = v3_get_shadow_region(vm, core_id, guest_addr_start); + struct v3_mem_region * reg = v3_get_mem_region(vm, core_id, guest_addr_start); struct mem_hook * hook = reg->priv_data; V3_Free(hook); - v3_delete_shadow_region(vm, reg); + v3_delete_mem_region(vm, reg); return 0; }