Skip to content

Commit c618de4

Browse files
Tom DohrmannFreax13
authored andcommitted
insert NOP after STI
Insert a NOP instruction after STI to make sure the interrupt shadow doesn't extend past the enable function. From the AMD64 APM, Volume 3: > If STI sets the IF flag and IF was initially clear, then interrupts > are not enabled until after the instruction following STI. Thus, if > IF is 0, this code will not allow an INTR to happen: > > STI > CLI > > In the following sequence, INTR will be allowed to happen only after the NOP. > > STI > NOP > CLI
1 parent 2c86471 commit c618de4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/instructions/interrupts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn enable() {
1818
// Omit `nomem` to imitate a lock release. Otherwise, the compiler
1919
// is free to move reads and writes through this asm block.
2020
unsafe {
21-
asm!("sti", options(preserves_flags, nostack));
21+
asm!("sti", "nop", options(preserves_flags, nostack));
2222
}
2323
}
2424

0 commit comments

Comments
 (0)