HomeFreeBSD

kvm: Support non-default CPUID leaf

Description

kvm: Support non-default CPUID leaf

KVM does not always use 0x40000000 as its CPUID base. For example, QEMU
adds a 0x100 offset when nested virtualization is detected and the host
exposes Hyper-V enlightenment hints. To accommodate this behavior,
switch the detection logic to use the CPUID leaf returned by do_cpuid(),
making the implementation more flexible.

See:
https://github.com/qemu/qemu/blob/master/target/i386/kvm/kvm.c#L2300

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D58146

(cherry picked from commit 86691d52a6d3796ad36ba474cf0a9493f6d99202)

Details

Provenance
aokblastAuthored on Jul 10 2026, 9:21 AM
Reviewer
kib
Differential Revision
D58146: kvm: Extend feature detection
Parents
rG4a1a1bf3afc7: stand: Fix shadow buffer offset handling
Branches
Unknown
Tags
Unknown