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.)