Re: [patch, 2.6.10-rc3] safe_hlt() & NMIs

From: Linus Torvalds
Date: Thu Dec 16 2004 - 10:59:18 EST

On Thu, 16 Dec 2004, Ingo Molnar wrote:
> i also played a bit with the %ss instructions, and combined them with
> the cli/sti instructions and other instructions in various ways, and
> with a bit of experimenting found the following, somewhat surprising
> results:
> [ snip ]
> it shows a number of interesting effects:
> - "mov %eax,%ss" followed by the _same_ instruction cancels the
> black-hole. This i suspect is done to prevent the lockup in vm86
> mode.

I don't think it's the "same instruction". Looking at the pattern, I think
that a "mov->ss" always checks interrupts _before_ it executes, and never
checks interrupts _after_ it executes.

So I think the pattern is (for your athlon64):

- regular instructions check interrupts before they execute, _except_ if
the "dontcheck" flag was set. They clear "dontcheck" after execution.
- "mov->ss" always checks interrupts before it executes, regardless of
"dontcheck". It always sets "dontcheck".
- "sti" sets "dontcheck" if interrupts were disabled before.

So you can get two-instruction holes by doing the sequence

/* interrupts disabled */
/* any instruction except cli/mov->ss */

but no other combination (series of "mov->ss" will always check _before_
each "mov->ss", and series of "sti" will obviously only have interrupts
disabled for the _first_ sti).

And I suspect this is very much micro-architecture-dependent, although the
Athlon64 rules seem very simple and straightforward.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at