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.


Update char_stream device for virtual console input event
[palacios.git] / palacios / src / palacios / vmm_mem_hook.c
index 7064d4e..46ee1fd 100644 (file)
@@ -21,6 +21,7 @@
 #include <palacios/vm_guest.h>
 #include <palacios/vmm_mem_hook.h>
 #include <palacios/vmm_emulator.h>
+#include <palacios/vm_guest_mem.h>
 
 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);