Proposal for better support of hypervisors and their synthetic drivers at boot-time

John Baldwin jhb at freebsd.org
Mon Apr 29 19:25:01 UTC 2013


I know Alexander replied about the ATA bits already, but I wanted to reply to 
two of your other points below:

On Tuesday, April 23, 2013 10:07:03 am Larry Melia wrote:
> (1) Move the call to init_param1() (in sys/kern/subr_parm.c), which is used
> for hypervisor detection, to an earlier point in the boot process.
> Presently, it appears to be called after the ATA driver is selected, which
> is too late in the boot process. (This was discovered after some testing
> with the ATA driver.) Therefore, before the bus drivers and native
> controllers are detected and selected, discovery of a host hypervisor
> should be done first.
> 
> (3) Upgrade the init_param1() function (in sys/kern/subr_parm.c) to use the
> more recent approach to hypervisor detection. This approach uses the
> CPU-identify functions to retrieve a unique signature consisting of a fixed
> string of ASCII characters. This was done on Linux about five years. For
> backward compatibility, however, the existing logic would be retained, but
> augmented with this new approach. It would also be conditionally added only
> for x86/AMD64 builds.

I definitely agree with these proposals.  In addition, our current hypervisor 
detection code is completely x86-specific and does not belong in MI code.  The 
only bits that should be MI are the vm_guest variable and the VM_GUEST 
constants.  I would argue that most of the VM_GUEST constants (for specific 
VMs which we do not have currently) should be MD as well.

Each platform that supports hypervisors would install its own SYSINIT to set 
vm_guest instead of doing it directly from init_param1().

Making the VM_GUEST_FOO constants be MD macros means you can use #ifdef to 
test for them.  Thus:

#ifdef VM_GUEST_HYPERV
/* Include a hyper-V specific driver. */
#endif

The current enum approach doesn't allow for that.

-- 
John Baldwin


More information about the freebsd-virtualization mailing list