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 lookup functions for all page table forms,
Jack Lange [Thu, 30 Oct 2008 23:14:30 +0000 (18:14 -0500)]
generalized the return types for the lookup functions
updated source tree to match
added large page forms for pae and 64 bit page tables

palacios/include/palacios/vmm_paging.h
palacios/src/palacios/vm_guest_mem.c
palacios/src/palacios/vmm_paging.c
palacios/src/palacios/vmm_paging_debug.h
palacios/src/palacios/vmm_shadow_paging.c

index 294282c..caba35f 100644 (file)
@@ -206,10 +206,23 @@ the host state in the vmcs before entering the guest.
 
 
 
+/* We'll use the general form for now.... 
+   typedef enum {PDE32_ENTRY_NOT_PRESENT, PDE32_ENTRY_PTE32, PDE32_ENTRY_LARGE_PAGE} pde32_entry_type_t;
+   typedef enum {PTE32_ENTRY_NOT_PRESENT, PTE32_ENTRY_PAGE} pte32_entry_type_t;
+   
+   typedef enum {PDPE32PAE_ENTRY_NOT_PRESENT, PDPE32PAE_ENTRY_PAGE} pdpe32pae_entry_type_t;
+   typedef enum {PDE32PAE_ENTRY_NOT_PRESENT, PDE32PAE_ENTRY_PTE32, PDE32PAE_ENTRY_LARGE_PAGE} pde32pae_entry_type_t;
+   typedef enum {PTE32PAE_ENTRY_NOT_PRESENT, PTE32PAE_ENTRY_PAGE} pte32pae_entry_type_t;
+   
+   typedef enum {PML4E64_ENTRY_NOT_PRESENT, PML4E64_ENTRY_PAGE} pml4e64_entry_type_t;
+   typedef enum {PDPE64_ENTRY_NOT_PRESENT, PDPE64_ENTRY_PTE32, PDPE64_ENTRY_LARGE_PAGE} pdpe64_entry_type_t;
+   typedef enum {PDE64_ENTRY_NOT_PRESENT, PDE64_ENTRY_PTE32, PDE64_ENTRY_LARGE_PAGE} pde64_entry_type_t;
+   typedef enum {PTE64_ENTRY_NOT_PRESENT, PTE64_ENTRY_PAGE} pte64_entry_type_t;
+*/
+
 
