X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_intr.c;h=06d5254bc79b455eb120867bf30051858a16bd35;hb=e3b62e7befa086a4fb320890952f54667ee46329;hp=48e46ea0e97cd77077c0caeb5df3967158fdb425;hpb=7e2270f01390b44dc99e28d56abb30bee18d1907;p=palacios.releases.git diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c index 48e46ea..06d5254 100644 --- a/palacios/src/palacios/vmm_intr.c +++ b/palacios/src/palacios/vmm_intr.c @@ -98,6 +98,11 @@ void v3_deinit_intr_routers(struct v3_vm_info * vm) { void * v3_register_intr_controller(struct guest_info * info, struct intr_ctrl_ops * ops, void * priv_data) { struct intr_controller * ctrlr = (struct intr_controller *)V3_Malloc(sizeof(struct intr_controller)); + if (!ctrlr) { + PrintError("Cannot allocate in registering an interrupt controller\n"); + return NULL; + } + ctrlr->priv_data = priv_data; ctrlr->ctrl_ops = ops; @@ -131,6 +136,11 @@ void v3_remove_intr_controller(struct guest_info * core, void * handle) { void * v3_register_intr_router(struct v3_vm_info * vm, struct intr_router_ops * ops, void * priv_data) { struct intr_router * router = (struct intr_router *)V3_Malloc(sizeof(struct intr_router)); + if (!router) { + PrintError("Cannot allocate in registering an interrupt router\n"); + return NULL; + } + router->priv_data = priv_data; router->router_ops = ops; @@ -175,12 +185,15 @@ int v3_hook_irq(struct v3_vm_info * vm, { struct v3_irq_hook * hook = (struct v3_irq_hook *)V3_Malloc(sizeof(struct v3_irq_hook)); + if (hook == NULL) { + PrintError("Cannot allocate when hooking an irq\n"); return -1; } if (get_irq_hook(vm, irq) != NULL) { PrintError("IRQ %d already hooked\n", irq); + V3_Free(hook); return -1; } @@ -191,6 +204,8 @@ int v3_hook_irq(struct v3_vm_info * vm, if (V3_Hook_Interrupt(vm, irq)) { PrintError("hook_irq: failed to hook irq %d\n", irq); + vm->intr_routers.hooks[irq] = NULL; + V3_Free(hook); return -1; } else { PrintDebug("hook_irq: hooked irq %d\n", irq); @@ -347,7 +362,15 @@ v3_intr_type_t v3_intr_pending(struct guest_info * info) { // PrintDebug("[intr_pending]\n"); addr_t irq_state = v3_lock_irqsave(intr_state->irq_lock); - // VIRQs have priority + // External IRQs have lowest priority + list_for_each_entry(ctrl, &(intr_state->controller_list), ctrl_node) { + if (ctrl->ctrl_ops->intr_pending(info, ctrl->priv_data) == 1) { + ret = V3_EXTERNAL_IRQ; + break; + } + } + + // VIRQs have 2nd priority for (i = 0; i < MAX_IRQ / 8; i++) { if (intr_state->virq_map[i] != 0) { ret = V3_VIRTUAL_IRQ; @@ -355,16 +378,7 @@ v3_intr_type_t v3_intr_pending(struct guest_info * info) { } } - if (ret == V3_INVALID_INTR) { - list_for_each_entry(ctrl, &(intr_state->controller_list), ctrl_node) { - if (ctrl->ctrl_ops->intr_pending(info, ctrl->priv_data) == 1) { - ret = V3_EXTERNAL_IRQ; - break; - } - } - } - - /* for swintr injection */ + /* SWINTRs have highest */ if (intr_state->swintr_posted == 1) { ret = V3_SOFTWARE_INTR; }