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.


got the bios setup ok, now we have to handle the exits
Jack Lange [Wed, 9 Apr 2008 00:21:54 +0000 (00:21 +0000)]
15 files changed:
palacios/build/vm_kernel
palacios/include/geekos/vm.h
palacios/include/palacios/8259a.h [new file with mode: 0644]
palacios/include/palacios/svm.h
palacios/include/palacios/vmm_intr.h [new file with mode: 0644]
palacios/include/palacios/vmm_paging.h
palacios/src/geekos/main.c
palacios/src/geekos/setup.asm
palacios/src/geekos/vm.c
palacios/src/palacios/8259a.c [new file with mode: 0644]
palacios/src/palacios/svm.c
palacios/src/palacios/svm_handler.c
palacios/src/palacios/vm_guest_mem.c
palacios/src/palacios/vmm_intr.c [new file with mode: 0644]
palacios/src/palacios/vmm_mem.c

index 5b5ab6d..971b982 100755 (executable)
Binary files a/palacios/build/vm_kernel and b/palacios/build/vm_kernel differ
index 57d3ec5..e8558c0 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __VM_H
 #define __VM_H
 
-int RunVMM();
+int RunVMM(struct Boot_Info * bootInfo);
 
 
 #endif
diff --git a/palacios/include/palacios/8259a.h b/palacios/include/palacios/8259a.h
new file mode 100644 (file)
index 0000000..64fa889
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __8259A_H
+#define __8259A_H
+
+
+
+
+
+
+#endif
index fb96a85..9c0912b 100644 (file)
@@ -62,6 +62,7 @@ int is_svm_capable();
 
 vmcb_t * Allocate_VMCB();
 void Init_VMCB(vmcb_t * vmcb, struct guest_info vm_info);
+void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info vm_info);
 void Init_VMCB_pe(vmcb_t * vmcb, struct guest_info vm_info);
 
 int init_svm_guest(struct guest_info *info);
diff --git a/palacios/include/palacios/vmm_intr.h b/palacios/include/palacios/vmm_intr.h
new file mode 100644 (file)
index 0000000..9751807
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __VMM_INTR_H
+#define __VMM_INTR_H
+
+
+
+
+#endif
index 1217513..9a6d213 100644 (file)
@@ -95,6 +95,7 @@ the host state in the vmcs before entering the guest.
 #endif
 #define PAGE_OFFSET(x)  ((((uint_t)x) & 0xfff))
 
+
 #define PAGE_POWER 12
 
 #define CR3_TO_PDE32(cr3) (((ulong_t)cr3) & 0xfffff000)
index ab7dd1f..1624aa9 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.31 $
+ * $Revision: 1.32 $
  * 
  * This is free software.  You are permitted to use,
  * redistribute, and modify it as specified in the file "COPYING".
@@ -198,7 +198,7 @@ void Main(struct Boot_Info* bootInfo)
 
 
   
-#if 1
+#if 0
   SerialPrint("Dumping VM kernel Code (first 128 bytes @ 0x%x)\n", 0x100000);
   SerialMemDump((unsigned char *)0x100000, 256);
   /*
@@ -207,9 +207,9 @@ void Main(struct Boot_Info* bootInfo)
   */
 #endif
 
