Re: [PATCH] x86, nmi: workaround sti; hlt race vs nmi; intr

From: Joerg Roedel
Date: Mon Sep 27 2010 - 06:31:33 EST


On Sun, Sep 19, 2010 at 06:28:19PM +0200, Avi Kivity wrote:
> On machines without monitor/mwait we use an sti; hlt sequence to atomically
> enable interrupts and put the cpu to sleep. The sequence uses the "interrupt
> shadow" property of the sti instruction: interrupts are enabled only after
> the instruction following sti has been executed. This means an interrupt
> cannot happen in the middle of the sequence, which would leave us with
> the interrupt processed but the cpu halted.
>
> The interrupt shadow, however, can be broken by an nmi; the following
> sequence
>
> sti
> nmi ... iret
> # interrupt shadow disabled
> intr ... iret
> hlt
>
> puts the cpu to sleep, even though the interrupt may need additional
> processing after the hlt (like scheduling a task).

Doesn't the interrupt return path check for a re-schedule condition
before iret? So to my believe the handler would not jump back to the
idle task if something else becomes running in the interrupt handler,
no?

Joerg

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/