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.


*** empty log message ***
Jack Lange [Fri, 28 Mar 2008 19:40:13 +0000 (19:40 +0000)]
palacios/build/Makefile
palacios/include/geekos/vm_guest.h
palacios/src/geekos/main.c
palacios/src/geekos/svm.c
palacios/src/geekos/svm_handler.c
palacios/src/geekos/vmm_paging.c
palacios/src/geekos/vmm_stubs.c

index 1406a31..adbf8cc 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile for GeekOS kernel, userspace, and tools
 # Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.17 $
+# $Revision: 1.18 $
 
 # This is free software.  You are permitted to use,
 # redistribute, and modify it as specified in the file "COPYING".
@@ -85,7 +85,7 @@ KERNEL_C_SRCS := idt.c int.c trap.c irq.c io.c \
        synch.c kthread.c \
        serial.c  reboot.c \
         paging.c vmx.c vmcs_gen.c vmcs.c \
-        svm.c svm_handler.c vmm.c vmm_util.c vmm_stubs.c \
+        svm.c svm_handler.c vmm.c vmm_util.c vmm_stubs.c svm_ctrl_regs.c \
        vmcb.c vmm_mem.c vm_guest.c vmm_paging.c vmm_io.c vmm_debug.c \
        debug.c\
        main.c