-#if 0
-  SerialPrint("Dumping BIOS code f0000-fffff\n\n");
-  SerialMemDump((unsigned char *)0xf0000, 65536);
+#if 1
+  SerialPrint("Dumping BIOS code ffff0-fffff\n\n");
+  SerialMemDump((unsigned char *)0x10fff0, 16);
   /*
     SerialPrint("Dumping kernel Code (first 512 bytes @ 0x%x)\n",KERNEL_START);
     SerialMemDump((unsigned char *)VM_KERNEL_START, 512);
@@ -224,7 +224,7 @@ void Main(struct Boot_Info* bootInfo)
 #endif
 
   {
-    RunVMM();
+    RunVMM(bootInfo);
   }
 
 
index d49a373..9ddfcb3 100644 (file)
@@ -1,7 +1,7 @@
 ; -*- fundamental -*-
 ; GeekOS setup code
 ; Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
-; $Revision: 1.2 $
+; $Revision: 1.3 $
 
 ; This is free software.  You are permitted to use,
 ; redistribute, and modify it as specified in the file "COPYING".
@@ -89,12 +89,14 @@ setup_32:
        push    eax             ; memSizeKB
        
        mov     eax, GUEST_SIZE 
+       shl     eax, 9          ; Multiply the guest size by 512 to get byte size
        push    eax             ; Size of the guest kernel
 
        mov     eax, 0x100000
        push    eax             ; Load address of the guest
        
        mov     eax, VMM_SIZE
+       shl     eax, 9          ; Multiply the vmm size by 512 to get byte size
        push    eax             ; size of the VMM
 
        push    dword 8         ; bootInfoSize
index 72940ed..0f588a5 100644 (file)
@@ -64,6 +64,13 @@ int IO_Write(ushort_t port, void * src, uint_t length) {
 }
 
 
+int IO_Read_to_Serial(ushort_t port, void * dst, uint_t length) {
+  PrintBoth("Input from Guest on port %d (0x%x) Length=%d\n", port, port, length);
+  
+  return 0;
+}
+
+
 
 int IO_Write_to_Serial(ushort_t port, void * src, uint_t length) {
   PrintBoth("Output from Guest on port %d (0x%x) Length=%d\n", port, port, length);
@@ -122,7 +129,7 @@ void BuzzVM()
 
 
 
-int RunVMM() {
+int RunVMM(struct Boot_Info * bootInfo) {
 
     struct vmm_os_hooks os_hooks;
     struct vmm_ctrl_ops vmm_ops;
@@ -172,7 +179,7 @@ int RunVMM() {
       vm_info.vm_regs.rsp = (rsp +4092 );// - 0x2000;
       
             
-    } else {
+    } else if (0) {
       //add_shared_mem_range(&(vm_info.mem_layout), 0x0, 0x1000, 0x100000);
       //      add_shared_mem_range(&(vm_info.mem_layout), 0x0, 0x100000, 0x0);
       
@@ -193,6 +200,37 @@ int RunVMM() {
 
       vm_info.rip = 0;
       vm_info.vm_regs.rsp = 0x0;
+    } else {
+      shadow_region_t *ent = Malloc(sizeof(shadow_region_t));
+      /*
+       init_shadow_region_physical(ent,0xf0000,0x100000,GUEST_REGION_PHYSICAL_MEMORY,
+       0x100000, HOST_REGION_PHYSICAL_MEMORY);
+       add_shadow_region(&(vm_info.mem_map),ent);
+       ent = Malloc(sizeof(shadow_region_t));
+      */
+      void * guest_mem = Allocate_VMM_Pages(256);
+
+      PrintDebug("Guest Size: %lu\n", bootInfo->guest_size);
+
+      memcpy((void *)(guest_mem + 0xf0000), (void *)0x100000, bootInfo->guest_size);
+
+
+      SerialMemDump((unsigned char *)(guest_mem + 0xffff0), 16);
+
+      init_shadow_region_physical(ent, 0x0, 0x100000, GUEST_REGION_PHYSICAL_MEMORY, 
+                                 (addr_t)guest_mem, HOST_REGION_PHYSICAL_MEMORY);
+      add_shadow_region(&(vm_info.mem_map),ent);
+
+      hook_io_port(&(vm_info.io_map), 0x61, &IO_Read, &IO_Write);
+      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial);
+
+      hook_io_port(&(vm_info.io_map), 0x20, &IO_Read, &IO_Write_to_Serial);
+      hook_io_port(&(vm_info.io_map), 0x21, &IO_Read, &IO_Write_to_Serial);
+      hook_io_port(&(vm_info.io_map), 0xa0, &IO_Read, &IO_Write_to_Serial);
+      hook_io_port(&(vm_info.io_map), 0xa1, &IO_Read, &IO_Write_to_Serial);
+
+      vm_info.rip = 0xfff0;
+      vm_info.vm_regs.rsp = 0x0;
     }
 
     PrintBoth("Initializing Guest (eip=0x%.8x) (esp=0x%.8x)\n", (uint_t)vm_info.rip,(uint_t)vm_info.vm_regs.rsp);
diff --git a/palacios/src/palacios/8259a.c b/palacios/src/palacios/8259a.c
new file mode 100644 (file)
index 0000000..60d6180
--- /dev/null
@@ -0,0 +1,9 @@
+#include <palacios/8259a.h>
+#include <palacios/vmm.h>
+
+
+
+static const uint_t PIC1_PORT_1 0x20;
+static const uint_t PIC1_PORT_2 0x21;
+static const uint_t PIC2_PORT_1 0xA0;
+static const uint_t PIC2_PORT_2 0xA1;
index 5b2e0c8..954b904 100644 (file)
@@ -14,6 +14,7 @@
 //#include <palacios/tss.h>
 /* ** */
 
