Skip to main content
The CPU subsystem in MVH Kernel is composed of five cooperating drivers that together fully characterize, initialize, and expose the x86_64 processor at boot. On startup, the kernel queries CPUID to identify the vendor, brand string, family/model/stepping, and every feature flag it needs. It then initializes the FPU and extended state (SSE, XSAVE, AVX, AVX-512F) based on the capabilities that CPUID reports, enables the applicable security features (NX, SMEP, SMAP, UMIP, supervisor write protection), and probes the available thermal sensor backend. All of this information is surfaced through the cpuinfo and features shell commands.

Drivers in This Subsystem

CPUID Detection

cpu_init() issues CPUID leaves to populate a cpu_info_t and a cpu_capabilities_t for every subsequent kernel subsystem to consume. The following information is retrieved at boot:
  • Vendor string — e.g., GenuineIntel or AuthenticAMD (via cpu_vendor())
  • Brand string — human-readable model name, up to 48 characters (via cpu_brand())
  • Family, model, and stepping — computed from the extended family/model fields in CPUID leaf 1
  • APIC ID and logical CPU count — reported by CPUID; MVH Kernel currently runs on a single boot processor
  • Cache geometry — L1 data, L1 instruction, L2, and L3 sizes in KiB, plus cache line size in bytes
  • TSC frequency — computed at boot and stored in tsc_hz
  • Microcode revision — read from MSR 0x8B when the MSR capability is present

FPU, SSE, and AVX Initialization

The x86-fpu-xsave driver runs after CPUID detection and enables each SIMD tier only when the corresponding capability flag is set:
1

FPU

Sets CR0.MP and clears CR0.EM and CR0.TS to enable the x87 FPU. Required for any floating-point operation.
2

SSE / SSE2

Sets CR4.OSFXSR and CR4.OSXMMEXCPT. SSE2 is always present on x86_64 but the driver confirms the flags before enabling.
3

XSAVE

Sets CR4.OSXSAVE when the xsave capability is present. This is the prerequisite for any extended state (AVX, AVX-512).
4

AVX

Enables the YMM state component in the XCR0 register when the avx capability is present.
5

AVX-512F

Enables the ZMM, opmask, and hi-ZMM state components in XCR0 when the avx512f capability is present.
The xsave_bytes field in cpu_info_t reports the size of the XSAVE area in bytes as returned by CPUID leaf 0xD.

Security State Initialization

After the FPU is initialized, the kernel enables all available hardware security features: Each feature is only enabled when the matching capability flag is set. cpu_get_security_state() returns the live state for all five flags.

Hardware RNG

The x86-msr-rng driver exposes cpu_random64(), which issues the RDRAND instruction to generate a hardware-backed 64-bit random number. The function is capability-guarded: it checks the rdrand flag in cpu_capabilities_t before executing the instruction and returns 0 (failure) if the processor does not support RDRAND.
RDSEED capability detection is also present in cpu_capabilities_t (rdseed flag) for future use.

MSR Access

The x86-msr-rng driver also provides capability-guarded MSR primitives:
Before calling either function, confirm that the msr flag in cpu_capabilities_t is set. Calling cpu_wrmsr on a processor that does not support MSRs will fault.

Temperature Backends

The kernel probes for a thermal backend in priority order and stores the result in cpu_info_t. The temperature_available flag indicates whether a reading was obtained. When no supported backend is detected — such as when running inside QEMU without thermal emulation — the driver reports the temperature as unavailable and sets temperature_celsius to a sentinel value rather than crashing.
Used on supported Intel processors. The driver reads MSR 0x19C (IA32_THERM_STATUS) and MSR 0x1A2 (MSR_TEMPERATURE_TARGET) to compute the package temperature from the thermal margin. Reported in both temperature_celsius and temperature_millicelsius. The temperature_source string is set to "Intel DTS/MSR".
Used on AMD processors from families 10h through 16h. The driver reads the Tctl register from the northbridge PCI device (bus 0, device 24, function 3, offset 0xA4) and converts the raw value to degrees Celsius. The temperature_source string is set to "AMD northbridge Tctl".
Used on AMD Zen-architecture processors (families 17h through 1Ah). The driver accesses the System Management Network (SMN) via PCI indirect registers to read THM::CUR_TEMP and converts the Tctl value to degrees Celsius. The temperature_source string is set to "AMD SMN Tctl".
All backends validate the raw value against a sane range before reporting. Out-of-range readings are discarded and the temperature is reported as unavailable.

Data Structures

cpu_info_t

cpu_capabilities_t

cpu_security_state_t

Shell Commands

Full API Reference