X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fgears%2Fext_sw_intr.c;h=8219447894e71576dda60f04fc3fcb899b4cd5dc;hb=25569fd796d1e1bb160b1b25ece9d4d3422720be;hp=f73b5ebc5fe166602f719c884b1c2f444350c7be;hpb=7229981629c6baa0afb61cc99cfcf6dd029c9c93;p=palacios.git diff --git a/palacios/src/gears/ext_sw_intr.c b/palacios/src/gears/ext_sw_intr.c index f73b5eb..8219447 100644 --- a/palacios/src/gears/ext_sw_intr.c +++ b/palacios/src/gears/ext_sw_intr.c @@ -37,11 +37,32 @@ #endif +struct v3_swintr_hook { + int (*handler)(struct guest_info * core, uint8_t vector, void * priv_data); + void * priv_data; +}; + + +static struct v3_swintr_hook * swintr_hooks[MAX_SWINTR_HOOKS]; + + static int init_swintr_intercept (struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** priv_data) { return 0; } +static int deinit_swintr_intercept (struct v3_vm_info * vm, void * priv_data) { + int i = 0; + + for (; i < MAX_SWINTR_HOOKS; i++) { + if (swintr_hooks[i]) + V3_Free(swintr_hooks[i]); + } + + return 0; +} + + static int init_swintr_core_svm (struct guest_info * core, void * priv_data) { vmcb_t * vmcb = (vmcb_t*)core->vmm_data; vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb); @@ -57,7 +78,7 @@ static int init_swintr_core_vmx (struct guest_info * core, void * priv_data) { } -static int init_swintr_intercept_core (struct guest_info * core, void * priv_data) { +static int init_swintr_intercept_core (struct guest_info * core, void * priv_data, void ** core_data) { v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); switch (cpu_type) { @@ -86,14 +107,6 @@ static int init_swintr_intercept_core (struct guest_info * core, void * priv_dat } -struct v3_swintr_hook { - int (*handler)(struct guest_info * core, uint8_t vector, void * priv_data); - void * priv_data; -}; - - -static struct v3_swintr_hook * swintr_hooks[256]; - static inline struct v3_swintr_hook * get_swintr_hook (struct guest_info * core, uint8_t vector) { return swintr_hooks[vector]; } @@ -102,7 +115,7 @@ static inline struct v3_swintr_hook * get_swintr_hook (struct guest_info * core, static struct v3_extension_impl swintr_impl = { .name = "swintr_intercept", .init = init_swintr_intercept, - .deinit = NULL, + .deinit = deinit_swintr_intercept, .core_init = init_swintr_intercept_core, .core_deinit = NULL, .on_entry = NULL, @@ -182,6 +195,7 @@ int v3_hook_swintr (struct guest_info * core, struct v3_swintr_hook * hook = (struct v3_swintr_hook*)V3_Malloc(sizeof(struct v3_swintr_hook)); if (hook == NULL) { + PrintError("Cannot allocate for swintr hook\n"); return -1; }