+
 extern struct vmm_os_hooks * os_hooks;
 
 extern uint_t cpuid_ecx(uint_t op);
@@ -109,12 +110,13 @@ int init_svm_guest(struct guest_info *info) {
   //  info->page_tables = NULL;
   //info->page_tables = generate_guest_page_tables_64(&(info->mem_layout), &(info->mem_list));
   //info->page_tables = generate_guest_page_tables(&(info->mem_layout), &(info->mem_list));
-  //PrintDebugPageTables(info->page_tables);
+  //  PrintDebugPageTables(info->page_tables);
 
 
   PrintDebug("Initializing VMCB (addr=%x)\n", info->vmm_data);
-  Init_VMCB((vmcb_t*)(info->vmm_data), *info);
+  Init_VMCB_BIOS((vmcb_t*)(info->vmm_data), *info);
   
+
   //  info->rip = 0;
 
   info->vm_regs.rdi = 0;
@@ -166,7 +168,8 @@ vmcb_t * Allocate_VMCB() {
 }
 
 
-void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info vm_info) {
+
+void Init_VMCB(vmcb_t * vmcb, struct guest_info vm_info) {
   vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb);
   vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA(vmcb);
   uint_t i;
@@ -176,11 +179,15 @@ void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info 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;
   guest_state->rflags = 0x00000002; // The reserved bit is always 1
   ctrl_area->svm_instrs.instrs.VMRUN = 1;
+  // guest_state->cr0 = 0x00000001;    // PE 
   ctrl_area->guest_ASID = 1;
-  guest_state->cr0 = 0x60000010;
 
 
   ctrl_area->exceptions.ex_names.de = 1;
@@ -196,10 +203,10 @@ void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info vm_info) {
   ctrl_area->exceptions.ex_names.of = 1;
   ctrl_area->exceptions.ex_names.nmi = 1;
 
-  guest_state->cs.selector = 0xf000;
-  guest_state->cs.limit=0xffff;
-  guest_state->cs.base =  0xffff0000;
-  guest_state->cs.attrib.raw = 0x9a;
+  guest_state->cs.selector = 0x0000;
+  guest_state->cs.limit=~0u;
+  guest_state->cs.base = guest_state->cs.selector<<4;
+  guest_state->cs.attrib.raw = 0xf3;
 
   
   struct vmcb_selector *segregs [] = {&(guest_state->ss), &(guest_state->ds), &(guest_state->es), &(guest_state->fs), &(guest_state->gs), NULL};
@@ -207,36 +214,11 @@ void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info vm_info) {
     struct vmcb_selector * seg = segregs[i];
     
     seg->selector = 0x0000;
-    seg->base = 0xffff0000;
-    seg->attrib.raw = 0x9b;
-    seg->limit = 0xffff;
+    seg->base = seg->selector << 4;
+    seg->attrib.raw = 0xf3;
+    seg->limit = ~0u;
   }
   
-  /* Set GPRs */
-  /*
-    EDX == 0xfxx
-    EAX, EBX, ECX, ESI, EDI, EBP, ESP == 0x0
-  */
-
-  guest_state->gdtr.base = 0;
-  guest_state->gdtr.limit = 0xffff;
-  guest_state->gdtr.attrib.raw = 0x0;
-
-  guest_state->idtr.base = 0;
-  guest_state->idtr.limit = 0xffff;
-  guest_state->idtr.attrib.raw = 0x0;
-
-  guest_state->ldtr.base = 0;
-  guest_state->ldtr.limit = 0xffff;
-  guest_state->ldtr.attrib.raw = 0x82;
-
-  guest_state->tr.base = 0;
-  guest_state->tr.limit = 0xffff;
-  guest_state->tr.attrib.raw = 0x83;
-
-
-
-
   if (vm_info.io_map.num_ports > 0) {
     vmm_io_hook_t * iter;
     addr_t io_port_bitmap;
@@ -257,12 +239,15 @@ void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info vm_info) {
       *bitmap |= 1 << (port % 8);
     }
 
