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.


source code clean up,
Jack Lange [Tue, 22 Jul 2008 20:34:51 +0000 (20:34 +0000)]
more explicit interfaces

palacios/include/palacios/vmm.h
palacios/include/palacios/vmm_dev_mgr.h
palacios/include/palacios/vmm_intr.h
palacios/include/palacios/vmm_io.h
palacios/src/geekos/vm.c
palacios/src/palacios/svm_io.c
palacios/src/palacios/vmm.c
palacios/src/palacios/vmm_dev_mgr.c
palacios/src/palacios/vmm_intr.c
palacios/src/palacios/vmm_io.c
palacios/src/palacios/vmm_shadow_paging.c

index aebc8ad..8e64a04 100644 (file)
   } while (0)                                          \
 
 
-/*
-#define V3_Malloc(type, var, size)                     \
-  do {                                                 \
-    extern struct vmm_os_hooks * os_hooks;             \
-    var = 0;                                           \
-    if ((os_hooks) && (os_hooks)->malloc) {            \
-      var = (type)(os_hooks)->malloc(size);            \
-    }                                                  \
-  } while (0)                                          \
-*/
+#define V3_FreePage(page)                      \
+  do {                                         \
+    extern struct vmm_os_hooks * os_hooks;     \
+    if ((os_hooks) && (os_hooks)->free_page) { \
+      (os_hooks)->free_page(page);             \
+    }                                          \
+  } while(0)                                   \
+
+
+
 
 #define V3_Malloc(size) ({                     \
       extern struct vmm_os_hooks * os_hooks;   \
     }                                                  \
   } while (0)                                          \
 
+
+// uint_t V3_CPU_KHZ();
 #define V3_CPU_KHZ()                                   \
   ({                                                   \
     unsigned int khz = 0;                              \
   })                                                   \
     
 
+
+#define V3_Hook_Interrupt(irq, opaque)                         \
+  ({                                                           \
+    int ret = 0;                                                       \
+    extern struct vmm_os_hooks * os_hooks;                     \
+    if ((os_hooks) && (os_hooks)->hook_interrupt) {            \
+      ret = (os_hooks)->hook_interrupt(irq, opaque);           \
+    }                                                          \
+    ret;                                                       \
+  })                                                           \
+
+
 /* ** */
 
 #define V3_ASSERT(x)                                                   \
   } while(0)                                                           \
     
 
+
+
 #define VMM_INVALID_CPU 0
 #define VMM_VMX_CPU 1
 #define VMM_SVM_CPU 2
@@ -169,21 +185,15 @@ struct vmm_os_hooks {
   void *(*paddr_to_vaddr)(void *addr);
   void *(*vaddr_to_paddr)(void *addr);
 
-  //  int (*hook_interrupt)(int irq, vmm_intr_handler handler, uint_t opaque);
-
-  int (*hook_interrupt)(struct guest_info *s, int irq);
+  //  int (*hook_interrupt)(struct guest_info *s, int irq);
 
-  int (*hook_interrupt_new)(uint_t irq, void *opaque);
+  int (*hook_interrupt)(uint_t irq, void *opaque);
 
   int (*ack_irq)(int irq);
 
 
   unsigned int (*get_cpu_khz)();
 
-  // Do we need this here?
-  //  void (*snprintf)(char * dst, char * format, int len, ...);
-
-
 
   void (*start_kernel_thread)(); // include pointer to function
 };
