X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_mem_hook.c;h=46ee1fdfabca6d257cbe2b33cc5631bf935e2c1d;hb=24e0221dd2fdcf613cc5e487ec57a30f2fef25e3;hp=7064d4ed78fa43bfd858c7db1c5b58f33ed68dbc;hpb=d0ebfed83ac079f95da8bf79e64ac77f31d551ac;p=palacios.git diff --git a/palacios/src/palacios/vmm_mem_hook.c b/palacios/src/palacios/vmm_mem_hook.c index 7064d4e..46ee1fd 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 { @@ -53,18 +54,25 @@ 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_mem_region * reg, pf_error_t access_info) { struct mem_hook * hook = reg->priv_data; + struct v3_mem_hooks * hooks = &(info->vm_info->mem_hooks); addr_t op_addr = 0; if (reg->flags.alloced == 0) { - op_addr = hook->hook_hva; + if (hook->hook_hva & 0xfff) { + op_addr = (addr_t)(hooks->hook_hvas + (PAGE_SIZE * info->cpu_id)); + } else { + 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"); @@ -138,14 +146,14 @@ int v3_hook_full_mem(struct v3_vm_info * vm, uint16_t core_id, struct v3_mem_region * entry = NULL; struct mem_hook * hook = V3_Malloc(sizeof(struct mem_hook)); - struct v3_mem_hooks * hooks = &(vm->mem_hooks); + // struct v3_mem_hooks * hooks = &(vm->mem_hooks); memset(hook, 0, sizeof(struct mem_hook)); hook->write = write; hook->read = read; hook->priv_data = priv_data; - hook->hook_hva = (addr_t)hooks->hook_hvas + (PAGE_SIZE_4KB * core_id); + hook->hook_hva = (addr_t)0xfff; entry = v3_create_mem_region(vm, core_id, guest_addr_start, guest_addr_end);