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§
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 bynormalized_xcr0()in the context-switch hot path to avoid acquiring theHOST_CPUspinlock with interrupts disabled. - INITIALIZED 🔒
Functions§
- detect 🔒
- Detect CPU features by interrogating CPUID leaves.
- features_
to_ flags_ string - Build a Linux-style
flagsstring 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(): returnsXCR0_X87 | XCR0_SSEif 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.