+
+    //PrintDebugMemDump((uchar_t*)io_port_bitmap, PAGE_SIZE *2);
+
     ctrl_area->instrs.instrs.IOIO_PROT = 1;
   }
 
   ctrl_area->instrs.instrs.INTR = 1;
 
-  // also determine if CPU supports nested paging
+
 
   if (vm_info.page_mode == SHADOW_PAGING) {
     PrintDebug("Creating initial shadow page table\n");
@@ -273,16 +258,13 @@ void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info 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;
 
-       
     guest_state->g_pat = 0x7040600070406ULL;
 
-    vm_info.shdw_pg_state.guest_cr0.e_reg.low = guest_state->cr0;
     guest_state->cr0 |= 0x80000000;
   } else if (vm_info.page_mode == NESTED_PAGING) {
     // Flush the TLB on entries/exits
@@ -303,18 +285,21 @@ void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info vm_info) {
     //    guest_state->g_pat = 0x7040600070406ULL;
   }
 
+
+
 }
 
 
-void Init_VMCB(vmcb_t * vmcb, struct guest_info vm_info) {
+
+void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info vm_info) {
   vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb);
   vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA(vmcb);
   uint_t i;
 
 
   guest_state->rsp = vm_info.vm_regs.rsp;
-  guest_state->rip = vm_info.rip;
-
+  // guest_state->rip = vm_info.rip;
+  guest_state->rip = 0xfff0;
 
   //ctrl_area->instrs.instrs.CR0 = 1;
   ctrl_area->cr_reads.crs.cr0 = 1;
