From: Jack Lange Date: Wed, 3 Feb 2010 01:24:34 +0000 (-0600) Subject: Fix interrupt injection bug due to caching irq vectors after vector mappings have... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=888c2dd8a3914f9a08e2b0e006ff96c5cc5cd792;p=palacios.git Fix interrupt injection bug due to caching irq vectors after vector mappings have changed back port of irq fix --- diff --git a/palacios/include/palacios/vmm_intr.h b/palacios/include/palacios/vmm_intr.h index 0781844..44de7db 100644 --- a/palacios/include/palacios/vmm_intr.h +++ b/palacios/include/palacios/vmm_intr.h @@ -84,6 +84,7 @@ struct intr_ctrl_ops { }; +void v3_clear_pending_intr(struct guest_info * core); void v3_register_intr_controller(struct guest_info * info, struct intr_ctrl_ops * ops, void * state); diff --git a/palacios/src/devices/8259a.c b/palacios/src/devices/8259a.c index 443fb0a..34851dd 100644 --- a/palacios/src/devices/8259a.c +++ b/palacios/src/devices/8259a.c @@ -421,6 +421,8 @@ static int write_master_port1(ushort_t port, void * src, uint_t length, struct v return -1; } + v3_clear_pending_intr(dev->vm); + if (IS_ICW1(cw)) { PrintDebug("8259 PIC: Setting ICW1 = %x (wr_Master1)\n", cw); @@ -483,12 +485,16 @@ static int write_master_port2(ushort_t port, void * src, uint_t length, struct v return -1; } + v3_clear_pending_intr(dev->vm); + if (state->master_state == ICW2) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); PrintDebug("8259 PIC: Setting ICW2 = %x (wr_Master2)\n", cw); state->master_icw2 = cw; + + if (cw1->sngl == 0) { state->master_state = ICW3; } else if (cw1->ic4 == 1) { @@ -497,6 +503,8 @@ static int write_master_port2(ushort_t port, void * src, uint_t length, struct v state->master_state = READY; } + + } else if (state->master_state == ICW3) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); @@ -539,6 +547,8 @@ static int write_slave_port1(ushort_t port, void * src, uint_t length, struct vm return -1; } + v3_clear_pending_intr(dev->vm); + if (IS_ICW1(cw)) { PrintDebug("8259 PIC: Setting ICW1 = %x (wr_Slave1)\n", cw); state->slave_icw1 = cw; @@ -597,6 +607,9 @@ static int write_slave_port2(ushort_t port, void * src, uint_t length, struct vm return -1; } + v3_clear_pending_intr(dev->vm); + + if (state->slave_state == ICW2) { struct icw1 * cw1 = (struct icw1 *)&(state->master_icw1); diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index acb5353..4b01c8b 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -309,7 +309,7 @@ static int update_irq_exit_state(struct guest_info * info) { // Interrupt was taken fully vectored info->intr_state.irq_started = 0; - } else { + } else if ((info->intr_state.irq_started == 1) && (guest_ctrl->exit_int_info.valid == 1)) { #ifdef CONFIG_DEBUG_INTERRUPTS PrintDebug("EXIT INT INFO is set (vec=%d)\n", guest_ctrl->exit_int_info.vector); #endif @@ -322,6 +322,12 @@ static int update_irq_exit_state(struct guest_info * info) { static int update_irq_entry_state(struct guest_info * info) { vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); + + if (info->intr_state.irq_pending == 0) { + guest_ctrl->guest_ctrl.V_IRQ = 0; + guest_ctrl->guest_ctrl.V_INTR_VECTOR = 0; + } + if (v3_excp_pending(info)) { uint_t excp = v3_get_excp_number(info); diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c index 656fa1e..bc36d05 100644 --- a/palacios/src/palacios/vmm_intr.c +++ b/palacios/src/palacios/vmm_intr.c @@ -200,6 +200,13 @@ int v3_raise_irq(struct guest_info * info, int irq) { } +void v3_clear_pending_intr(struct guest_info * core) { + struct v3_intr_state * intr_state = &(core->intr_state); + + intr_state->irq_pending = 0; + +} + v3_intr_type_t v3_intr_pending(struct guest_info * info) { struct v3_intr_state * intr_state = &(info->intr_state);