x86_64: make cli and sti compiler barriers #158

Open
nonos-sync wants to merge 2 commits from nonos-sync/gh-611 into main AGit
Member

@eKisNonos, fixes #606.

All 24 x86_64 cli / sti / sti; hlt / cli; hlt asm sites in 14 files lose options(nomem). nomem promised LLVM the instruction touches no memory, so ordinary loads and stores could be moved across interrupt masking (e.g. out of an inlined run_without_interrupts body). Without it each one is a full compiler barrier. The instructions emitted are unchanged. preserves_flags is kept where it was (IF isn't one of the flags Rust tracks).

No proof crate includes any of these files.

Verification: kernel cargo check (x86_64-nonos.json, microkernel-core and microkernel-core,nonos-smp) passes with only the 2 existing quirk_bits.rs warnings. Not yet boot-tested; a combined make dev-image / dev-boot of all seven fix branches is still to run.


Opened on GitHub by senseix21 as pull request 611. Review and merge happen there while this repository is kept in step from GitHub; this copy follows it, and is marked merged or closed when it is.

@eKisNonos, fixes [#606](https://github.com/NON-OS/nonos-micro-kernel/issues/606). All 24 x86_64 `cli` / `sti` / `sti; hlt` / `cli; hlt` asm sites in 14 files lose `options(nomem)`. `nomem` promised LLVM the instruction touches no memory, so ordinary loads and stores could be moved across interrupt masking (e.g. out of an inlined `run_without_interrupts` body). Without it each one is a full compiler barrier. The instructions emitted are unchanged. `preserves_flags` is kept where it was (IF isn't one of the flags Rust tracks). No proof crate includes any of these files. **Verification:** kernel `cargo check` (`x86_64-nonos.json`, `microkernel-core` and `microkernel-core,nonos-smp`) passes with only the 2 existing `quirk_bits.rs` warnings. Not yet boot-tested; a combined `make dev-image` / `dev-boot` of all seven fix branches is still to run. --- Opened on GitHub by senseix21 as [pull request 611](https://github.com/NON-OS/microkernel/pull/611). Review and merge happen there while this repository is kept in step from GitHub; this copy follows it, and is marked merged or closed when it is.
Every x86_64 cli, sti and sti; hlt was emitted with options(nomem), which
promises LLVM the instruction touches no memory. The compiler may then move
ordinary loads and stores across it, so code meant to run with interrupts
masked, such as the body of run_without_interrupts once it is inlined, can
be scheduled outside the masked window. Without nomem each one is a full
compiler barrier, which is what the masking relies on. The instructions
emitted do not change.

Refs #606
nonos-sync changed title from WIP: x86_64: make cli and sti compiler barriers to x86_64: make cli and sti compiler barriers 2026-10-10 05:09:39 -04:00
# Conflicts:
#	src/arch/x86_64/idt/ops/init.rs
#	src/arch/x86_64/idt/ops/interrupt.rs
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin +refs/pull/158/head:nonos-sync/gh-611
git switch nonos-sync/gh-611
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
NON-OS/nonos-micro-kernel!158
No description provided.