From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52403 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PmNmF-0000KU-D1 for qemu-devel@nongnu.org; Mon, 07 Feb 2011 04:53:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PmNmD-0004cZ-K4 for qemu-devel@nongnu.org; Mon, 07 Feb 2011 04:52:59 -0500 Received: from david.siemens.de ([192.35.17.14]:16281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PmNmD-0004cB-BS for qemu-devel@nongnu.org; Mon, 07 Feb 2011 04:52:57 -0500 Message-ID: <4D4FC0E5.4050107@siemens.com> Date: Mon, 07 Feb 2011 10:52:37 +0100 From: Jan Kiszka MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] correctly check ppr priority during interrupt injection References: <20110206092920.GZ14984@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: Yoshiaki Tamura , "qemu-devel@nongnu.org" On 2011-02-07 00:45, Yoshiaki Tamura wrote: > 2011/2/6 Gleb Natapov : >> >> TPR blocks all interrupts in a priority class, so simple "less or >> equal" check is not enough. >> >> Signed-off-by: Gleb Natapov >> diff --git a/hw/apic.c b/hw/apic.c >> index 2f8376a..cbac75d 100644 >> --- a/hw/apic.c >> +++ b/hw/apic.c >> @@ -372,19 +372,33 @@ static int apic_get_arb_pri(APICState *s) >> return 0; >> } >> >> -/* signal the CPU if an irq is pending */ >> -static void apic_update_irq(APICState *s) >> + >> +/* >> + * <0 - low prio interrupt, >> + * 0 - no interrupt, >> + * >0 - interrupt number >> + */ >> +static int apic_irq_pending(APICState *s) >> { >> int irrv, ppr; >> - if (!(s->spurious_vec & APIC_SV_ENABLE)) >> - return; >> irrv = get_highest_priority_int(s->irr); >> if (irrv < 0) >> - return; >> + return 0; >> ppr = apic_get_ppr(s); >> if (ppr && (irrv & 0xf0) <= (ppr & 0xf0)) >> + return -1; > > Just a minor point: braces are missing. checkpatch.pl would > help. Actually, the code above does not touch lines with missing braces (though I prefer to clean up the close environment of my patches as well) but.. >> + >> + return irrv; >> +} >> + >> +/* signal the CPU if an irq is pending */ >> +static void apic_update_irq(APICState *s) >> +{ >> + if (!(s->spurious_vec & APIC_SV_ENABLE)) >> return; ...here checkpatch would complain. Also about a trailing whitespace earlier. Besides those minor issues, patch looks good and works fine. So you can add Reviewed-by: Jan Kiszka on resubmission. Please also add a 0.14 tag, this is a must-have for stable IMO. Jan >> - cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD); >> + if (apic_irq_pending(s) > 0) { >> + cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD); >> + } >> } >> >> void apic_reset_irq_delivered(void) >> @@ -590,12 +604,13 @@ int apic_get_interrupt(DeviceState *d) >> if (!(s->spurious_vec & APIC_SV_ENABLE)) >> return -1; >> >> - /* XXX: spurious IRQ handling */ >> - intno = get_highest_priority_int(s->irr); >> - if (intno < 0) >> + intno = apic_irq_pending(s); >> + >> + if (intno == 0) { >> return -1; >> - if (s->tpr && intno <= s->tpr) >> + } else if (intno < 0) { >> return s->spurious_vec & 0xff; >> + } >> reset_bit(s->irr, intno); >> set_bit(s->isr, intno); >> apic_update_irq(s); >> -- >> Gleb. >> >> -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux