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.


more 64 bit guest support
[palacios.git] / palacios / src / palacios / vmm_paging.c
index cdb14f7..22e0311 100644 (file)
@@ -29,8 +29,8 @@
   
 
 
-void delete_page_tables_pde32(pde32_t * pde) {
-  int i;//, j;
+void delete_page_tables_32(pde32_t * pde) {
+  int i;
 
   if (pde == NULL) { 
     return;
@@ -42,13 +42,6 @@ void delete_page_tables_pde32(pde32_t * pde) {
       PrintDebug("PTE base addr %x \n", pde[i].pt_base_addr);
       pte32_t * pte = (pte32_t *)((addr_t)(uint_t)(pde[i].pt_base_addr << PAGE_POWER));
 
-      /*
-       for (j = 0; (j < MAX_PTE32_ENTRIES); j++) {
-       if ((pte[j].present)) {
-       os_hooks->free_page((void *)(pte[j].page_base_addr << PAGE_POWER));
-       }
-       }
-      */
       PrintDebug("Deleting PTE %d (%p)\n", i, pte);
       V3_FreePage(pte);
     }
@@ -58,6 +51,14 @@ void delete_page_tables_pde32(pde32_t * pde) {
   V3_FreePage(V3_PAddr(pde));
 }
 
+void delete_page_tables_32PAE(pdpe32pae_t * pdpe) { 
+  PrintError("Unimplemented function\n");
+}
+
+void delete_page_tables_64(pml4e64_t * pml4) {
+  PrintError("Unimplemented function\n");
+}
+
 
 
 
@@ -266,7 +267,7 @@ pde32_t * create_passthrough_pts_32(struct guest_info * guest_info) {
  * pulling pages from the mem_list when necessary
  * If there are any gaps in the layout, we add them as unmapped pages
  */
-pdpe32pae_t * create_passthrough_pts_PAE32(struct guest_info * guest_info) {
+pdpe32pae_t * create_passthrough_pts_32PAE(struct guest_info * guest_info) {
   addr_t current_page_addr = 0;
   int i, j, k;
   struct shadow_map * map = &(guest_info->mem_map);
@@ -416,7 +417,7 @@ pml4e64_t * create_passthrough_pts_64(struct guest_info * info) {
     int pdpe_present = 0;
     pdpe64_t * pdpe = V3_VAddr(V3_AllocPages(1));
 
-    for (j = 0; j < 1; j++) {
+    for (j = 0; j < 20; j++) {
       int pde_present = 0;
       pde64_t * pde = V3_VAddr(V3_AllocPages(1));
 
@@ -581,6 +582,9 @@ pml4e64_t * create_passthrough_pts_64(struct guest_info * info) {
 
 
 
+
+
+
 void PrintPDE32(addr_t virtual_address, pde32_t * pde)
 {
   PrintDebug("PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
@@ -621,42 +625,6 @@ void PrintPTE32(addr_t virtual_address, pte32_t * pte)
 
 
 
-void PrintPDE64(addr_t virtual_address, pde64_t * pde)
-{
-  PrintDebug("PDE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
-            (void *)virtual_address,
-            (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER),
-            pde->present,
-            pde->writable,
-            pde->user_page, 
-            pde->write_through,
-            pde->cache_disable,
-            pde->accessed,
-            pde->reserved,
-            pde->large_page,
-            0,//pde->global_page,
-            pde->vmm_info);
-}
-
-  
-void PrintPTE64(addr_t virtual_address, pte64_t * pte)
-{
-  PrintDebug("PTE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n",
-            (void *)virtual_address,
-            (void*)(addr_t)(pte->page_base_addr << PAGE_POWER),
-            pte->present,
-            pte->writable,
-            pte->user_page,
-            pte->write_through,
-            pte->cache_disable,
-            pte->accessed,
-            pte->dirty,
-            pte->pte_attr,
-            pte->global_page,
-            pte->vmm_info);
-}
-
-  
 
 
 
@@ -804,3 +772,118 @@ void PrintDebugPageTables32PAE(pdpe32pae_t * pdpe)
 }
     
 
+
+void PrintPML4e64(addr_t virtual_address, pml4e64_t * pml)
+{
+  PrintDebug("PML4e64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, kernelInfo=%x\n",
+            (void *)virtual_address,
+            (void *)(addr_t) (BASE_TO_PAGE_ADDR(pml->pdp_base_addr)),
+            pml->present,
+            pml->writable,
+            pml->user_page, 
+            pml->write_through,
+            pml->cache_disable,
+            pml->accessed,
+            pml->reserved,
+            pml->vmm_info);
+}
+
+void PrintPDPE64(addr_t virtual_address, pdpe64_t * pdpe)
+{
+  PrintDebug("PDPE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
+            (void *)virtual_address,
+            (void *)(addr_t) (BASE_TO_PAGE_ADDR(pdpe->pd_base_addr)),
+            pdpe->present,
+            pdpe->writable,
+            pdpe->user_page, 
+            pdpe->write_through,
+            pdpe->cache_disable,
+            pdpe->accessed,
+            pdpe->reserved,
+            pdpe->large_page,
+            0,//pdpe->global_page,
+            pdpe->vmm_info);
+}
+
+
+
+void PrintPDE64(addr_t virtual_address, pde64_t * pde)
+{
+  PrintDebug("PDE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
+            (void *)virtual_address,
+            (void *)(addr_t) (BASE_TO_PAGE_ADDR(pde->pt_base_addr)),
+            pde->present,
+            pde->writable,
+            pde->user_page, 
+            pde->write_through,
+            pde->cache_disable,
+            pde->accessed,
+            pde->reserved,
+            pde->large_page,
+            0,//pde->global_page,
+            pde->vmm_info);
+}
+
+  
+void PrintPTE64(addr_t virtual_address, pte64_t * pte)
+{
+  PrintDebug("PTE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n",
+            (void *)virtual_address,
+            (void*)(addr_t)(BASE_TO_PAGE_ADDR(pte->page_base_addr)),
+            pte->present,
+            pte->writable,
+            pte->user_page,
+            pte->write_through,
+            pte->cache_disable,
+            pte->accessed,
+            pte->dirty,
+            pte->pte_attr,
+            pte->global_page,
+            pte->vmm_info);
+}
+
+  
+
+
+
+void PrintPageTree_64(addr_t virtual_addr, pml4e64_t * pml) {
+  uint_t pml4_index = PML4E64_INDEX(virtual_addr);
+  uint_t pdpe_index = PDPE64_INDEX(virtual_addr);
+  uint_t pde_index = PDE64_INDEX(virtual_addr);
+  uint_t pte_index = PTE64_INDEX(virtual_addr);
+
+  PrintPML4e64(virtual_addr, &(pml[pml4_index]));
+  if (pml[pml4_index].present) {
+    pdpe64_t * pdpe = (pdpe64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pml[pml4_index].pdp_base_addr));
+    PrintPDPE64(virtual_addr, &(pdpe[pdpe_index]));
+
+    if (pdpe[pdpe_index].present) {
+      pde64_t * pde = (pde64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pdpe[pdpe_index].pd_base_addr));
+      PrintPDE64(virtual_addr, &(pde[pde_index]));
+      
+      if (pde[pde_index].present) {
+       pte64_t * pte = (pte64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr));
+       PrintPTE64(virtual_addr, &(pte[pte_index]));
+      }
+
+    }
+
+  }
+
+}
+
+
+
+
+void PrintPageTree(v3_vm_cpu_mode_t cpu_mode, addr_t virtual_addr, addr_t cr3) {
+  switch (cpu_mode) {
+  case LONG:
+  case LONG_32_COMPAT:
+  case LONG_16_COMPAT:
+    PrintPageTree_64(virtual_addr, CR3_TO_PML4E64(cr3));
+    break;
+  default:
+    PrintError("Unsupported CPU MODE %d\n", cpu_mode);
+    break;
+  }
+}