From: Patrick G. Bridges Date: Tue, 12 Oct 2010 17:43:17 +0000 (-0600) Subject: Fixed ioapic bug that caused interrupt routing entries to be stored incorrectly and... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=ed487950f94cc28008dcf38f68f3e2a1472f9d93 Fixed ioapic bug that caused interrupt routing entries to be stored incorrectly and interrupts to be dispatched incorrectly in some modes --- diff --git a/palacios/src/devices/apic.c b/palacios/src/devices/apic.c index 763b538..b32e6f8 100644 --- a/palacios/src/devices/apic.c +++ b/palacios/src/devices/apic.c @@ -810,6 +810,8 @@ static int apic_write(struct guest_info * core, addr_t guest_addr, void * src, u apic->task_prio.val = op_val; break; case LDR_OFFSET: + PrintDebug("apic %u: core %u: setting log_dst.val to 0x%x\n", + apic->lapic_id.val, core->cpu_id, op_val); apic->log_dst.val = op_val; break; case DFR_OFFSET: @@ -1131,8 +1133,12 @@ static int apic_should_deliver_flat(struct guest_info * core, uint8_t mda, void if (mda==0xff || // broadcast or (apic->log_dst.dst_log_id & mda)) { // I am in the set + PrintDebug("apic %u core %u: accepting flat IRQ (mda 0x%x == log_dst 0x%x)\n", + apic->lapic_id.val, core->cpu_id, mda, apic->log_dst.dst_log_id); return 1; } else { + PrintDebug("apic %u core %u: rejecting flat IRQ (mda 0x%x != log_dst 0x%x)\n", + apic->lapic_id.val, core->cpu_id, mda, apic->log_dst.dst_log_id); return 0; } } @@ -1144,8 +1150,13 @@ static int apic_should_deliver_cluster(struct guest_info * core, uint8_t mda, vo if (mda==0xff || // broadcast or ( ((mda & 0xf0) == (apic->log_dst.dst_log_id & 0xf0)) && // (I am in the cluster and ((mda & 0x0f) & (apic->log_dst.dst_log_id & 0x0f)) ) ) { // I am in the set) + PrintDebug("apic %u core %u: accepting clustered IRQ (mda 0x%x == log_dst 0x%x)\n", + apic->lapic_id.val, core->cpu_id, mda, apic->log_dst.dst_log_id); + return 1; } else { + PrintDebug("apic %u core %u: rejecting clustered IRQ (mda 0x%x != log_dst 0x%x)\n", + apic->lapic_id.val, core->cpu_id, mda, apic->log_dst.dst_log_id); return 0; } } diff --git a/palacios/src/devices/io_apic.c b/palacios/src/devices/io_apic.c index 7a0c6e8..48f1ed6 100644 --- a/palacios/src/devices/io_apic.c +++ b/palacios/src/devices/io_apic.c @@ -186,7 +186,7 @@ static int ioapic_read(struct guest_info * core, addr_t guest_addr, void * dst, break; default: { uint_t redir_index = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) >> 1; - uint_t hi_val = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) % 1; + uint_t hi_val = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) & 1; if (redir_index > 0x3f) { PrintError("ioapic %u: Invalid redirection table entry %x\n", ioapic->ioapic_id.id, (uint32_t)redir_index); @@ -217,6 +217,7 @@ static int ioapic_write(struct guest_info * core, addr_t guest_addr, void * src, PrintDebug("ioapic %u: IOAPIC Write at %p (val = %d)\n", ioapic->ioapic_id.id, (void *)guest_addr, *(uint32_t *)src); if (reg_tgt == 0x00) { + PrintDebug("ioapic %u: Setting ioapic index register to 0x%x.\n", ioapic->ioapic_id.id, op_val); ioapic->index_reg = op_val; } else if (reg_tgt == 0x10) { // IOWIN register @@ -235,10 +236,10 @@ static int ioapic_write(struct guest_info * core, addr_t guest_addr, void * src, default: { uint_t redir_index = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) >> 1; - uint_t hi_val = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) % 1; - - + uint_t hi_val = (ioapic->index_reg - IOAPIC_REDIR_BASE_REG) & 1; + PrintDebug("ioapic %u: Writing value 0x%x to redirection entry %u (%s)\n", + ioapic->ioapic_id.id, op_val, redir_index, hi_val ? "hi" : "low"); if (redir_index > 0x3f) { PrintError("ioapic %u: Invalid redirection table entry %x\n", ioapic->ioapic_id.id, (uint32_t)redir_index);