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, 11 Apr 2008 21:59:49 +0000 (21:59 +0000)]
palacios/include/palacios/vmm_io.h
palacios/src/geekos/vm.c
palacios/src/palacios/svm_handler.c
palacios/src/palacios/svm_io.c
palacios/src/palacios/vmm_io.c

index f13eee8..df58367 100644 (file)
@@ -13,10 +13,12 @@ typedef struct vmm_io_hook {
   ushort_t port;
 
   // Reads data into the IO port (IN, INS)
-  int (*read)(ushort_t port, void * dst, uint_t length);
+  int (*read)(ushort_t port, void * dst, uint_t length, void * priv_data);
 
   // Writes data from the IO port (OUT, OUTS)
-  int (*write)(ushort_t port, void * src, uint_t length);
+  int (*write)(ushort_t port, void * src, uint_t length, void * priv_data);
+
+  void * priv_data;
 
   struct vmm_io_hook * next;
   struct vmm_io_hook * prev;
@@ -42,8 +44,9 @@ vmm_io_hook_t * get_io_hook(vmm_io_map_t * io_map, uint_t port);
 
 /* External API */
 void hook_io_port(vmm_io_map_t * io_map, uint_t port, 
-                 int (*read)(ushort_t port, void * dst, uint_t length),
-                 int (*write)(ushort_t port, void * src, uint_t length));
+                 int (*read)(ushort_t port, void * dst, uint_t length, void * priv_data),
+                 int (*write)(ushort_t port, void * src, uint_t length, void * priv_data), 
+                 void * priv_data );
 
 void init_vmm_io_map(vmm_io_map_t * io_map);
 
index 7a88d3e..aa3d7a1 100644 (file)
@@ -37,7 +37,7 @@ inline uchar_t VM_In_Byte(ushort_t port)
 
 
 
