Page MenuHomeFreeBSD

vmm/amd64: Bhyve should keep guest CPUID updated when using explicit CPUID settings
Needs ReviewPublic

Authored by rosenfeld_grumpf.hope-2000.org on Jan 22 2026, 4:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 16, 4:12 PM
Unknown Object (File)
Thu, Oct 15, 3:51 PM
Unknown Object (File)
Fri, Oct 9, 9:51 PM
Unknown Object (File)
Fri, Oct 9, 9:21 PM
Unknown Object (File)
Mon, Oct 5, 7:34 AM
Unknown Object (File)
Mon, Oct 5, 7:31 AM
Unknown Object (File)
Sun, Oct 4, 2:52 PM
Unknown Object (File)
Sat, Oct 3, 1:19 AM

Details

Reviewers
markj
chuck
emaste
Group Reviewers
bhyve
Summary

This is a port of the following bhyve improvement from illumos:

16647 bhyve should keep guest CPUID updated when using explicit CPUID settings
https://www.illumos.org/issues/16647

Some bits of information returned by the CPUID instruction depend on the
values system software previously set in the CPU's control registers.
These include

  • Leaf 1 ecx: bit 27 changes depending on whether XSAVE support is enabled in cr4
  • Leaf 1 edx: bit 9 changes depending on whether the APIC is enabled in MSR 0x1B
  • Leaf D subleaf 0/subleaf 1 ebx: values change depending on the bits set in xcr0

bhyve should ensure that VMs with explicitly-provided CPUID values
account for the guest's current CR/MSR values before returning the
explicitly-set values for these leaves. (The legacy CPUID handler,
legacy_emulate_cpuid, already handles this for VMs where explicit
CPUID settings aren't in use.)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77444
Build 74327: arc lint + arc unit

Event Timeline

One data point from running guests on the legacy path, in case it helps reviewing this: the leaf 0xD subleaf 0 EBX dependency on XCR0 is not cosmetic. We once returned a cached host value there (sized for the host's XCR0, not the guest's), and Linux 7.0 guests (Ubuntu 26.04) disabled XSAVE as inconsistent and then panicked; recomputing EBX from the guest's current XCR0 on every CPUID fixed it. So having the explicit-CPUID path do the same as legacy_emulate_cpuid() looks right to us.