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.


*** empty log message ***
[palacios.git] / palacios / src / palacios / vmm_paging.c
index 2c6a078..95240ad 100644 (file)
@@ -8,7 +8,7 @@
 extern struct vmm_os_hooks * os_hooks;
 
 void delete_page_tables_pde32(pde32_t * pde) {
-  int i, j;
+  int i;//, j;
 
   if (pde == NULL) { 
     return;
@@ -17,17 +17,20 @@ void delete_page_tables_pde32(pde32_t * pde) {
   for (i = 0; (i < MAX_PDE32_ENTRIES); i++) {
     if (pde[i].present) {
       pte32_t * pte = (pte32_t *)(pde[i].pt_base_addr << PAGE_POWER);
-      
-      for (j = 0; (j < MAX_PTE32_ENTRIES); j++) {
+
+      /*
+       for (j = 0; (j < MAX_PTE32_ENTRIES); j++) {
        if ((pte[j].present)) {
-         os_hooks->free_page((void *)(pte[j].page_base_addr << PAGE_POWER));
+       os_hooks->free_page((void *)(pte[j].page_base_addr << PAGE_POWER));
        }
-      }
-      
+       }
+      */
+      //PrintDebug("Deleting PTE %d (%x)\n", i, pte);
       os_hooks->free_page(pte);
     }
   }
 
+  //  PrintDebug("Deleting PDE (%x)\n", pde);
   os_hooks->free_page(pde);
 }
 
@@ -35,6 +38,26 @@ void delete_page_tables_pde32(pde32_t * pde) {
 
 
 
+int pt32_lookup(pde32_t * pd, addr_t vaddr, addr_t * paddr) {
+  addr_t pde_entry;
+  pde32_entry_type_t pde_entry_type;
+
+  if (pd == 0) {
+    return -1;
+  }
+
+  pde_entry_type = pde32_lookup(pd, vaddr, &pde_entry);
+
+  if (pde_entry_type == PDE32_ENTRY_PTE32) {
+    return pte32_lookup((pte32_t *)pde_entry, vaddr, paddr);
+  } else if (pde_entry_type == PDE32_ENTRY_LARGE_PAGE) {
+    *paddr = pde_entry;
+    return 0;
+  }
+
+  return -1;
+}
+
 
 
 /* We can't do a full lookup because we don't know what context the page tables are in...
@@ -48,10 +71,12 @@ pde32_entry_type_t pde32_lookup(pde32_t * pd, addr_t addr, addr_t * entry) {
     *entry = 0;
     return PDE32_ENTRY_NOT_PRESENT;
   } else  {
-    *entry = PAGE_ADDR(pde_entry->pt_base_addr);
-    
+
     if (pde_entry->large_page) {
-      *entry += PAGE_OFFSET(addr);
+      pde32_4MB_t * large_pde = (pde32_4MB_t *)pde_entry;
+
+      *entry = PDE32_4MB_T_ADDR(*large_pde);
+      *entry += PD32_4MB_PAGE_OFFSET(addr);
       return PDE32_ENTRY_LARGE_PAGE;
     } else {
       *entry = PDE32_T_ADDR(*pde_entry);
@@ -133,10 +158,10 @@ pde32_t * create_passthrough_pde32_pts(struct guest_info * guest_info) {
     
 
     for (j = 0; j < MAX_PTE32_ENTRIES; j++) {
-      shadow_region_t * region = get_shadow_region_by_addr(map, current_page_addr);
+      struct shadow_region * region = get_shadow_region_by_addr(map, current_page_addr);
 
       if (!region || 
-         (region->host_type == HOST_REGION_NOTHING) || 
+         (region->host_type == HOST_REGION_HOOK) || 
          (region->host_type == HOST_REGION_UNALLOCATED) || 
          (region->host_type == HOST_REGION_MEMORY_MAPPED_DEVICE) || 
          (region->host_type == HOST_REGION_REMOTE) ||