-int IO_Read(ushort_t port, void * dst, uint_t length) {
+int IO_Read(ushort_t port, void * dst, uint_t length, void * priv_data) {
   uchar_t * iter = dst;
   uint_t i;
 
@@ -51,7 +51,7 @@ int IO_Read(ushort_t port, void * dst, uint_t length) {
 
 
 
-int IO_Write(ushort_t port, void * src, uint_t length) {
+int IO_Write(ushort_t port, void * src, uint_t length, void * priv_data) {
   uchar_t * iter = src;
   uint_t i;
 
@@ -65,7 +65,7 @@ int IO_Write(ushort_t port, void * src, uint_t length) {
 }
 
 
-int IO_Read_to_Serial(ushort_t port, void * dst, uint_t length) {
+int IO_Read_to_Serial(ushort_t port, void * dst, uint_t length, void * priv_data) {
   PrintBoth("Input from Guest on port %d (0x%x) Length=%d\n", port, port, length);
   
   return 0;
@@ -76,7 +76,7 @@ char * bochs_debug_buf = NULL;
 int bochs_debug_offset = 0;
 
 
-int IO_BOCHS_debug(ushort_t port, void * src, uint_t length) {
+int IO_BOCHS_debug(ushort_t port, void * src, uint_t length, void * priv_data) {
   if (!bochs_debug_buf) {
     bochs_debug_buf = (char*)Malloc(1024);
   }
@@ -93,7 +93,7 @@ int IO_BOCHS_debug(ushort_t port, void * src, uint_t length) {
 }
 
 
-int IO_Write_to_Serial(ushort_t port, void * src, uint_t length) {
+int IO_Write_to_Serial(ushort_t port, void * src, uint_t length, void * priv_data) {
  SerialPrint("Output from Guest on port %d (0x%x) Length=%d\n", port, port, length);
   switch (length) {
 
@@ -214,8 +214,8 @@ int RunVMM(struct Boot_Info * bootInfo) {
 
       add_shadow_region_passthrough(&vm_info, 0x0, 0x100000, 0x100000);
 
-      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), 0x61, &IO_Read, &IO_Write, NULL);
+      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
       
       /*
        vm_info.cr0 = 0;
@@ -271,18 +271,18 @@ int RunVMM(struct Boot_Info * bootInfo) {
 
       print_shadow_map(&(vm_info.mem_map));
 
-      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), 0x61, &IO_Read, &IO_Write, NULL);
+      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
 
-      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);
+      hook_io_port(&(vm_info.io_map), 0x20, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0x21, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0xa0, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0xa1, &IO_Read, &IO_Write_to_Serial, NULL);
 
-      hook_io_port(&(vm_info.io_map), 0x400, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0x401, &IO_Read, &IO_Write_to_Serial);
-      hook_io_port(&(vm_info.io_map), 0x402, &IO_Read, &IO_BOCHS_debug);
-      hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial);
+      hook_io_port(&(vm_info.io_map), 0x400, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0x401, &IO_Read, &IO_Write_to_Serial, NULL);
+      hook_io_port(&(vm_info.io_map), 0x402, &IO_Read, &IO_BOCHS_debug, NULL);
+      hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial, NULL);
 
       vm_info.rip = 0xfff0;
       vm_info.vm_regs.rsp = 0x0;
index d1123b6..6a14ddd 100644 (file)
@@ -120,7 +120,7 @@ int handle_svm_exit(struct guest_info * info) {
       break;
     case EXCEPTION:
       guest_ctrl->EVENTINJ.type = SVM_INJECTION_EXCEPTION;
-      guest_ctrl->EVENTINJ.excp_error_code = info->intr_state.excp_error_code;
+      guest_ctrl->EVENTINJ.error_code = info->intr_state.excp_error_code;
       break;
     case SOFTWARE:
       guest_ctrl->EVENTINJ.type = SVM_INJECTION_SOFT_INTR;
index dd027c6..3668897 100644 (file)
@@ -30,7 +30,7 @@ int handle_svm_io_in(struct guest_info * info) {
   }
 
 
-  if (hook->read(io_info->port, &(info->vm_regs.rax), read_size) != read_size) {
+  if (hook->read(io_info->port, &(info->vm_regs.rax), read_size, hook->priv_data) != read_size) {
     // not sure how we handle errors.....
     return -1;
   }
@@ -113,7 +113,7 @@ int handle_svm_io_ins(struct guest_info * info) {
       // either page fault or gpf...
     }
 
-    if (hook->read(io_info->port, (char*)host_addr, read_size) != read_size) {
+    if (hook->read(io_info->port, (char*)host_addr, read_size, hook->priv_data) != read_size) {
       // not sure how we handle errors.....
       return -1;
     }
@@ -156,7 +156,7 @@ int handle_svm_io_out(struct guest_info * info) {
   }
 
 
-  if (hook->write(io_info->port, &(info->vm_regs.rax), write_size) != write_size) {
+  if (hook->write(io_info->port, &(info->vm_regs.rax), write_size, hook->priv_data) != write_size) {
     // not sure how we handle errors.....
     return -1;
   }
@@ -236,7 +236,7 @@ int handle_svm_io_outs(struct guest_info * info) {
       // either page fault or gpf...
     }
 
-    if (hook->write(io_info->port, (char*)host_addr, write_size) != write_size) {
+    if (hook->write(io_info->port, (char*)host_addr, write_size, hook->priv_data) != write_size) {
       // not sure how we handle errors.....
       return -1;
     }
index 4f58d04..bd5648d 100644 (file)
@@ -52,8 +52,9 @@ void add_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook) {
 }
 
 void hook_io_port(vmm_io_map_t * io_map, uint_t port, 
-                 int (*read)(ushort_t port, void * dst, uint_t length),
-                 int (*write)(ushort_t port, void * src, uint_t length)) {
+                 int (*read)(ushort_t port, void * dst, uint_t length, void * priv_data),
+                 int (*write)(ushort_t port, void * src, uint_t length, void * priv_data), 
+                 void * priv_data) {
   vmm_io_hook_t * io_hook = os_hooks->malloc(sizeof(vmm_io_hook_t));
 
   io_hook->port = port;
@@ -62,6 +63,8 @@ void hook_io_port(vmm_io_map_t * io_map, uint_t port,
   io_hook->next = NULL;
   io_hook->prev = NULL;
 
+  io_hook->priv_data = priv_data;
+
   add_io_hook(io_map, io_hook);
 
   return;