-/* PDE 32 bit PAGE STRUCTURES */
-typedef enum {PDE32_ENTRY_NOT_PRESENT, PDE32_ENTRY_PTE32, PDE32_ENTRY_LARGE_PAGE} pde32_entry_type_t;
-typedef enum {PT_ACCESS_OK, PT_ENTRY_NOT_PRESENT, PT_WRITE_ERROR, PT_USER_ERROR} pt_access_status_t;
+typedef enum {PT_ENTRY_NOT_PRESENT, PT_ENTRY_LARGE_PAGE, PT_ENTRY_PAGE} pt_entry_type_t;
+typedef enum {PT_ACCESS_OK, PT_ACCESS_NOT_PRESENT, PT_ACCESS_WRITE_ERROR, PT_ACCESS_USER_ERROR} pt_access_status_t;
 
 typedef struct pde32 {
   uint_t present         : 1;
@@ -233,7 +246,7 @@ typedef struct pde32_4MB {
   uint_t cache_disable   : 1;
   uint_t accessed        : 1;
   uint_t dirty           : 1;
-  uint_t one             : 1;
+  uint_t large_page      : 1;
   uint_t global_page     : 1;
   uint_t vmm_info        : 3;
   uint_t pat             : 1;
@@ -288,7 +301,7 @@ typedef struct pde32pae {
   uint_t rsvd            : 28;
 } __attribute__((packed)) pde32pae_t;
 
-typedef struct pde32pae_4MB {
+typedef struct pde32pae_2MB {
   uint_t present         : 1;
   uint_t writable        : 1;
   uint_t user_page       : 1;
@@ -300,11 +313,11 @@ typedef struct pde32pae_4MB {
   uint_t global_page     : 1;
   uint_t vmm_info        : 3;
   uint_t pat             : 1;
-  uint_t rsvd            : 9;
-  uint_t page_base_addr  : 14;
+  uint_t rsvd            : 8;
+  uint_t page_base_addr  : 15;
   uint_t rsvd2           : 28;
 
-} __attribute__((packed)) pde32pae_4MB_t;
+} __attribute__((packed)) pde32pae_2MB_t;
 
 typedef struct pte32pae {
   uint_t present         : 1;
@@ -348,12 +361,12 @@ typedef struct pml4e64 {
 typedef struct pdpe64 {
   uint_t present        : 1;
   uint_t writable       : 1;
-  uint_t user_page           : 1;
+  uint_t user_page      : 1;
   uint_t write_through  : 1;
   uint_t cache_disable  : 1;
   uint_t accessed       : 1;
-  uint_t reserved       : 1;
-  uint_t large_page    : 1;
+  uint_t avail          : 1;
+  uint_t large_page     : 1;
   uint_t zero           : 1;
   uint_t vmm_info       : 3;
   ullong_t pd_base_addr : 40;
@@ -362,6 +375,25 @@ typedef struct pdpe64 {
 } __attribute__((packed)) pdpe64_t;
 
 
+// We Don't support this
+typedef struct pdpe64_1GB {
+  uint_t present        : 1;
+  uint_t writable       : 1;
+  uint_t user_page      : 1;
+  uint_t write_through  : 1;
+  uint_t cache_disable  : 1;
+  uint_t accessed       : 1;
+  uint_t dirty          : 1;
+  uint_t large_page     : 1;
+  uint_t global_page    : 1;
+  uint_t vmm_info       : 3;
+  uint_t pat            : 1;
+  uint_t rsvd           : 17;
+  ullong_t page_base_addr : 22;
+  uint_t available      : 11;
+  uint_t no_execute     : 1;
+} __attribute__((packed)) pdpe64_1GB_t;
+
 
 
 typedef struct pde64 {
@@ -371,15 +403,34 @@ typedef struct pde64 {
   uint_t write_through   : 1;
   uint_t cache_disable   : 1;
   uint_t accessed        : 1;
-  uint_t reserved        : 1;
-  uint_t large_page     : 1;
-  uint_t reserved2       : 1;
+  uint_t avail           : 1;
+  uint_t large_page      : 1;
+  uint_t global_page     : 1;
   uint_t vmm_info        : 3;
   ullong_t pt_base_addr  : 40;
   uint_t available       : 11;
   uint_t no_execute      : 1;
 } __attribute__((packed)) pde64_t;
 
+typedef struct pde64_2MB {
+  uint_t present         : 1;
+  uint_t writable        : 1;
+  uint_t user_page       : 1;
+  uint_t write_through   : 1;
+  uint_t cache_disable   : 1;
+  uint_t accessed        : 1;
+  uint_t dirty           : 1;
+  uint_t large_page      : 1;
+  uint_t global_page     : 1;
+  uint_t vmm_info        : 3;
+  uint_t pat             : 1;
+  uint_t rsvd            : 8;
+  ullong_t page_base_addr  : 31;
+  uint_t available       : 11;
+  uint_t no_execute      : 1;
+} __attribute__((packed)) pde64_2MB_t;
+
+
 typedef struct pte64 {
   uint_t present         : 1;
   uint_t writable        : 1;
@@ -414,12 +465,20 @@ void delete_page_tables_32(pde32_t * pde);
 void delete_page_tables_32PAE(pdpe32pae_t * pdpe);
 void delete_page_tables_64(pml4e64_t *  pml4);
 
-pde32_entry_type_t pde32_lookup(pde32_t * pd, addr_t addr, addr_t * entry);
-int pte32_lookup(pte32_t * pte, addr_t addr, addr_t * entry);
+pt_entry_type_t pde32_lookup(pde32_t * pd, addr_t addr, addr_t * entry);
+pt_entry_type_t pte32_lookup(pte32_t * pt, addr_t addr, addr_t * entry);
+
+pt_entry_type_t pdpe32pae_lookup(pdpe32pae_t * pdp, addr_t addr, addr_t * entry);
+pt_entry_type_t pde32pae_lookup(pde32pae_t * pd, addr_t addr, addr_t * entry);
+pt_entry_type_t pte32pae_lookup(pte32pae_t * pt, addr_t addr, addr_t * entry);
+
+pt_entry_type_t pml4e64_lookup(pml4e64_t * pml, addr_t addr, addr_t * entry);
+pt_entry_type_t pdpe64_lookup(pdpe64_t * pdp, addr_t addr, addr_t * entry);
+pt_entry_type_t pde64_lookup(pde64_t * pd, addr_t addr, addr_t * entry);
+pt_entry_type_t pte64_lookup(pte64_t * pt, addr_t addr, addr_t * entry);
+
+
 
-// This assumes that the page table resides in the host address space
-// IE. IT DOES NO VM ADDR TRANSLATION
-int pt32_lookup(pde32_t * pd, addr_t vaddr, addr_t * paddr);
 
 
 
index 2cc4385..b623cd8 100644 (file)
@@ -173,13 +173,13 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
       
       
       switch (pde32_lookup(pde, guest_va, &tmp_pa)) {
-      case PDE32_ENTRY_NOT_PRESENT: 
+      case PT_ENTRY_NOT_PRESENT: 
        *guest_pa = 0;
        return -1;
-      case PDE32_ENTRY_LARGE_PAGE:
+      case PT_ENTRY_LARGE_PAGE:
        *guest_pa = tmp_pa;
        return 0;
-      case PDE32_ENTRY_PTE32:
+      case PT_ENTRY_PAGE:
        {
          pte32_t * pte = 0;
          
@@ -192,7 +192,7 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
          
          //PrintDebug("PTE host addr=%x, GVA=%x, GPA=%x(should be 0)\n", pte, guest_va, *guest_pa);
         
-         if (pte32_lookup(pte, guest_va, guest_pa) != 0) {
+         if (pte32_lookup(pte, guest_va, guest_pa) != PT_ENTRY_PAGE) {
            PrintError("In GVA->GPA: PTE32 Lookup failure GVA=%p; PTE=%p\n", 
                        (void *)guest_va,  (void *)pte);
            //        PrintPT32(PDE32_INDEX(guest_va) << 22, pte);
index 4784e90..7643dd9 100644 (file)
@@ -74,13 +74,13 @@ int translate_guest_pt_32(struct guest_info * info, addr_t guest_cr3, addr_t vad
   }
   
   switch (pde32_lookup(guest_pde, vaddr, &guest_pte_pa)) {
-  case PDE32_ENTRY_NOT_PRESENT:
+  case PT_ENTRY_NOT_PRESENT:
     *paddr = 0;  
     return -1;
-  case PDE32_ENTRY_LARGE_PAGE:
+  case PT_ENTRY_LARGE_PAGE:
     *paddr = guest_pte_pa;
     return 0;
-  case PDE32_ENTRY_PTE32:
+  case PT_ENTRY_PAGE:
     {
       pte32_t * guest_pte;
       if (guest_pa_to_host_va(info, guest_pte_pa, (addr_t*)&guest_pte) == -1) {
@@ -104,13 +104,13 @@ int translate_host_pt_32(addr_t host_cr3, addr_t vaddr, addr_t * paddr) {
   pte32_t * host_pte = 0;
     
   switch (pde32_lookup(host_pde, vaddr, (addr_t *)&host_pte)) {
-  case PDE32_ENTRY_NOT_PRESENT:
+  case PT_ENTRY_NOT_PRESENT:
     *paddr = 0;
     return -1;
-  case PDE32_ENTRY_LARGE_PAGE:
+  case PT_ENTRY_LARGE_PAGE:
     *paddr = (addr_t)host_pte;
     return 0;
-  case PDE32_ENTRY_PTE32:
+  case PT_ENTRY_PAGE:
     if (pte32_lookup(host_pte, vaddr, paddr) == -1) {
       return -1;
     }
@@ -121,42 +121,14 @@ int translate_host_pt_32(addr_t host_cr3, addr_t vaddr, addr_t * paddr) {
 
 
 int translate_host_pt_32pae(addr_t host_cr3, addr_t vaddr, addr_t * paddr) {
-  pde32_t * host_pde = (pde32_t *)CR3_TO_PDE32_VA((void *)host_cr3);
-  pte32_t * host_pte = 0;
-    
-  switch (pde32_lookup(host_pde, vaddr, (addr_t *)&host_pte)) {
-  case PDE32_ENTRY_NOT_PRESENT:
-    *paddr = 0;
-    return -1;
-  case PDE32_ENTRY_LARGE_PAGE:
-    *paddr = (addr_t)host_pte;
-    return 0;
-  case PDE32_ENTRY_PTE32:
-    if (pte32_lookup(host_pte, vaddr, paddr) == -1) {
-      return -1;
-    }
-  }
+
 
   return -1;
 }
 
 
 int translate_host_pt_64(addr_t host_cr3, addr_t vaddr, addr_t * paddr) {
-  pde32_t * host_pde = (pde32_t *)CR3_TO_PDE32_VA((void *)host_cr3);
-  pte32_t * host_pte = 0;
-    
-  switch (pde32_lookup(host_pde, vaddr, (addr_t *)&host_pte)) {
-  case PDE32_ENTRY_NOT_PRESENT:
-    *paddr = 0;
-    return -1;
-  case PDE32_ENTRY_LARGE_PAGE:
-    *paddr = (addr_t)host_pte;
-    return 0;
-  case PDE32_ENTRY_PTE32:
-    if (pte32_lookup(host_pte, vaddr, paddr) == -1) {
-      return -1;
-    }
-  }
+
 
   return -1;
 }
@@ -165,106 +137,201 @@ int translate_host_pt_64(addr_t host_cr3, addr_t vaddr, addr_t * paddr) {
 
 
 
-
-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...
- * The entry addresses could be pointing to either guest physical memory or host physical memory
- * Instead we just return the entry address, and a flag to show if it points to a pte or a large page...
- */
-/* The value of entry is a return type:
+/*
+ * PAGE TABLE LOOKUP FUNCTIONS
+ *
+ *
+ * The value of entry is a return type:
  * Page not present: *entry = 0
  * Large Page: *entry = translated physical address (byte granularity)
  * PTE entry: *entry is the address of the PTE Page
  */
-pde32_entry_type_t pde32_lookup(pde32_t * pd, addr_t addr, addr_t * entry) {
+
+/**
+ * 
+ *  32 bit Page Table lookup functions
+ *
+ **/
+
+pt_entry_type_t pde32_lookup(pde32_t * pd, addr_t addr, addr_t * entry) {
   pde32_t * pde_entry = &(pd[PDE32_INDEX(addr)]);
 
   if (!pde_entry->present) {
     *entry = 0;
-    return PDE32_ENTRY_NOT_PRESENT;
-  } else  {
+    return PT_ENTRY_NOT_PRESENT;
+  } else if (pde_entry->large_page) {
+    pde32_4MB_t * large_pde = (pde32_4MB_t *)pde_entry;
 
-    if (pde_entry->large_page) {
-      pde32_4MB_t * large_pde = (pde32_4MB_t *)pde_entry;
+    *entry = BASE_TO_PAGE_ADDR_4MB(large_pde->page_base_addr);
+    *entry += PAGE_OFFSET_4MB(addr);
 
-      *entry = BASE_TO_PAGE_ADDR_4MB(large_pde->page_base_addr);
-      *entry += PAGE_OFFSET_4MB(addr);
-      return PDE32_ENTRY_LARGE_PAGE;
-    } else {
-      *entry = BASE_TO_PAGE_ADDR(pde_entry->pt_base_addr);
-      return PDE32_ENTRY_PTE32;
-    }
-  }  
-  return PDE32_ENTRY_NOT_PRESENT;
+    return PT_ENTRY_LARGE_PAGE;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pde_entry->pt_base_addr);
+    return PT_ENTRY_PAGE;
+  }
 }
 
 
 
 /* Takes a virtual addr (addr) and returns the physical addr (entry) as defined in the page table
  */
-int pte32_lookup(pte32_t * pt, addr_t addr, addr_t * entry) {
+pt_entry_type_t pte32_lookup(pte32_t * pt, addr_t addr, addr_t * entry) {
   pte32_t * pte_entry = &(pt[PTE32_INDEX(addr)]);
 
   if (!pte_entry->present) {
     *entry = 0;
     //    PrintDebug("Lookup at non present page (index=%d)\n", PTE32_INDEX(addr));
-    return -1;
+    return PT_ENTRY_NOT_PRESENT;
   } else {
     *entry = BASE_TO_PAGE_ADDR(pte_entry->page_base_addr) + PAGE_OFFSET(addr);
-    return 0;
+    return PT_ENTRY_PAGE;
   }
 
-  return -1;
 }
 
 
-int pdpe32pae_lookup(pdpe32pae_t * pdp, addr_t addr, addr_t * entry) {
+
+/**
+ * 
+ *  32 bit PAE Page Table lookup functions
+ *
+ **/
+pt_entry_type_t pdpe32pae_lookup(pdpe32pae_t * pdp, addr_t addr, addr_t * entry) {
   pdpe32pae_t * pdpe_entry = &(pdp[PDPE32PAE_INDEX(addr)]);
   
   if (!pdpe_entry->present) {
     *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pdpe_entry->pd_base_addr);
+    return PT_ENTRY_PAGE;
+  }
+}
+
+pt_entry_type_t pde32pae_lookup(pde32pae_t * pd, addr_t addr, addr_t * entry) {
+  pde32pae_t * pde_entry = &(pd[PDE32PAE_INDEX(addr)]);
+
+  if (!pde_entry->present) {
+    *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else if (pde_entry->large_page) {
+    pde32pae_2MB_t * large_pde = (pde32pae_2MB_t *)pde_entry;
+
+    *entry = BASE_TO_PAGE_ADDR_2MB(large_pde->page_base_addr);
+    *entry += PAGE_OFFSET_2MB(addr);
+
+    return PT_ENTRY_LARGE_PAGE;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pde_entry->pt_base_addr);
+    return PT_ENTRY_PAGE;
+  }
+}
+
+pt_entry_type_t pte32pae_lookup(pte32pae_t * pt, addr_t addr, addr_t * entry) {
+  pte32pae_t * pte_entry = &(pt[PTE32PAE_INDEX(addr)]);
+
+  if (!pte_entry->present) {
+    *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pte_entry->page_base_addr) + PAGE_OFFSET(addr);
+    return PT_ENTRY_PAGE;
+  }
+}
+
+
+
+/**
+ * 
+ *  64 bit Page Table lookup functions
+ *
+ **/
+pt_entry_type_t pml4e64_lookup(pml4e64_t * pml, addr_t addr, addr_t * entry) {
+  pml4e64_t * pml_entry = &(pml[PML4E64_INDEX(addr)]);
+
+  if (!pml_entry->present) {
+    *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pml_entry->pdp_base_addr);
+    return PT_ENTRY_PAGE;
+  }
+}
+
+pt_entry_type_t pdpe64_lookup(pdpe64_t * pdp, addr_t addr, addr_t * entry) {
+  pdpe64_t * pdpe_entry = &(pdp[PDPE64_INDEX(addr)]);
+  
+  if (!pdpe_entry->present) {
+    *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else if (pdpe_entry->large_page) {
+    PrintError("1 Gigabyte pages not supported\n");
+    V3_ASSERT(0);
     return -1;
   } else {
-    *entry = BASE_TO_PAGE_ADDR(pdpe_entry->pd_base_addr) + PAGE_OFFSET(addr);
-    return 0;
+    *entry = BASE_TO_PAGE_ADDR(pdpe_entry->pd_base_addr);
+    return PT_ENTRY_PAGE;
   }
+}
 
-  return -1;
+pt_entry_type_t pde64_lookup(pde64_t * pd, addr_t addr, addr_t * entry) {
+  pde64_t * pde_entry = &(pd[PDE64_INDEX(addr)]);
+
+  if (!pde_entry->present) {
+    *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else if (pde_entry->large_page) {
+    pde64_2MB_t * large_pde = (pde64_2MB_t *)pde_entry;
+
+    *entry = BASE_TO_PAGE_ADDR_2MB(large_pde->page_base_addr);
+    *entry += PAGE_OFFSET_2MB(addr);
+
+    return PT_ENTRY_LARGE_PAGE;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pde_entry->pt_base_addr);
+    return PT_ENTRY_PAGE;
+  }
+}
+
+pt_entry_type_t pte64_lookup(pte64_t * pt, addr_t addr, addr_t * entry) {
+  pte64_t * pte_entry = &(pt[PTE64_INDEX(addr)]);
+
+  if (!pte_entry->present) {
+    *entry = 0;
+    return PT_ENTRY_NOT_PRESENT;
+  } else {
+    *entry = BASE_TO_PAGE_ADDR(pte_entry->page_base_addr) + PAGE_OFFSET(addr);
+    return PT_ENTRY_PAGE;
+  }
 }
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 pt_access_status_t can_access_pde32(pde32_t * pde, addr_t addr, pf_error_t access_type) {
   pde32_t * entry = &pde[PDE32_INDEX(addr)];
 
   if (entry->present == 0) {
-    return PT_ENTRY_NOT_PRESENT;
+    return PT_ACCESS_NOT_PRESENT;
   } else if ((entry->writable == 0) && (access_type.write == 1)) {
-    return PT_WRITE_ERROR;
+    return PT_ACCESS_WRITE_ERROR;
   } else if ((entry->user_page == 0) && (access_type.user == 1)) {
     // Check CR0.WP?
-    return PT_USER_ERROR;
+    return PT_ACCESS_USER_ERROR;
   }
 
   return PT_ACCESS_OK;
@@ -275,12 +342,12 @@ pt_access_status_t can_access_pte32(pte32_t * pte, addr_t addr, pf_error_t acces
   pte32_t * entry = &pte[PTE32_INDEX(addr)];
 
   if (entry->present == 0) {
-    return PT_ENTRY_NOT_PRESENT;
+    return PT_ACCESS_NOT_PRESENT;
   } else if ((entry->writable == 0) && (access_type.write == 1)) {
-    return PT_WRITE_ERROR;
+    return PT_ACCESS_WRITE_ERROR;
   } else if ((entry->user_page == 0) && (access_type.user == 1)) {
     // Check CR0.WP?
-    return PT_USER_ERROR;
+    return PT_ACCESS_USER_ERROR;
   }
 
   return PT_ACCESS_OK;
@@ -612,7 +679,7 @@ pml4e64_t * create_passthrough_pts_64(struct guest_info * info) {
          pde[k].write_through = 0;
          pde[k].cache_disable = 0;
          pde[k].accessed = 0;
-         pde[k].reserved = 0;
+         pde[k].avail = 0;
          pde[k].large_page = 0;
          //pde[k].global_page = 0;
          pde[k].vmm_info = 0;
@@ -624,7 +691,7 @@ pml4e64_t * create_passthrough_pts_64(struct guest_info * info) {
          pde[k].write_through = 0;
          pde[k].cache_disable = 0;
          pde[k].accessed = 0;
-         pde[k].reserved = 0;
+         pde[k].avail = 0;
          pde[k].large_page = 0;
          //pde[k].global_page = 0;
          pde[k].vmm_info = 0;
@@ -643,7 +710,7 @@ pml4e64_t * create_passthrough_pts_64(struct guest_info * info) {
        pdpe[j].write_through = 0;
        pdpe[j].cache_disable = 0;
        pdpe[j].accessed = 0;
-       pdpe[j].reserved = 0;
+       pdpe[j].avail = 0;
        pdpe[j].large_page = 0;
        //pdpe[j].global_page = 0;
        pdpe[j].vmm_info = 0;
@@ -655,7 +722,7 @@ pml4e64_t * create_passthrough_pts_64(struct guest_info * info) {
        pdpe[j].write_through = 0;
        pdpe[j].cache_disable = 0;
        pdpe[j].accessed = 0;
-       pdpe[j].reserved = 0;
+       pdpe[j].avail = 0;
        pdpe[j].large_page = 0;
        //pdpe[j].global_page = 0;
        pdpe[j].vmm_info = 0;
index d3611d1..c87e829 100644 (file)
@@ -213,7 +213,7 @@ void PrintPML4e64(addr_t virtual_address, pml4e64_t * pml)
 
 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",
+  PrintDebug("PDPE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage/zero=%x, kernelInfo=%x\n",
             (void *)virtual_address,
             (void *)(addr_t) (BASE_TO_PAGE_ADDR(pdpe->pd_base_addr)),
             pdpe->present,
@@ -222,9 +222,9 @@ void PrintPDPE64(addr_t virtual_address, pdpe64_t * pdpe)
             pdpe->write_through,
             pdpe->cache_disable,
             pdpe->accessed,
-            pdpe->reserved,
+            pdpe->avail,
             pdpe->large_page,
-            0,//pdpe->global_page,
+            pdpe->zero,
             pdpe->vmm_info);
 }
 
@@ -241,9 +241,9 @@ void PrintPDE64(addr_t virtual_address, pde64_t * pde)
             pde->write_through,
             pde->cache_disable,
             pde->accessed,
-            pde->reserved,
+            pde->avail,
             pde->large_page,
-            0,//pde->global_page,
+            pde->global_page,
             pde->vmm_info);
 }
 
index 3851bf3..287691e 100644 (file)
@@ -370,14 +370,14 @@ static int is_guest_pf(pt_access_status_t guest_access, pt_access_status_t shado
   if (guest_access != PT_ACCESS_OK) {
     // Guest Access Error
     
-    if ((shadow_access != PT_ENTRY_NOT_PRESENT) &&
-       (guest_access != PT_ENTRY_NOT_PRESENT)) {
+    if ((shadow_access != PT_ACCESS_NOT_PRESENT) &&
+       (guest_access != PT_ACCESS_NOT_PRESENT)) {
       // aka (guest permission error)
       return 1;
     }
 
-    if ((shadow_access == PT_ENTRY_NOT_PRESENT) &&
-       (guest_access == PT_ENTRY_NOT_PRESENT)) {      
+    if ((shadow_access == PT_ACCESS_NOT_PRESENT) &&
+       (guest_access == PT_ACCESS_NOT_PRESENT)) {      
       // Page tables completely blank, handle guest first
       return 1;
     }
@@ -476,7 +476,7 @@ static int handle_shadow_pagefault_32(struct guest_info * info, addr_t fault_add
   }
 
   
-  if (shadow_pde_access == PT_ENTRY_NOT_PRESENT) 
+  if (shadow_pde_access == PT_ACCESS_NOT_PRESENT) 
     {
       pte32_t * shadow_pt =  (pte32_t *)v3_create_new_shadow_pt();
 
@@ -531,7 +531,7 @@ static int handle_shadow_pagefault_32(struct guest_info * info, addr_t fault_add
        }
       }
     }
-  else if ((shadow_pde_access == PT_WRITE_ERROR) && 
+  else if ((shadow_pde_access == PT_ACCESS_WRITE_ERROR) && 
           (guest_pde->large_page == 1) && 
           (((pde32_4MB_t *)guest_pde)->dirty == 0)) 
     {
@@ -546,7 +546,7 @@ static int handle_shadow_pagefault_32(struct guest_info * info, addr_t fault_add
       return 0;
       
     } 
-  else if (shadow_pde_access == PT_USER_ERROR) 
+  else if (shadow_pde_access == PT_ACCESS_USER_ERROR) 
     {
       //
       // Page Directory Entry marked non-user
@@ -596,7 +596,7 @@ static int handle_large_pagefault_32(struct guest_info * info,
   }
 
   
-  if (shadow_pte_access == PT_ENTRY_NOT_PRESENT) {
+  if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) {
     // Get the guest physical address of the fault
     addr_t guest_fault_pa = BASE_TO_PAGE_ADDR_4MB(large_guest_pde->page_base_addr) + PAGE_OFFSET_4MB(fault_addr);
     host_region_type_t host_page_type = get_shadow_addr_type(info, guest_fault_pa);
@@ -647,7 +647,7 @@ static int handle_large_pagefault_32(struct guest_info * info,
        return -1;
       }
     }
-  } else if ((shadow_pte_access == PT_WRITE_ERROR) && 
+  } else if ((shadow_pte_access == PT_ACCESS_WRITE_ERROR) && 
             (shadow_pte->vmm_info == PT32_GUEST_PT)) {
 
     struct shadow_page_state * state = &(info->shdw_pg_state);
@@ -713,7 +713,7 @@ static int handle_shadow_pte32_fault(struct guest_info * info,
   }
 
 
-  if (shadow_pte_access == PT_ENTRY_NOT_PRESENT) {
+  if (shadow_pte_access == PT_ACCESS_NOT_PRESENT) {
 
     addr_t guest_pa = BASE_TO_PAGE_ADDR((addr_t)(guest_pte->page_base_addr)) +  PAGE_OFFSET(fault_addr);
 
@@ -781,7 +781,7 @@ static int handle_shadow_pte32_fault(struct guest_info * info,
       }
     }
 
-  } else if ((shadow_pte_access == PT_WRITE_ERROR) &&
+  } else if ((shadow_pte_access == PT_ACCESS_WRITE_ERROR) &&
             (guest_pte->dirty == 0)) {
 
     PrintDebug("Shadow PTE Write Error\n");