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.


fixed shadow paging up to the next error
Jack Lange [Wed, 22 Oct 2008 18:47:48 +0000 (13:47 -0500)]
palacios/include/palacios/vmm.h
palacios/src/palacios/svm.c
palacios/src/palacios/svm_handler.c
palacios/src/palacios/vm_guest_mem.c
palacios/src/palacios/vmm_ctrl_regs.c
palacios/src/palacios/vmm_mem.c

index 82a8fc2..f7a612d 100644 (file)
@@ -211,12 +211,12 @@ struct guest_info;
 
 /* This will contain function pointers that provide OS services */
 struct v3_os_hooks {
-  void (*print_info)(const char * format, ...)
-       __attribute__ ((format (printf, 1, 2)));
-  void (*print_debug)(const char * format, ...)
-       __attribute__ ((format (printf, 1, 2)));
-  void (*print_trace)(const char * format, ...)
-       __attribute__ ((format (printf, 1, 2)));
+  void (*print_info)(const char * format, ...);
+  //   __attribute__ ((format (printf, 1, 2)));
+  void (*print_debug)(const char * format, ...);
+  //   __attribute__ ((format (printf, 1, 2)));
+  void (*print_trace)(const char * format, ...);
+  //   __attribute__ ((format (printf, 1, 2)));
   
   void *(*allocate_pages)(int numPages);
   void (*free_page)(void * page);
index 7d91c45..bd5deca 100644 (file)
@@ -201,11 +201,15 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) {
     PrintDebug("Creating initial shadow page table\n");
     vm_info->direct_map_pt = (addr_t)V3_PAddr(create_passthrough_pde32_pts(vm_info));
 
-    vm_info->shdw_pg_state.shadow_cr3 |= (vm_info->direct_map_pt & ~0xfff);
+    //vm_info->shdw_pg_state.shadow_cr3 |= (vm_info->direct_map_pt & ~0xfff);
+    vm_info->shdw_pg_state.shadow_cr3 = 0;
     vm_info->shdw_pg_state.guest_cr0 = 0x0000000000000010LL;
     PrintDebug("Created\n");
 
-    guest_state->cr3 = vm_info->shdw_pg_state.shadow_cr3;
+    //guest_state->cr3 = vm_info->shdw_pg_state.shadow_cr3;
+
+    guest_state->cr3 = vm_info->direct_map_pt;
+
 
     //PrintDebugPageTables((pde32_t*)(vm_info->shdw_pg_state.shadow_cr3.e_reg.low));
 
index fece42c..4c76f8a 100644 (file)
@@ -353,12 +353,12 @@ int v3_handle_svm_exit(struct guest_info * info) {
     
 
     if (info->mem_mode == PHYSICAL_MEM) {
-      if (guest_pa_to_host_pa(info, guest_state->rip, &host_addr) == -1) {
+      if (guest_pa_to_host_va(info, guest_state->rip, &host_addr) == -1) {
        PrintError("Could not translate guest_state->rip to host address\n");
        return -1;
       }
     } else if (info->mem_mode == VIRTUAL_MEM) {
-      if (guest_va_to_host_pa(info, guest_state->rip, &host_addr) == -1) {
+      if (guest_va_to_host_va(info, guest_state->rip, &host_addr) == -1) {
        PrintError("Could not translate guest_state->rip to host address\n");
        return -1;
       }
index 32d4ab6..3400b97 100644 (file)
@@ -160,9 +160,9 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
       addr_t guest_pde = 0;
       
       if (guest_info->shdw_pg_mode == SHADOW_PAGING) {
-       guest_pde = (addr_t)CR3_TO_PDE32((void *)(guest_info->shdw_pg_state.guest_cr3));
+       guest_pde = (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)(guest_info->shdw_pg_state.guest_cr3)));
       } else if (guest_info->shdw_pg_mode == NESTED_PAGING) {
-       guest_pde = (addr_t)CR3_TO_PDE32((void *)(guest_info->ctrl_regs.cr3));
+       guest_pde = (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)(guest_info->ctrl_regs.cr3)));
       }
       
       if (guest_pa_to_host_va(guest_info, guest_pde, (addr_t *)&pde) == -1) {
index a6301db..1a287cd 100644 (file)
@@ -120,7 +120,7 @@ int v3_handle_cr0_write(struct guest_info * info) {
          
          if (v3_get_mem_mode(info) == VIRTUAL_MEM) {
            struct cr3_32 * shadow_cr3 = (struct cr3_32 *)&(info->shdw_pg_state.shadow_cr3);
-           
+           PrintDebug("Setting up Shadow Page Table\n");
            info->ctrl_regs.cr3 = *(addr_t*)shadow_cr3;
          } else  {
            info->ctrl_regs.cr3 = *(addr_t*)&(info->direct_map_pt);
@@ -261,8 +261,9 @@ int v3_handle_cr3_write(struct guest_info * info) {
                 *(uint_t*)shadow_cr3, *(uint_t*)guest_cr3);
       
 
-      cached = v3_cache_page_tables32(info, (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)*(addr_t *)new_cr3)));
 
+      cached = v3_cache_page_tables32(info, (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)*(addr_t *)new_cr3)));
+       
       if (cached == -1) {
        PrintError("CR3 Cache failed\n");
        return -1;
@@ -280,6 +281,7 @@ int v3_handle_cr3_write(struct guest_info * info) {
        PrintDebug("Reusing cached shadow Page table\n");
       }
       
+      
       shadow_cr3->pwt = new_cr3->pwt;
       shadow_cr3->pcd = new_cr3->pcd;
       
index b4a181f..1b9f16d 100644 (file)
@@ -122,6 +122,8 @@ int handle_special_page_fault(struct guest_info * info,
 {
   struct shadow_region * reg = get_shadow_region_by_addr(&(info->mem_map), fault_gpa);
 
+  PrintDebug("Handling Special Page Fault\n");
+
   switch (reg->host_type) {
   case HOST_REGION_HOOK:
     return mem_hook_dispatch(info, fault_gva, fault_gpa, access_info, (struct vmm_mem_hook *)(reg->host_addr));