From: Jack Lange Date: Fri, 27 Jul 2012 18:34:56 +0000 (-0400) Subject: exit handler tweaks X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f4952e76f4fadb1abd32626b57b6d9b272003cc;hp=0c942db0269c98d20875637eab9e97d639f7cda8;p=palacios.git exit handler tweaks --- diff --git a/palacios/include/palacios/vmm_exits.h b/palacios/include/palacios/vmm_exits.h index e793137..899bf0b 100644 --- a/palacios/include/palacios/vmm_exits.h +++ b/palacios/include/palacios/vmm_exits.h @@ -98,7 +98,7 @@ int v3_hook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, void * priv_data, struct guest_info * current_core); -int v3_unhook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type); +int v3_unhook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, struct guest_info * current_core); #endif diff --git a/palacios/src/palacios/vmm_exits.c b/palacios/src/palacios/vmm_exits.c index e76a3b3..8093fae 100644 --- a/palacios/src/palacios/vmm_exits.c +++ b/palacios/src/palacios/vmm_exits.c @@ -156,7 +156,8 @@ int v3_hook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, hook->handler = handler; hook->priv_data = priv_data; - if (vm->run_state != VM_INVALID) { + if ((vm->run_state == VM_RUNNING) || + (vm->run_state == VM_SIMULATING)) { int i = 0; while (v3_raise_barrier(vm, current_core) == -1); @@ -173,8 +174,56 @@ int v3_hook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, v3_lower_barrier(vm); } + return 0; +} - return 0; +int v3_unhook_exit(struct v3_vm_info * vm, v3_exit_type_t exit_type, struct guest_info * current_core) { + struct v3_exit_map * map = &(vm->exit_map); + struct v3_exit_hook * hook = NULL; + + + if (exit_type >= V3_EXIT_INVALID) { + PrintError("Error: Tried to unhook invalid exit type (%d)\n", exit_type); + return -1; + } + + hook = &(map->exits[exit_type]); + + if (hook->registered == 0) { + PrintError("Tried to unhook an unregistered exit (%d)\n", exit_type); + return -1; + } + + if (hook->hooked == 0) { + PrintError("Tried to unhook and unhooked exit (%d)\n", exit_type); + return -1; + } + + + hook->hooked = 0; + hook->handler = NULL; + hook->priv_data = NULL; + + + if ((vm->run_state == VM_RUNNING) || + (vm->run_state == VM_SIMULATING)) { + int i = 0; + + while (v3_raise_barrier(vm, current_core) == -1); + + for (i = 0; i < vm->num_cores; i++) { + + if (hook->disable(&(vm->cores[i]), exit_type) != 0) { + PrintError("Error could not enable exit hook %d on core %d\n", exit_type, i); + v3_lower_barrier(vm); + return -1; + } + } + + v3_lower_barrier(vm); + } + + return 0; }