Skip to content

Commit 4fbf718

Browse files
authored
Merge pull request #588 from rust-osdev/fix/nop-after-sti
insert NOP after STI
2 parents 5351719 + d95f292 commit 4fbf718

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/instructions/interrupts.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ pub fn are_enabled() -> bool {
1313
/// Enable interrupts.
1414
///
1515
/// This is a wrapper around the `sti` instruction.
16+
///
17+
/// This function executes `sti; nop` to ensure that the interrupt shadow
18+
/// caused by the `sti` instruction doesn't last beyond this function.
19+
/// Use [`enable_and_hlt`] to execute `hlt` in `sti`'s interrupt shadow.
1620
#[inline]
1721
pub fn enable() {
1822
// Omit `nomem` to imitate a lock release. Otherwise, the compiler
1923
// is free to move reads and writes through this asm block.
2024
unsafe {
21-
asm!("sti", options(preserves_flags, nostack));
25+
asm!("sti", "nop", options(preserves_flags, nostack));
2226
}
2327
}
2428

0 commit comments

Comments
 (0)