Re: [PATCH v2] x86/bhyve: Detect FreeBSD Bhyve hypervisor
From: David Woodhouse
Date: Fri Aug 15 2025 - 05:35:01 EST
On Thu, 2025-08-14 at 19:10 +0200, Ahmed S. Darwish wrote:
> On Thu, 14 Aug 2025, David Woodhouse wrote:
> >
> > +static uint32_t __init bhyve_detect(void)
> > +{
> > + if (boot_cpu_data.cpuid_level < 0 ||
> > ...
>
> The CPUID API at <asm/cpuid/api.h> provides a cpuid_feature() macro for
> this. Let's please use that instead.
> I understand that arch/x86/kernel/kvm.c and arch/x86/kernel/jailhouse.c
> does a similar "cpuid_level < 0" check, but they should also be using
> cpuid_feature() instead.
Or just not, in the case of jailhouse and bhyve? Since cpuid_feature()
is hard-coded to true for x86_64 anyway, and they both depend on that
(like acrn, which already only checks for X86_FEATURE_HYPERVISOR).
And anyway, how is X86_FEATURE_HYPERVISOR even going to get set if
there's no CPUID? Can that happen?
Speaking of which, I note detect_hypervisor_vendor does a bunch of
calling into various hypervisor detection routines which are only going
to return immediately because !X86_FEATURE_HYPERVISOR. Should that be
lifted out to a flag like the ignore_nopv flag, so it doesn't need to
bother, and the detection routines don't all need to reimplement the
check differently for themselves?
Attachment:
smime.p7s
Description: S/MIME cryptographic signature