From: Kyle Hale Date: Thu, 19 Jul 2012 23:58:07 +0000 (-0500) Subject: small fixes to swint code, add proper cleanup X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=b94be6799fca5da67eb64f5e7467c2da5dff5022;p=palacios.git small fixes to swint code, add proper cleanup --- diff --git a/palacios/include/gears/sw_intr.h b/palacios/include/gears/sw_intr.h index 45c2bdc..327fdd0 100644 --- a/palacios/include/gears/sw_intr.h +++ b/palacios/include/gears/sw_intr.h @@ -23,6 +23,8 @@ #include +#define MAX_SWINTR_HOOKS 256 + #define SW_INTR_SYSCALL_VEC 0x80 int v3_handle_swintr (struct guest_info * core); diff --git a/palacios/src/gears/ext_sw_intr.c b/palacios/src/gears/ext_sw_intr.c index 4739d51..9d9bebf 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); @@ -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,