@@ -340,7 +325,7 @@ void Init_VMCB(vmcb_t * vmcb, struct guest_info vm_info) {
   ctrl_area->exceptions.ex_names.of = 1;
   ctrl_area->exceptions.ex_names.nmi = 1;
 
-  guest_state->cs.selector = 0x0000;
+  guest_state->cs.selector = 0xf000;
   guest_state->cs.limit=~0u;
   guest_state->cs.base = guest_state->cs.selector<<4;
   guest_state->cs.attrib.raw = 0xf3;
@@ -393,6 +378,8 @@ void Init_VMCB(vmcb_t * vmcb, struct guest_info vm_info) {
 
     guest_state->cr3 = vm_info.shdw_pg_state.shadow_cr3.r_reg;
 
+    //PrintDebugPageTables((pde32_t*)(vm_info.shdw_pg_state.shadow_cr3.e_reg.low));
+
     ctrl_area->cr_reads.crs.cr3 = 1;
     ctrl_area->cr_writes.crs.cr3 = 1;
 
@@ -426,6 +413,7 @@ void Init_VMCB(vmcb_t * vmcb, struct guest_info vm_info) {
 
 }
 
+
 void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) {
   vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb);
   vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA(vmcb);
@@ -586,3 +574,163 @@ void Init_VMCB_pe(vmcb_t *vmcb, struct guest_info vm_info) {
 }
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+
+
+void Init_VMCB_Real(vmcb_t * vmcb, struct guest_info vm_info) {
+  vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb);
+  vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA(vmcb);
+  uint_t i;
+
+
+  guest_state->rsp = vm_info.vm_regs.rsp;
+  guest_state->rip = vm_info.rip;
+
+
+  guest_state->efer |= EFER_MSR_svm_enable;
+  guest_state->rflags = 0x00000002; // The reserved bit is always 1
+  ctrl_area->svm_instrs.instrs.VMRUN = 1;
+  ctrl_area->guest_ASID = 1;
+  guest_state->cr0 = 0x60000010;
+
+
+  ctrl_area->exceptions.ex_names.de = 1;
+  ctrl_area->exceptions.ex_names.df = 1;
+  ctrl_area->exceptions.ex_names.pf = 1;
+  ctrl_area->exceptions.ex_names.ts = 1;
+  ctrl_area->exceptions.ex_names.ss = 1;
+  ctrl_area->exceptions.ex_names.ac = 1;
+  ctrl_area->exceptions.ex_names.mc = 1;
+  ctrl_area->exceptions.ex_names.gp = 1;
+  ctrl_area->exceptions.ex_names.ud = 1;
+  ctrl_area->exceptions.ex_names.np = 1;
+  ctrl_area->exceptions.ex_names.of = 1;
+  ctrl_area->exceptions.ex_names.nmi = 1;
+
+  guest_state->cs.selector = 0xf000;
+  guest_state->cs.limit=0xffff;
+  guest_state->cs.base =  0xffff0000;
+  guest_state->cs.attrib.raw = 0x9a;
+
+  
+  struct vmcb_selector *segregs [] = {&(guest_state->ss), &(guest_state->ds), &(guest_state->es), &(guest_state->fs), &(guest_state->gs), NULL};
+  for ( i = 0; segregs[i] != NULL; i++) {
+    struct vmcb_selector * seg = segregs[i];
+    
+    seg->selector = 0x0000;
+    seg->base = 0xffff0000;
+    seg->attrib.raw = 0x9b;
+    seg->limit = 0xffff;
+  }
+  
+  // Set GPRs 
+  //
+  //  EDX == 0xfxx
+  //  EAX, EBX, ECX, ESI, EDI, EBP, ESP == 0x0
+  //
+
+  guest_state->gdtr.base = 0;
+  guest_state->gdtr.limit = 0xffff;
+  guest_state->gdtr.attrib.raw = 0x0;
+
+  guest_state->idtr.base = 0;
+  guest_state->idtr.limit = 0xffff;
+  guest_state->idtr.attrib.raw = 0x0;
+
+  guest_state->ldtr.base = 0;
+  guest_state->ldtr.limit = 0xffff;
+  guest_state->ldtr.attrib.raw = 0x82;
+
+  guest_state->tr.base = 0;
+  guest_state->tr.limit = 0xffff;
+  guest_state->tr.attrib.raw = 0x83;
+
+
+
+
+  if (vm_info.io_map.num_ports > 0) {
+    vmm_io_hook_t * iter;
+    addr_t io_port_bitmap;
+    
+    io_port_bitmap = (addr_t)os_hooks->allocate_pages(3);
+    memset((uchar_t*)io_port_bitmap, 0, PAGE_SIZE * 3);
+    
+    ctrl_area->IOPM_BASE_PA = io_port_bitmap;
+
+    //PrintDebug("Setting up IO Map at 0x%x\n", io_port_bitmap);
+
+    FOREACH_IO_HOOK(vm_info.io_map, iter) {
+      ushort_t port = iter->port;
+      uchar_t * bitmap = (uchar_t *)io_port_bitmap;
+
+      bitmap += (port / 8);
+      PrintDebug("Setting Bit in block %x\n", bitmap);
+      *bitmap |= 1 << (port % 8);
+    }
+
+    ctrl_area->instrs.instrs.IOIO_PROT = 1;
+  }
+
+  ctrl_area->instrs.instrs.INTR = 1;
+
+  // also determine if CPU supports nested paging
+
+  if (vm_info.page_mode == SHADOW_PAGING) {
+    PrintDebug("Creating initial shadow page table\n");
+    vm_info.shdw_pg_state.shadow_cr3.e_reg.low |= ((addr_t)create_passthrough_pde32_pts(&vm_info) & ~0xfff);
+    PrintDebug("Created\n");
+
+    guest_state->cr3 = vm_info.shdw_pg_state.shadow_cr3.r_reg;
+
+    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;
+
+       
+    guest_state->g_pat = 0x7040600070406ULL;
+
+    vm_info.shdw_pg_state.guest_cr0.e_reg.low = guest_state->cr0;
+    guest_state->cr0 |= 0x80000000;
+  } else if (vm_info.page_mode == NESTED_PAGING) {
+    // Flush the TLB on entries/exits
+    //ctrl_area->TLB_CONTROL = 1;
+
+    // Enable Nested Paging
+    //ctrl_area->NP_ENABLE = 1;
+
+    //PrintDebug("NP_Enable at 0x%x\n", &(ctrl_area->NP_ENABLE));
+
+        // Set the Nested Page Table pointer
+    //    ctrl_area->N_CR3 = ((addr_t)vm_info.page_tables);
+    // ctrl_area->N_CR3 = (addr_t)(vm_info.page_tables);
+
+    //   ctrl_area->N_CR3 = Get_CR3();
+    // guest_state->cr3 |= (Get_CR3() & 0xfffff000);
+
+    //    guest_state->g_pat = 0x7040600070406ULL;
+  }
+
+}
+*/
index fed7b79..23efbc6 100644 (file)
@@ -1,5 +1,7 @@
 #include <palacios/svm_handler.h>
 #include <palacios/vmm.h>
