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 ***
[palacios.git] / palacios / src / geekos / vmx.c
index 84b6bd6..2278da9 100644 (file)
@@ -1,8 +1,5 @@
 /* Eventually  we want to get rid of these */
-#include <geekos/mem.h>
-#include <geekos/segment.h>
-#include <geekos/gdt.h>
-#include <geekos/idt.h>
+
 #include <geekos/cpu.h>
 #include <geekos/io_devs.h>
 /* ** */
@@ -30,6 +27,8 @@ extern int Launch_VM(ullong_t vmcsPtr, uint_t eip);
 #define ROMBIOS_DEBUG_PORT    0x403
 
 
+extern struct vmm_os_hooks * os_hooks;
+
 
 static struct VM theVM;
 
@@ -186,7 +185,7 @@ void SetCtrlBitsCorrectly(int msrno, int vmcsno)
   uint_t reserved =0;
   union VMX_MSR msr;
 
-  PrintTrace("SetCtrlBitsCorrectly(%x,%x)\n",msrno,vmcsno);
+  PrintTrace("SetCtrlBitsCorrectly(%x,%x)\n", msrno, vmcsno);
   Get_MSR(msrno, &msr.regs.high, &msr.regs.low);
   PrintTrace("MSR %x = %x : %x \n", msrno, msr.regs.high, msr.regs.low);
   reserved = msr.regs.low;
@@ -216,8 +215,8 @@ extern int vmRunning;
 
 static int PanicUnhandledVMExit(struct VM *vm)
 {
-  Print("Panicking due to VMExit with reason %u\n",vm->vmcs.exitInfoFields.reason);
-  PrintTrace("Panicking due to VMExit with reason %u\n",vm->vmcs.exitInfoFields.reason);
+  PrintInfo("Panicking due to VMExit with reason %u\n", vm->vmcs.exitInfoFields.reason);
+  PrintTrace("Panicking due to VMExit with reason %u\n", vm->vmcs.exitInfoFields.reason);
   PrintTrace_VMCS_ALL();
   PrintTrace_VMX_Regs(&(vm->registers));
   VMXPanic();
@@ -267,13 +266,13 @@ static int HandleInOutExit(struct VM *vm)
   address=GetLinearIP(vm);
 
   PrintTrace("Handling Input/Output Instruction Exit\n");
-  if (SERIAL_PRINT_DEBUG && 1000>=SERIAL_PRINT_DEBUG_LEVEL) {
-      PrintTrace_VMX_Regs(regs);
-  }
-  PrintTrace("Qualifications=0x%x\n",exitinfo->qualification);
-  PrintTrace("Reason=0x%x\n",exitinfo->reason);
+
+  PrintTrace_VMX_Regs(regs);
+
+  PrintTrace("Qualifications=0x%x\n", exitinfo->qualification);
+  PrintTrace("Reason=0x%x\n", exitinfo->reason);
   PrintTrace("IO Port: 0x%x (%d)\n", qual->port, qual->port);
-  PrintTrace("Instruction Info=%x\n",exitinfo->instrInfo);
+  PrintTrace("Instruction Info=%x\n", exitinfo->instrInfo);
   PrintTrace("%x : %s %s %s instruction of length %d for %d bytes from/to port 0x%x\n",
                   address,
                   qual->dir == 0 ? "output" : "input",
@@ -283,20 +282,20 @@ static int HandleInOutExit(struct VM *vm)
                   qual->accessSize==0 ? 1 : qual->accessSize==1 ? 2 : 4,
                   qual->port);
 
-  if (qual->port==PIC_MASTER_CMD_ISR_PORT ||
-      qual->port==PIC_MASTER_IMR_PORT ||
-      qual->port==PIC_SLAVE_CMD_ISR_PORT ||
-      qual->port==PIC_SLAVE_IMR_PORT) {
+  if ((qual->port == PIC_MASTER_CMD_ISR_PORT) ||
+      (qual->port == PIC_MASTER_IMR_PORT)     ||
+      (qual->port == PIC_SLAVE_CMD_ISR_PORT)  ||
+      (qual->port == PIC_SLAVE_IMR_PORT)) {
     PrintTrace( "PIC Access\n");
   }
                   
 
-  if (qual->dir==1 && qual->REP==0 && qual->string==0) { 
+  if ((qual->dir == 1) && (qual->REP == 0) && (qual->string == 0)) { 
     char byte = In_Byte(qual->port);
 
     vm->vmcs.guestStateArea.rip += exitinfo->instrLength;
     regs->eax = (regs->eax & 0xffffff00) | byte;
-    PrintTrace("Returning 0x%x in eax\n",(regs->eax));
+    PrintTrace("Returning 0x%x in eax\n", (regs->eax));
   }
 
   if (qual->dir==0 && qual->REP==0 && qual->string==0) { 
@@ -844,7 +843,7 @@ int MyLaunch(struct VM *vm)
   //  tmpReg = 0x4100;
   tmpReg = 0xffffffff;
   if (VMCS_WRITE(EXCEPTION_BITMAP,&tmpReg ) != VMX_SUCCESS) {
-    Print("Bitmap error\n");
+    PrintInfo("Bitmap error\n");
   }
 
   ConfigureExits(vm);
@@ -884,21 +883,21 @@ int VMLaunch(struct VMDescriptor *vm)
 
 VmxOnRegion * CreateVmxOnRegion() {
   union VMX_MSR basicMSR;
-  VmxOnRegion * region = (VmxOnRegion *)Alloc_Page();
+  VmxOnRegion * region = (VmxOnRegion *)(os_hooks)->allocate_pages(1);
 
   Get_MSR(IA32_VMX_BASIC_MSR, &basicMSR.regs.high, &basicMSR.regs.low);
   //  memcpy(region, &basicMSR.vmxBasic.revision, sizeof(uint_t));
 
   *(ulong_t*)region = basicMSR.vmxBasic.revision;
 
-  Print("VMX revision: 0x%lu\n", *(ulong_t *)region);
+  PrintInfo("VMX revision: 0x%lu\n", *(ulong_t *)region);
 
   return region;
 }
 
 VMCS * CreateVMCS() {
   union VMX_MSR basicMSR;
-  VMCS * vmcs = (VMCS *)Alloc_Page();
+  VMCS * vmcs = (VMCS *)(os_hooks)->allocate_pages(1);
 
   Get_MSR(IA32_VMX_BASIC_MSR, &basicMSR.regs.high, &basicMSR.regs.low);
   *(ulong_t *)vmcs = basicMSR.vmxBasic.revision;