index fe3bd1f..89dd950 100644 (file)
@@ -19,7 +19,7 @@ struct guest_gprs {
 
 
 typedef enum {SHADOW_PAGING, NESTED_PAGING} vm_page_mode_t;
-
+typedef enum {REAL, PROTECTED, PROTECTED_PG, PROTECTED_PAE, PROTECTED_PAE_PG, LONG, LONG_PG} vm_cpu_mode_t;
 
 typedef struct guest_info {
   ullong_t rip;
@@ -36,6 +36,8 @@ typedef struct guest_info {
   vmm_io_map_t io_map;
   // device_map
 
+  vm_cpu_mode_t cpu_mode;
+
 
   struct guest_gprs vm_regs;
 
index c463f2d..9197521 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (c) 2001,2003,2004 David H. Hovemeyer <daveho@cs.umd.edu>
  * Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
  * Copyright (c) 2004, Iulian Neamtiu <neamtiu@cs.umd.edu>
- * $Revision: 1.22 $
+ * $Revision: 1.23 $
  * 
  * This is free software.  You are permitted to use,
  * redistribute, and modify it as specified in the file "COPYING".
@@ -311,6 +311,8 @@ void Main(struct Boot_Info* bootInfo)
     init_shadow_page_state(&(vm_info.shadow_page_state));
     vm_info.page_mode = SHADOW_PAGING;
 
+    vm_info.cpu_mode = REAL;
+
     init_vmm_io_map(&(vm_info.io_map));
 
     
index f3865ca..ab2a406 100644 (file)
@@ -43,16 +43,15 @@ int is_svm_capable() {
 
   Get_MSR(SVM_VM_CR_MSR, &vm_cr_high, &vm_cr_low);
 
+  if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_np) == 1) {
+    PrintDebug("Nested Paging not supported\n");
+  }
+
   if ((vm_cr_low & SVM_VM_CR_MSR_svmdis) == 0) {
     return 1;
   }
 
   ret = cpuid_edx(CPUID_SVM_REV_AND_FEATURE_IDS);
-  
-
-  if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_np) == 0) {
-    PrintDebug("Nested Paging not supported\n");
-  }
 
   if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_svml) == 0) {
     PrintDebug("SVM BIOS Disabled, not unlockable\n");
@@ -317,7 +316,8 @@ void Init_VMCB(vmcb_t * vmcb, guest_info_t vm_info) {
   guest_state->rip = vm_info.rip;
 
 
-
+  //ctrl_area->instrs.instrs.CR0 = 1;
+  ctrl_area->cr_reads.crs.cr0 = 1;
   ctrl_area->cr_writes.crs.cr0 = 1;
 
   guest_state->efer |= EFER_MSR_svm_enable;
@@ -395,14 +395,10 @@ void Init_VMCB(vmcb_t * vmcb, guest_info_t vm_info) {
 
     ctrl_area->cr_reads.crs.cr3 = 1;
     ctrl_area->cr_writes.crs.cr3 = 1;
-    ctrl_area->cr_reads.crs.cr0 = 1;
-    ctrl_area->cr_writes.crs.cr0 = 1;
+
 
     ctrl_area->instrs.instrs.INVLPG = 1;
     ctrl_area->instrs.instrs.INVLPGA = 1;
-    ctrl_area->instrs.instrs.CR0 = 1;
-       
-
 
     guest_state->g_pat = 0x7040600070406ULL;
 
index 6840ade..e9d2a90 100644 (file)
@@ -1,6 +1,6 @@
 #include <geekos/svm_handler.h>
 #include <geekos/vmm.h>
-
+#include <geekos/svm_ctrl_regs.h>
 
 
 
@@ -12,10 +12,17 @@ int handle_svm_exit(guest_info_t * info) {
   guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data));
   guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
   
+
+  // Update the high level state 
+  info->rip = guest_state->rip;
+  info->rsp = guest_state->rsp;
+
+
   PrintDebug("SVM Returned: (Exit Code=%x) (VMCB=%x)\n",&(guest_ctrl->exit_code), info->vmm_data); 
   PrintDebug("RIP: %x\n", guest_state->rip);
   
-  
+
+
   exit_code = guest_ctrl->exit_code;
   
   //  PrintDebugVMCB((vmcb_t*)(info->vmm_data));
@@ -27,6 +34,15 @@ int handle_svm_exit(guest_info_t * info) {
   PrintDebug("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4));
   if (exit_code == VMEXIT_IOIO) {
     handle_svm_io(info);
+
+  } else if (exit_code == VMEXIT_CR0_WRITE) {
+    PrintDebug("CR0 Write\n");
+    ullong_t new_cr0 = 0;
+
+    handle_cr0_write(info, &new_cr0);
+
+    guest_state->cr0 = new_cr0;
+
   } else if (( (exit_code == VMEXIT_CR3_READ)  ||
               (exit_code == VMEXIT_CR3_WRITE) ||
               (exit_code == VMEXIT_INVLPG)    ||
@@ -37,6 +53,10 @@ int handle_svm_exit(guest_info_t * info) {
   }
 
 
+  // Update the low level state
+  guest_state->rip = info->rip;
+  guest_state->rsp = info->rsp;
+
   return 0;
 }
 
@@ -76,3 +96,6 @@ int handle_shadow_paging(guest_info_t * info) {
 
   return 0;
 }
+
+
+
index 9cd97d6..5daea0f 100644 (file)
@@ -292,7 +292,7 @@ vmm_pde_t * create_passthrough_pde32_pts(shadow_map_t * map) {
     }
 
     if (pte_present == 0) { 
-      VMMFree(pte);
+      os_hooks->free_page(pte);
 
       pde[i].present = 0;
       pde[i].flags = 0;
index a9db9c6..4c37033 100644 (file)
@@ -7,12 +7,12 @@ void * Identity(void *addr) { return addr; };
 
 void * Allocate_VMM_Pages(int num_pages) {
   void * start_page = Alloc_Page();
-  SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages); 
+  //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages); 
   int i = 1;
 
   while (i < num_pages) {
     void * tmp_page = Alloc_Page();
-    SerialPrint("Allocating Page: %x (%d of %d)\n",tmp_page, i+1, num_pages); 
+    //SerialPrint("Allocating Page: %x (%d of %d)\n",tmp_page, i+1, num_pages); 
     
     if (tmp_page != start_page + (PAGE_SIZE * i)) {
       //we have to start over...;
@@ -21,7 +21,7 @@ void * Allocate_VMM_Pages(int num_pages) {
        i--;
       }
       start_page = Alloc_Page();
-      SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
+      //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
       i = 1;
       continue;
     }