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.


Direct paging changes
Steven Jaconette [Fri, 6 Feb 2009 05:39:55 +0000 (23:39 -0600)]
palacios/build/Makefile
palacios/include/palacios/vmm_direct_paging.h [new file with mode: 0644]
palacios/src/palacios/svm.c
palacios/src/palacios/vmm_direct_paging.c [new file with mode: 0644]
palacios/src/palacios/vmm_direct_paging_32.h [new file with mode: 0644]
palacios/src/palacios/vmm_shadow_paging.c

index abf8008..457f078 100644 (file)
@@ -268,6 +268,7 @@ VMM_OBJS := \
        palacios/vmm_xed.o \
        palacios/vmm_rbtree.o \
        palacios/vmm_profiler.o \
+       palacios/vmm_direct_paging.o \
 
 #              vmx.c vmcs_gen.c vmcs.c
 
diff --git a/palacios/include/palacios/vmm_direct_paging.h b/palacios/include/palacios/vmm_direct_paging.h
new file mode 100644 (file)
index 0000000..c33833a
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __VMM_DIRECT_PAGING_H__
+#define __VMM_DIRECT_PAGING_H__
+
+#ifdef __V3VEE__
+
+#include <palacios/vmm_mem.h>
+#include <palacios/vmm_paging.h>
+
+pde32_t * v3_create_direct_passthrough_pts(struct guest_info * guest_info);
+
+int v3_handle_shadow_pagefault_physical_mode(struct guest_info * info, addr_t fault_addr, pf_error_t error_code);
+
+#endif // ! __V3VEE__
+
+#endif
index 50cfdd9..87ecc82 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <palacios/vmm_profiler.h>
 
+#include <palacios/vmm_direct_paging.h>
 
 extern void v3_stgi();
 extern void v3_clgi();
@@ -240,7 +241,7 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) {
 
     /* Testing 64 bit page tables for long paged real mode guests */
     //    vm_info->direct_map_pt = (addr_t)V3_PAddr(create_passthrough_pts_64(vm_info));
-    vm_info->direct_map_pt = (addr_t)V3_PAddr(create_passthrough_pts_32(vm_info));
+    vm_info->direct_map_pt = (addr_t)V3_PAddr(v3_create_direct_passthrough_pts(vm_info));
     /* End Test */
 
     vm_info->shdw_pg_state.guest_cr0 = 0x0000000000000010LL;
diff --git a/palacios/src/palacios/vmm_direct_paging.c b/palacios/src/palacios/vmm_direct_paging.c
new file mode 100644 (file)
index 0000000..55bf30d
--- /dev/null
@@ -0,0 +1,50 @@
+#include <palacios/vmm_direct_paging.h>
+
+// Inline handler functions for each cpu mode
+#include "vmm_direct_paging_32.h"
+
+#include <palacios/vmm_paging.h>
+#include <palacios/vmm.h>
+#include <palacios/vm_guest_mem.h>
+#include <palacios/vm_guest.h>
+
+pde32_t * v3_create_direct_passthrough_pts(struct guest_info * info) {
+  v3_vm_cpu_mode_t mode = v3_get_cpu_mode(info);
+  switch(mode) {
+    case REAL:
+      //break;
+    case PROTECTED:
+      PrintError("ABC\n");
+      return v3_create_direct_passthrough_pts_32(info);
+    case PROTECTED_PAE:
+      break;
+    case LONG:
+      break;
+    case LONG_32_COMPAT:
+      break;
+    default:
+      PrintError("Unknown CPU Mode\n");
+      break;
+  }
+  return NULL;
+}
+
+int v3_handle_shadow_pagefault_physical_mode(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
+  v3_vm_cpu_mode_t mode = v3_get_cpu_mode(info);
+  switch(mode) {
+    case REAL:
+      // break;
+    case PROTECTED:
+      return v3_handle_shadow_pagefault_physical_mode_32(info, fault_addr, error_code);
+    case PROTECTED_PAE:
+      break;
+    case LONG:
+      break;
+    case LONG_32_COMPAT:
+      break;
+    default:
+      PrintError("Unknown CPU Mode\n");
+      break;
+  }
+  return -1;
+}
diff --git a/palacios/src/palacios/vmm_direct_paging_32.h b/palacios/src/palacios/vmm_direct_paging_32.h
new file mode 100644 (file)
index 0000000..625abab
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef __VMM_DIRECT_PAGING_32_H__
+#define __VMM_DIRECT_PAGING_32_H__
+
+#include <palacios/vmm_mem.h>
+#include <palacios/vmm_paging.h>
+#include <palacios/vmm.h>
+#include <palacios/vm_guest_mem.h>
+#include <palacios/vm_guest.h>
+
+static pde32_t * create_pde32() {
+  void * pde = 0;
+  pde = V3_VAddr(V3_AllocPages(1));
+  memset(pde, 0, PAGE_SIZE);
+
+  return (pde32_t *) pde;
+}
+
+
+static pte32_t * create_pte32() {
+  void * pte = 0;
+  pte = V3_VAddr(V3_AllocPages(1));
+  memset(pte, 0, PAGE_SIZE);
+
+  return (pte32_t *) pte;
+}
+
+
+static inline pde32_t * v3_create_direct_passthrough_pts_32(struct guest_info * info) {
+  return create_pde32();
+}
+
+
+static inline int v3_handle_shadow_pagefault_physical_mode_32(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
+  // Check to see if pde and pte exist (create them if not)
+  pde32_t * pde = CR3_TO_PDE32_VA(info->ctrl_regs.cr3);
+  int pde_index = PDE32_INDEX(fault_addr);
+  int pte_index = PTE32_INDEX(fault_addr);
+  if(pde[pde_index].present != 1) {
+    PrintError("Creating new page table for PTE index: %d\n", pde_index);
+    pte32_t * pte = create_pte32();
+    addr_t host_addr;
+    if(guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1;
+      pte[pte_index].present = 1;
+      pte[pte_index].writable = 1;
+      pte[pte_index].user_page = 1;
+      pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr);
+
+      pde[pde_index].present = 1;
+      pde[pde_index].writable = 1;
+      pde[pde_index].user_page = 1;
+      pde[pde_index].pt_base_addr = PAGE_BASE_ADDR((addr_t)V3_PAddr(pte));
+      PrintError("Fault Addr: 0x%p\nHost Addr: 0x%p\n", (void*)fault_addr, (void*)host_addr);
+    }
+    else {
+      pte32_t * pte = (void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr);
+      if(pte[pte_index].present != 1) {
+       addr_t host_addr;
+       if(guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1;
+       pte[pte_index].present = 1;
+       pte[pte_index].writable = 1;
+       pte[pte_index].user_page = 1;
+       pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr);
+      }
+    }
+    return 0;
+}
+
+
+#endif
index 968a840..3ae28d4 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <palacios/vmm_hashtable.h>
 
+#include <palacios/vmm_direct_paging.h>
+
 #ifndef DEBUG_SHADOW_PAGING
 #undef PrintDebug
 #define PrintDebug(fmt, args...)
@@ -127,7 +129,7 @@ int v3_handle_shadow_pagefault(struct guest_info * info, addr_t fault_addr, pf_e
   
   if (v3_get_mem_mode(info) == PHYSICAL_MEM) {
     // If paging is not turned on we need to handle the special cases
-    return handle_special_page_fault(info, fault_addr, fault_addr, error_code);
+    return v3_handle_shadow_pagefault_physical_mode(info, fault_addr, error_code);
   } else if (v3_get_mem_mode(info) == VIRTUAL_MEM) {
 
     switch (v3_get_cpu_mode(info)) {