ax-cpu 0.10.0

Privileged instruction and structure abstractions for various CPU architectures
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Page-table publication ordering.

/// Publishes page-table stores before a subsequent invalidation.
pub fn synchronize_page_table_writes() {
    core::sync::atomic::fence(core::sync::atomic::Ordering::SeqCst);
}

/// Completes prior loads and stores before later memory accesses.
/// This includes a compiler memory barrier and executes MFENCE locally.
pub fn data_fence() {
    // SAFETY: MFENCE is available in long mode and does not dereference memory.
    unsafe {
        core::arch::asm!("mfence", options(nostack, preserves_flags));
    }
}