pub struct SpectreMitigation;Expand description
Spectre v1 mitigation helpers.
Implementations§
Source§impl SpectreMitigation
impl SpectreMitigation
Sourcepub fn speculation_barrier()
pub fn speculation_barrier()
Insert a speculation barrier after a bounds check.
On x86_64 this emits LFENCE, on AArch64 CSDB, on RISC-V FENCE.
Sourcepub fn safe_array_access<T: Copy + Default>(arr: &[T], index: usize) -> T
pub fn safe_array_access<T: Copy + Default>(arr: &[T], index: usize) -> T
Bounds-checked array access with speculation barrier.
Returns the value at index if in bounds, otherwise returns the
default value. Always inserts a speculation barrier after the check.