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 full page table access check functions
[palacios.git] / palacios / src / palacios / vmm_shadow_paging.c
index 3851bf3..5e57c63 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;
     }
@@ -462,10 +462,10 @@ static int handle_shadow_pagefault_32(struct guest_info * info, addr_t fault_add
 
 
   // Check the guest page permissions
-  guest_pde_access = can_access_pde32(guest_pd, fault_addr, error_code);
+  guest_pde_access = v3_can_access_pde32(guest_pd, fault_addr, error_code);
 
   // Check the shadow page permissions
-  shadow_pde_access = can_access_pde32(shadow_pd, fault_addr, error_code);
+  shadow_pde_access = v3_can_access_pde32(shadow_pd, fault_addr, error_code);
   
   /* Was the page fault caused by the Guest's page tables? */
   if (is_guest_pf(guest_pde_access, shadow_pde_access) == 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
@@ -585,7 +585,7 @@ static int handle_large_pagefault_32(struct guest_info * info,
                                    addr_t fault_addr, pf_error_t error_code, 
                                    pte32_t * shadow_pt, pde32_4MB_t * large_guest_pde) 
 {
-  pt_access_status_t shadow_pte_access = can_access_pte32(shadow_pt, fault_addr, error_code);
+  pt_access_status_t shadow_pte_access = v3_can_access_pte32(shadow_pt, fault_addr, error_code);
   pte32_t * shadow_pte = (pte32_t *)&(shadow_pt[PTE32_INDEX(fault_addr)]);
   
   if (shadow_pte_access == PT_ACCESS_OK) {
@@ -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);
@@ -684,10 +684,10 @@ static int handle_shadow_pte32_fault(struct guest_info * info,
 
 
   // Check the guest page permissions
-  guest_pte_access = can_access_pte32(guest_pt, fault_addr, error_code);
+  guest_pte_access = v3_can_access_pte32(guest_pt, fault_addr, error_code);
 
   // Check the shadow page permissions
-  shadow_pte_access = can_access_pte32(shadow_pt, fault_addr, error_code);
+  shadow_pte_access = v3_can_access_pte32(shadow_pt, fault_addr, error_code);
   
 #ifdef DEBUG_SHADOW_PAGING
   PrintDebug("Guest PTE: (access=%d)\n\t", guest_pte_access);
@@ -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");
@@ -825,7 +825,8 @@ int v3_handle_shadow_invlpg(struct guest_info * info)
   
   
   if (info->cpu_mode != PROTECTED) {
-    return 0;
+    PrintError("Unsupported CPU mode (mode=%s)\n", v3_cpu_mode_to_str(info->cpu_mode));
+    return -1;
   }
   
   uchar_t instr[15];