+#include <palacios/vm_guest_mem.h>
+#include <palacios/vmm_emulate.h>
 #include <palacios/svm_ctrl_regs.h>
 #include <palacios/svm_io.h>
 
@@ -61,7 +63,7 @@ int handle_svm_exit(struct guest_info * info) {
     if (handle_cr0_write(info) == -1) {
       return -1;
     }
-
+    /*
   } else if (( (exit_code == VMEXIT_CR3_READ)  ||
               (exit_code == VMEXIT_CR3_WRITE) ||
               (exit_code == VMEXIT_INVLPG)    ||
@@ -69,6 +71,27 @@ int handle_svm_exit(struct guest_info * info) {
               (exit_code == VMEXIT_EXCP14)) && 
             (info->page_mode == SHADOW_PAGING)) {
     handle_shadow_paging(info);
+    */
+  } else {
+    addr_t rip_addr = get_addr_linear(info, guest_state->rip, guest_state->cs.selector);
+    char buf[15];
+    addr_t host_addr;
+
+    if (guest_pa_to_host_pa(info, guest_state->rip, &host_addr) == -1) {
+      PrintDebug("Could not translate guest_state->rip to host address\n");
+      return -1;
+    }
+
+    PrintDebug("Host Address of rip = 0x%x\n", host_addr);
+
+    memset(buf, 0, 15);
+    
+    PrintDebug("Reading from 0x%x in guest\n", rip_addr);
+    
+    read_guest_pa_memory(info, rip_addr, 15, buf);
+
+    PrintTraceMemDump(buf, 15);
+
   }
 
 
index 33cb5b2..d1c8bee 100644 (file)
@@ -283,7 +283,7 @@ int read_guest_va_memory(struct guest_info * guest_info, addr_t guest_va, int co
   int bytes_read = 0;
 
   while (count > 0) {
-    int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor;
+    int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor;
     int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
     addr_t host_addr;
 
@@ -314,7 +314,7 @@ int read_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int co
   int bytes_read = 0;
 
   while (count > 0) {
-    int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor;
+    int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor;
     int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
     addr_t host_addr;
 
@@ -322,11 +322,18 @@ int read_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int co
       return bytes_read;
     }
 
+    /*
+      PrintDebug("Trying to read %d bytes\n", bytes_to_copy);
+      PrintDebug("Dist to page edge=%d\n", dist_to_pg_edge);
+      PrintDebug("PAGE_ADDR=0x%x\n", PAGE_ADDR(cursor));
+      PrintDebug("guest_pa=0x%x\n", guest_pa);
+    */
+    
     memcpy(dest + bytes_read, (void*)host_addr, bytes_to_copy);
 
     bytes_read += bytes_to_copy;
     count -= bytes_to_copy;
-    cursor += bytes_to_copy;    
+    cursor += bytes_to_copy;
   }
 
   return bytes_read;
@@ -343,7 +350,7 @@ int write_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int c
   int bytes_written = 0;
 
   while (count > 0) {
-    int dist_to_pg_edge = (PAGE_OFFSET(cursor) + PAGE_SIZE) - cursor;
+    int dist_to_pg_edge = (PAGE_ADDR(cursor) + PAGE_SIZE) - cursor;
     int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
     addr_t host_addr;
 
@@ -351,8 +358,9 @@ int write_guest_pa_memory(struct guest_info * guest_info, addr_t guest_pa, int c
       return bytes_written;
     }
 
+
     memcpy((void*)host_addr, src + bytes_written, bytes_to_copy);
-    
+
     bytes_written += bytes_to_copy;
     count -= bytes_to_copy;
     cursor += bytes_to_copy;    
diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c
new file mode 100644 (file)
index 0000000..c15d68c
--- /dev/null
@@ -0,0 +1,4 @@
+#include <palacios/vmm_intr.h>
+
+
+
index 013ea0b..49586f1 100644 (file)
@@ -53,10 +53,7 @@ void free_shadow_map(shadow_map_t * map) {
 
 
 
-/* This is slightly different semantically from the mem list, in that
- * we don't allow overlaps we could probably allow overlappig regions
- * of the same type... but I'll let someone else deal with that
- */
+
 int add_shadow_region(shadow_map_t * map,
                      shadow_region_t * region) 
 {