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.


Added non-contiguous memory region support.
[palacios.git] / palacios / src / palacios / vmx_ept.c
index bf1ab86..82f084a 100644 (file)
@@ -27,8 +27,15 @@ static struct vmx_ept_msr * ept_info = NULL;
 
 
 static addr_t create_ept_page() {
+    void * temp;
     void * page = 0;
-    page = V3_VAddr(V3_AllocPages(1));
+    
+    temp = V3_AllocPages(1);
+    if (!temp) {
+       PrintError(VM_NONE, VCORE_NONE, "Cannot allocate EPT page\n");
+       return 0;
+    }
+    page = V3_VAddr(temp);
     memset(page, 0, PAGE_SIZE);
 
     return (addr_t)page;
@@ -50,7 +57,7 @@ int v3_init_ept(struct guest_info * core, struct vmx_hw_info * hw_info) {
     if (ept_info->pg_walk_len4) {
        ept_ptr->pwl1 = 3;
     } else {
-       PrintError("Unsupported EPT Table depth\n");
+       PrintError(core->vm_info, core, "Unsupported EPT Table depth\n");
        return -1;
     }
 
@@ -77,7 +84,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_
     int pde_index  = PDE64_INDEX(fault_addr);
     int pte_index  = PTE64_INDEX(fault_addr);
 
-    struct v3_mem_region * region = v3_get_mem_region(core->vm_info, core->cpu_id, fault_addr);
+    struct v3_mem_region * region = v3_get_mem_region(core->vm_info, core->vcpu_id, fault_addr);
     int page_size = PAGE_SIZE_4KB;
 
 
@@ -87,7 +94,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_
     error_code.write = ept_qual->write;
     
     if (region == NULL) {
-       PrintError("invalid region, addr=%p\n", (void *)fault_addr);
+       PrintError(core->vm_info, core, "invalid region, addr=%p\n", (void *)fault_addr);
        return -1;
     }
 
@@ -144,7 +151,9 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_
                // Full access
                pde2mb[pde_index].read = 1;
                pde2mb[pde_index].exec = 1;
-              
+               pde2mb[pde_index].ipat = 1;
+               pde2mb[pde_index].mt = 6;
+
                if (region->flags.write == 1) {
                    pde2mb[pde_index].write = 1;
                } else {
@@ -152,7 +161,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_
                }
 
                if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) {
-                   PrintError("Error: Could not translate fault addr (%p)\n", (void *)fault_addr);
+                   PrintError(core->vm_info, core, "Error: Could not translate fault addr (%p)\n", (void *)fault_addr);
                    return -1;
                }
 
@@ -197,6 +206,8 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_
            // Full access
            pte[pte_index].read = 1;
            pte[pte_index].exec = 1;
+           pte[pte_index].ipat = 1;
+           pte[pte_index].mt = 6;
 
            if (region->flags.write == 1) {
                pte[pte_index].write = 1;
@@ -205,7 +216,7 @@ int v3_handle_ept_fault(struct guest_info * core, addr_t fault_addr, struct ept_
            }
 
            if (v3_gpa_to_hpa(core, fault_addr, &host_addr) == -1) {
-               PrintError("Error Could not translate fault addr (%p)\n", (void *)fault_addr);
+               PrintError(core->vm_info, core, "Error Could not translate fault addr (%p)\n", (void *)fault_addr);
                return -1;
            }