Skip to main content

Module cpuid

Module cpuid 

Source
Expand description

CPU feature detection via CPUID instruction.

Provides a CpuInfo struct populated at boot time with vendor, model, feature flags, and XSAVE geometry. All subsequent queries go through host() which returns the cached result.

Structs§

CpuFeatures
CPU feature flags detected via CPUID.
CpuInfo
Cached CPU identification and feature information.

Enums§

CpuVendor

Constants§

XCR0_AVX
XCR0_HI16_ZMM
XCR0_OPMASK
XCR0_SSE
XCR0_X87
XCR0 component bits.
XCR0_ZMM_HI256

Statics§

HOST_CPU 🔒
HOST_DEFAULT_XCR0_CACHE 🔒
Lock-free cache of the host’s default XCR0 mask, written once during init(). Used by normalized_xcr0() in the context-switch hot path to avoid acquiring the HOST_CPU spinlock with interrupts disabled.
INITIALIZED 🔒

Functions§

detect 🔒
Detect CPU features by interrogating CPUID leaves.
features_to_flags_string
Build a Linux-style flags string from CPU features.
host
Return a clone of the cached host CPU info. Panics if init() not called.
host_default_xcr0
host_default_xcr0_fast
Return the host’s default XCR0 mask from the lock-free cache, falling back to the locked query before init() is complete.
host_uses_xsave
Whether XSAVE is supported by the host.
init
Detect and cache CPU information. Must be called once at BSP boot.
tsc_frequency_khz
Return the host’s default XCR0 mask (all supported features). Safe to call before init() : returns XCR0_X87 | XCR0_SSE if not yet initialized.
xcr0_for_features
Compute the XCR0 mask for a given set of allowed features, clamped to what the host actually supports.
xsave_size_for_xcr0
Compute the XSAVE area size needed for a given XCR0 mask. Falls back to 512 (FXSAVE) if XSAVE is not supported.