@@ -202,7 +212,7 @@ struct vmm_ctrl_ops {
 
 
 
-void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
+void Init_V3(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
 
 
 
index ed49769..eba13c8 100644 (file)
@@ -8,7 +8,6 @@
 struct vm_device;
 struct guest_info;
 
-
 struct vmm_dev_mgr {
   uint_t num_devs;
   struct list_head dev_list;
@@ -22,6 +21,24 @@ struct vmm_dev_mgr {
 };
 
 
+int dev_mgr_init(struct vmm_dev_mgr *mgr);
+int dev_mgr_deinit(struct vmm_dev_mgr * mgr);
+
+
+// Registration of devices
+
+//
+// The following device manager functions should only be called
+// when the guest is stopped
+//
+
+int v3_attach_device(struct guest_info *vm, struct vm_device * dev);
+int v3_unattach_device(struct vm_device *dev);
+
+
+void PrintDebugDevMgr(struct vmm_dev_mgr * mgr);
+
+#ifdef __V3VEE__
 
 struct dev_io_hook {
   ushort_t port;
@@ -49,31 +66,12 @@ struct dev_mem_hook {
 };
 
 
-// Registration of devices
-
-//
-// The following device manager functions should only be called
-// when the guest is stopped
-//
-
-int dev_mgr_init(struct vmm_dev_mgr *mgr);
-int dev_mgr_deinit(struct vmm_dev_mgr * mgr);
-
 
 
-int attach_device(struct guest_info *vm, struct vm_device * dev);
-int unattach_device(struct vm_device *dev);
-
-
-int dev_mgr_add_device(struct vmm_dev_mgr * mgr, struct vm_device * dev);
-int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev);
-
-
-
-
-void PrintDebugDevMgr(struct vmm_dev_mgr * mgr);
 void PrintDebugDev(struct vm_device * dev);
 void PrintDebugDevIO(struct vm_device * dev);
 void PrintDebugDevMgrIO(struct vmm_dev_mgr * mgr);
 
+#endif // ! __V3VEE__
+
 #endif
index 919576a..ec7a8c9 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef __VMM_INTR_H_
 #define __VMM_INTR_H_
 
+
+#ifdef __V3VEE__
+
 #include <palacios/vmm_intr.h>
 #include <palacios/vmm_types.h>
 
@@ -32,40 +35,11 @@ struct guest_info;
 
 
 
-/* We need a way to allow the APIC/PIC to decide when they are supposed to receive interrupts...
- * Maybe a notification call when they have been turned on, to deliver irqs to them...
- * We can rehook the guest raise_irq op, to the appropriate controller
- */
 
 
-struct vm_intr {
-
-  /* We need to rework the exception state, to handle stacking */
-  uint_t excp_pending;
-  uint_t excp_num;
-  uint_t excp_error_code_valid : 1;
-  uint_t excp_error_code;
-  
-  struct intr_ctrl_ops * controller;
-  void * controller_state;
-
-  /* some way to get the [A]PIC intr */
-
-};
-
 
 
 int v3_raise_irq(struct guest_info * info, int irq);
-int hook_irq(struct guest_info * info, int irq);
-
-
-struct vmm_intr_state;
-
-int hook_irq_new(uint_t irq,
-                void (*handler)(struct vmm_intr_state *state),
-                void  *opaque);
-
-int hook_irq_for_guest_injection(struct guest_info *info, int irq);
 
 
 struct intr_ctrl_ops {
@@ -77,11 +51,11 @@ struct intr_ctrl_ops {
 
 
 
-void init_interrupt_state(struct guest_info * info);
+
 void set_intr_controller(struct guest_info * info, struct intr_ctrl_ops * ops, void * state);
 
-int raise_exception(struct guest_info * info, uint_t excp);
-int raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code);
+int v3_raise_exception(struct guest_info * info, uint_t excp);
+int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code);
 
 int intr_pending(struct guest_info * info);
 uint_t get_intr_number(struct guest_info * info);
@@ -93,4 +67,42 @@ int injecting_intr(struct guest_info * info, uint_t intr_num, intr_type_t type);
 int start_irq(struct vm_intr * intr);
 int end_irq(struct vm_intr * intr, int irq);
 */
+
+#endif // !__V3VEE__
+
+
+
+void init_interrupt_state(struct guest_info * info);
+
+/* We need a way to allow the APIC/PIC to decide when they are supposed to receive interrupts...
+ * Maybe a notification call when they have been turned on, to deliver irqs to them...
+ * We can rehook the guest raise_irq op, to the appropriate controller
+ */
+
+
+struct vm_intr {
+
+  /* We need to rework the exception state, to handle stacking */
+  uint_t excp_pending;
+  uint_t excp_num;
+  uint_t excp_error_code_valid : 1;
+  uint_t excp_error_code;
+  
+  struct intr_ctrl_ops * controller;
+  void * controller_state;
+
+  /* some way to get the [A]PIC intr */
+
+};
+
+
+struct vmm_intr_state;
+
+int v3_hook_irq(uint_t irq,
+                void (*handler)(struct vmm_intr_state *state),
+                void  *opaque);
+
+int v3_hook_irq_for_guest_injection(struct guest_info *info, int irq);
+
+
 #endif
index 34c04f0..9609453 100644 (file)
@@ -1,15 +1,49 @@
 #ifndef __VMM_IO_H
 #define __VMM_IO_H
 
-#include <palacios/vmm_types.h>
 
+
+#include <palacios/vmm_types.h>
 #include <palacios/vmm_util.h>
 
+
+struct vmm_io_hook;
+
+typedef struct vmm_io_map {
+  uint_t num_ports;
+
+
+  struct vmm_io_hook * head;
+
+} vmm_io_map_t;
+
+
+int v3_unhook_io_port(vmm_io_map_t * io_map, uint_t port);
+
+
+/* External API */
+int v3_hook_io_port(vmm_io_map_t * io_map, uint_t port, 
+                   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);
+
+
+
+struct vmm_io_hook * v3_get_io_hook(vmm_io_map_t * io_map, uint_t port);
+
+
+
+
+#ifdef __V3VEE__
+
+
 // FOREACH_IO_HOOK(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook)
 #define FOREACH_IO_HOOK(io_map, io_hook) for (io_hook = (io_map).head; io_hook != NULL; io_hook = (io_hook)->next)
 
 
-typedef struct vmm_io_hook {
+struct vmm_io_hook {
   ushort_t port;
 
   // Reads data into the IO port (IN, INS)
@@ -23,38 +57,18 @@ typedef struct vmm_io_hook {
   struct vmm_io_hook * next;
   struct vmm_io_hook * prev;
 
-} vmm_io_hook_t;
+};
 
-
-typedef struct vmm_io_map {
-  uint_t num_ports;
+typedef struct vmm_io_hook vmm_io_hook_t;
 
 
-  vmm_io_hook_t * head;
-
-} vmm_io_map_t;
 
 
-int add_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook);
-
-int remove_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook);
-
-vmm_io_hook_t * get_io_hook(vmm_io_map_t * io_map, uint_t port);
-
-
-/* External API */
-int hook_io_port(vmm_io_map_t * io_map, uint_t port, 
-                 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);
-
-int unhook_io_port(vmm_io_map_t * io_map, uint_t port);
-
-void init_vmm_io_map(vmm_io_map_t * io_map);
-
 void PrintDebugIOMap(vmm_io_map_t * io_map);
 
 
+#endif // !__V3VEE__
+
 
 
 
index 779e36e..a6f5bb0 100644 (file)
@@ -219,14 +219,13 @@ int RunVMM(struct Boot_Info * bootInfo) {
     os_hooks.free = &VMM_Free;
     os_hooks.vaddr_to_paddr = &Identity;
     os_hooks.paddr_to_vaddr = &Identity;
-    os_hooks.hook_interrupt = &hook_irq_stub;
-    os_hooks.hook_interrupt_new = &geekos_hook_interrupt_new;
+    os_hooks.hook_interrupt = &geekos_hook_interrupt_new;
     os_hooks.ack_irq = &ack_irq;
     os_hooks.get_cpu_khz = &get_cpu_khz;
 
 
 
-    Init_VMM(&os_hooks, &vmm_ops);
+    Init_V3(&os_hooks, &vmm_ops);
 
     //test decoder
     PrintBoth("testing decoder\n");
@@ -285,8 +284,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, NULL);
-      hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x61, &IO_Read, &IO_Write, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
       
       /*
        vm_info.cr0 = 0;
@@ -369,14 +368,14 @@ 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, NULL);
-      //hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x61, &IO_Read, &IO_Write, NULL);
+      //v3_hook_io_port(&(vm_info.io_map), 0x05, &IO_Read, &IO_Write_to_Serial, NULL);
 
 
-      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_info, NULL);
-      hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_BOCHS_debug, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x400, &IO_Read, &IO_Write_to_Serial, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x401, &IO_Read, &IO_Write_to_Serial, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x402, &IO_Read, &IO_BOCHS_info, NULL);
+      v3_hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_BOCHS_debug, NULL);
 
       {
        
@@ -442,17 +441,17 @@ int RunVMM(struct Boot_Info * bootInfo) {
 
 #endif
 
-       attach_device(&(vm_info), nvram);
-       //attach_device(&(vm_info), timer);
-       attach_device(&(vm_info), pic);
-       attach_device(&(vm_info), pit);
-       attach_device(&(vm_info), keyboard);
-       // attach_device(&(vm_info), serial);
+       v3_attach_device(&(vm_info), nvram);
+       //v3_attach_device(&(vm_info), timer);
+       v3_attach_device(&(vm_info), pic);
+       v3_attach_device(&(vm_info), pit);
+       v3_attach_device(&(vm_info), keyboard);
+       // v3_attach_device(&(vm_info), serial);
 
 
 #if GENERIC
        // Important that this be attached last!
-       attach_device(&(vm_info), generic);
+       v3_attach_device(&(vm_info), generic);
 
 #endif
 
@@ -465,15 +464,15 @@ int RunVMM(struct Boot_Info * bootInfo) {
       
 #if 1
       // give floppy controller to vm
-      hook_irq_for_guest_injection(&vm_info, 6);
+      v3_hook_irq_for_guest_injection(&vm_info, 6);
 #endif
 
 #if 1
       //primary ide
-      hook_irq_for_guest_injection(&vm_info, 14);
+      v3_hook_irq_for_guest_injection(&vm_info, 14);
 
       // secondary ide
-      hook_irq_for_guest_injection(&vm_info, 15);
+      v3_hook_irq_for_guest_injection(&vm_info, 15);
 #endif
 
 
index 488b8a2..efc5294 100644 (file)
@@ -16,7 +16,7 @@ int handle_svm_io_in(struct guest_info * info) {
   //  vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
   struct svm_io_info * io_info = (struct svm_io_info *)&(ctrl_area->exit_info1);
 
-  vmm_io_hook_t * hook = get_io_hook(&(info->io_map), io_info->port);
+  vmm_io_hook_t * hook = v3_get_io_hook(&(info->io_map), io_info->port);
   uint_t read_size = 0;
 
   if (hook == NULL) {
@@ -60,7 +60,7 @@ int handle_svm_io_ins(struct guest_info * info) {
   
   struct svm_io_info * io_info = (struct svm_io_info *)&(ctrl_area->exit_info1);
   
-  vmm_io_hook_t * hook = get_io_hook(&(info->io_map), io_info->port);
+  vmm_io_hook_t * hook = v3_get_io_hook(&(info->io_map), io_info->port);
   uint_t read_size = 0;
 
   addr_t dst_addr = 0;
@@ -195,7 +195,7 @@ int handle_svm_io_out(struct guest_info * info) {
   //  vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
   struct svm_io_info * io_info = (struct svm_io_info *)&(ctrl_area->exit_info1);
 
-  vmm_io_hook_t * hook = get_io_hook(&(info->io_map), io_info->port);
+  vmm_io_hook_t * hook = v3_get_io_hook(&(info->io_map), io_info->port);
   uint_t write_size = 0;
 
   if (hook == NULL) {
@@ -238,7 +238,7 @@ int handle_svm_io_outs(struct guest_info * info) {
   
   struct svm_io_info * io_info = (struct svm_io_info *)&(ctrl_area->exit_info1);
   
-  vmm_io_hook_t * hook = get_io_hook(&(info->io_map), io_info->port);
+  vmm_io_hook_t * hook = v3_get_io_hook(&(info->io_map), io_info->port);
   uint_t write_size = 0;
 
   addr_t dst_addr = 0;
index de1edee..036d8ae 100644 (file)
@@ -14,7 +14,7 @@ struct vmm_os_hooks * os_hooks = NULL;
 
 
 
-void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops) {
+void Init_V3(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops) {
   vmm_cpu_type = VMM_INVALID_CPU;
 
   os_hooks = hooks;
index 8f9b3a2..1d6f35c 100644 (file)
@@ -5,7 +5,6 @@
 #include <palacios/vmm_decoder.h>
 
 
-extern struct vmm_os_hooks *os_hooks;
 
 #ifndef NULL
 #define NULL 0
@@ -27,7 +26,7 @@ int dev_mgr_deinit(struct vmm_dev_mgr * mgr) {
   struct vm_device * dev;
 
   list_for_each_entry(dev, &(mgr->dev_list), dev_link) {
-    unattach_device(dev);
+    v3_unattach_device(dev);
     free_device(dev);
   }
 
@@ -37,14 +36,14 @@ int dev_mgr_deinit(struct vmm_dev_mgr * mgr) {
 
 
 
-int dev_mgr_add_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) {
+static int dev_mgr_add_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) {
   list_add(&(dev->dev_link), &(mgr->dev_list));
   mgr->num_devs++;
 
   return 0;
 }
 
-int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) {
+static int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) {
   list_del(&(dev->dev_link));
   mgr->num_devs--;
 
@@ -117,14 +116,14 @@ int dev_hook_io(struct vm_device   *dev,
                int (*read)(ushort_t port, void * dst, uint_t length, struct vm_device * dev),
                int (*write)(ushort_t port, void * src, uint_t length, struct vm_device * dev)) {
 
-  struct dev_io_hook *hook = os_hooks->malloc(sizeof(struct dev_io_hook));
+  struct dev_io_hook *hook = (struct dev_io_hook *)V3_Malloc(sizeof(struct dev_io_hook));
   
   if (!hook) { 
     return -1;
   }
 
 
-  if (hook_io_port(&(dev->vm->io_map), port, 
+  if (v3_hook_io_port(&(dev->vm->io_map), port, 
                   (int (*)(ushort_t, void *, uint_t, void *))read, 
                   (int (*)(ushort_t, void *, uint_t, void *))write, 
                   (void *)dev) == 0) {
@@ -158,11 +157,11 @@ int dev_unhook_io(struct vm_device   *dev,
   dev_mgr_remove_io_hook(mgr, hook);
   dev_remove_io_hook(dev, hook);
 
-  return unhook_io_port(&(dev->vm->io_map), port);
+  return v3_unhook_io_port(&(dev->vm->io_map), port);
 }
 
 
-int attach_device(struct guest_info * vm, struct vm_device * dev) {
+int v3_attach_device(struct guest_info * vm, struct vm_device * dev) {
   struct vmm_dev_mgr *mgr= &(vm->dev_mgr);
   
   dev->vm = vm;
@@ -172,7 +171,7 @@ int attach_device(struct guest_info * vm, struct vm_device * dev) {
   return 0;
 }
 
-int unattach_device(struct vm_device * dev) {
+int v3_unattach_device(struct vm_device * dev) {
   struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
 
   dev->ops->deinit(dev);
index 8908507..7dc3c3b 100644 (file)
@@ -34,24 +34,22 @@ struct vmm_intr_decode {
   void              *opaque;
 };
 
-int hook_irq_new(uint_t irq,
-                void (*handler)(struct vmm_intr_state *state),
-                void  *opaque)
+int v3_hook_irq(uint_t irq,
+            void (*handler)(struct vmm_intr_state *state),
+            void  *opaque)
 {
-  extern struct vmm_os_hooks * os_hooks;
-
-  struct vmm_intr_decode *d = V3_Malloc(sizeof(struct vmm_intr_decode));
+  struct vmm_intr_decode *d = (struct vmm_intr_decode *)V3_Malloc(sizeof(struct vmm_intr_decode));
 
   if (!d) { return -1; }
 
   d->handler = handler;
   d->opaque = opaque;
   
-  if (os_hooks->hook_interrupt_new(irq,d)) { 
-    PrintError("hook_irq_new: failed to hook irq 0x%x to decode 0x%x\n", irq,d);
+  if (V3_Hook_Interrupt(irq,d)) { 
+    PrintError("hook_irq: failed to hook irq 0x%x to decode 0x%x\n", irq,d);
     return -1;
   } else {
-    PrintDebug("hook_irq_new: hooked irq 0x%x to decode 0x%x\n", irq,d);
+    PrintDebug("hook_irq: hooked irq 0x%x to decode 0x%x\n", irq,d);
     return 0;
   }
 }
@@ -73,7 +71,7 @@ void deliver_interrupt_to_vmm(struct vmm_intr_state *state)
 }
 
 
-void guest_injection_irq_handler(struct vmm_intr_state *state)
+static void guest_injection_irq_handler(struct vmm_intr_state *state)
 {
   PrintDebug("guest_irq_injection: state=0x%x\n",state);
 
@@ -84,12 +82,12 @@ void guest_injection_irq_handler(struct vmm_intr_state *state)
 }
 
 
-int hook_irq_for_guest_injection(struct guest_info *info, int irq)
+int v3_hook_irq_for_guest_injection(struct guest_info *info, int irq)
 {
 
-  int rc = hook_irq_new(irq,
-                       guest_injection_irq_handler,
-                       info);
+  int rc = v3_hook_irq(irq,
+                      guest_injection_irq_handler,
+                      info);
 
   if (rc) { 
     PrintError("guest_irq_injection: failed to hook irq 0x%x for guest 0x%x\n", irq,info);
@@ -103,13 +101,7 @@ int hook_irq_for_guest_injection(struct guest_info *info, int irq)
 
 
 
-int hook_irq(struct guest_info * info, int irq) {
-  extern struct vmm_os_hooks * os_hooks;
-
-  return os_hooks->hook_interrupt(info, irq);
-}
-
-int raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code) {
+int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code) {
   struct vm_intr * intr_state = &(info->intr_state);
 
   if (intr_state->excp_pending == 0) {
@@ -126,7 +118,7 @@ int raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t err
   return 0;
 }
 
-int raise_exception(struct guest_info * info, uint_t excp) {
+int v3_raise_exception(struct guest_info * info, uint_t excp) {
   struct vm_intr * intr_state = &(info->intr_state);
 
   if (intr_state->excp_pending == 0) {
index 81febc7..91fef14 100644 (file)
@@ -18,7 +18,9 @@ void init_vmm_io_map(vmm_io_map_t * io_map) {
 
 
 
-int add_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook) {
+
+
+static int add_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook) {
 
   if (!(io_map->head)) {
     io_map->head = io_hook;
@@ -62,7 +64,7 @@ int add_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook) {
   return -1;
 }
 
-int remove_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook) {
+static int remove_io_hook(vmm_io_map_t * io_map, vmm_io_hook_t * io_hook) {
   if (io_map->head == io_hook) {
     io_map->head = io_hook->next;
   } else if (io_hook->prev) {
@@ -128,7 +130,7 @@ static int default_read(ushort_t port, void * dst, uint_t length, void * priv_da
   return 0;
 }
 
-int hook_io_port(vmm_io_map_t * io_map, uint_t port, 
+int v3_hook_io_port(vmm_io_map_t * io_map, uint_t port, 
                 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) {
@@ -161,8 +163,8 @@ int hook_io_port(vmm_io_map_t * io_map, uint_t port,
   return 0;
 }
 
-int unhook_io_port(vmm_io_map_t * io_map, uint_t port) {
-  vmm_io_hook_t * hook = get_io_hook(io_map, port);
+int v3_unhook_io_port(vmm_io_map_t * io_map, uint_t port) {
+  vmm_io_hook_t * hook = v3_get_io_hook(io_map, port);
 
   if (hook == NULL) {
     return -1;
@@ -173,7 +175,7 @@ int unhook_io_port(vmm_io_map_t * io_map, uint_t port) {
 }
 
 
-vmm_io_hook_t * get_io_hook(vmm_io_map_t * io_map, uint_t port) {
+vmm_io_hook_t * v3_get_io_hook(vmm_io_map_t * io_map, uint_t port) {
   vmm_io_hook_t * tmp_hook;
   FOREACH_IO_HOOK(*io_map, tmp_hook) {
     if (tmp_hook->port == port) {
index 9eeecc6..2c2d03d 100644 (file)
@@ -132,7 +132,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er
     // inject page fault to the guest (Guest PDE fault)
 
        info->ctrl_regs.cr2 = fault_addr;
-    raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
+    v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
 
 
     PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", guest_pde_access, error_code);
@@ -195,7 +195,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er
 
       if (host_page_type == HOST_REGION_INVALID) {
 
-       raise_exception(info, MC_EXCEPTION);
+       v3_raise_exception(info, MC_EXCEPTION);
        PrintError("Invalid guest address in large page (0x%x)\n", guest_start_addr);
        return -1;
       } else if (host_page_type == HOST_REGION_PHYSICAL_MEMORY) {
@@ -285,7 +285,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er
     
     PrintDebug("Shadow Paging User access error (shadow_pde_access=0x%x, guest_pde_access=0x%x - injecting into guest\n", shadow_pde_access, guest_pde_access);
     info->ctrl_regs.cr2 = fault_addr;
-    raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
+    v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
     return 0;
 
   } else if (shadow_pde_access == PT_ACCESS_OK) {
@@ -298,7 +298,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er
       PrintDebug("Invalid Guest PTE Address: 0x%x\n", PDE32_T_ADDR((*guest_pde)));
       // Machine check the guest
 
-      raise_exception(info, MC_EXCEPTION);
+      v3_raise_exception(info, MC_EXCEPTION);
       
       return 0;
     }
@@ -312,7 +312,7 @@ int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr, pf_er
  } else {
     // Unknown error raise page fault in guest
     info->ctrl_regs.cr2 = fault_addr;
-    raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
+    v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
 
     // For debugging we will return an error here for the time being, 
     // this probably shouldn't ever happen
@@ -379,7 +379,7 @@ int handle_shadow_pte32_fault(struct guest_info * info,
     // Inject page fault into the guest        
     
     info->ctrl_regs.cr2 = fault_addr;
-    raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
+    v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
     
     PrintDebug("Access error injecting pf to guest (guest access error=%d) (pf error code=%d)\n", guest_pte_access, *(uint_t*)&error_code);
     return 0; 
@@ -404,7 +404,7 @@ int handle_shadow_pte32_fault(struct guest_info * info,
     if (host_page_type == HOST_REGION_INVALID) {
       // Inject a machine check in the guest
 
-      raise_exception(info, MC_EXCEPTION);
+      v3_raise_exception(info, MC_EXCEPTION);
 #ifdef DEBUG_SHADOW_PAGING
       PrintDebug("Invalid Guest Address in page table (0x%x)\n", guest_pa);
       PrintDebug("fault_addr=0x%x next are guest and shadow ptes \n",fault_addr);
@@ -459,7 +459,7 @@ int handle_shadow_pte32_fault(struct guest_info * info,
     // Inject page fault into the guest        
        
     info->ctrl_regs.cr2 = fault_addr;
-    raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
+    v3_raise_exception_with_error(info, PF_EXCEPTION, *(uint_t *)&error_code);
 
     PrintError("PTE Page fault fell through... Not sure if this should ever happen\n");
     PrintError("Manual Says to inject page fault into guest\n");