Page MenuHomeFreeBSD

Rework hypervisor detection.
ClosedPublic

Authored by jhb on Oct 26 2014, 8:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 6:43 AM
Unknown Object (File)
Fri, Nov 15, 11:54 AM
Unknown Object (File)
Wed, Nov 6, 11:52 PM
Unknown Object (File)
Wed, Nov 6, 10:49 AM
Unknown Object (File)
Tue, Nov 5, 10:36 PM
Unknown Object (File)
Tue, Nov 5, 9:42 PM
Unknown Object (File)
Fri, Nov 1, 12:35 PM
Unknown Object (File)
Fri, Nov 1, 12:34 PM

Details

Summary

Rework virtual machine hypervisor detection.

  • Move the existing code to x86/x86/identcpu.c since it is x86-specific.
  • If the CPUID2_HV flag is set, assume a hypervisor is present and query the 0x40000000 leaf to determine the hypervisor vendor ID. Export the vendor ID and the highest supported hypervisor CPUID leaf via hv_vendor[] and hv_high variables, respectively. The hv_vendor[] array is also exported via the hw.hv_vendor sysctl.
  • Merge the VMWare detection code from tsc.c into the new probe in identcpu.c. Add a VM_GUEST_VMWARE to identify vmware and use that in the TSC code to identify VMWare.
Test Plan
  • Booted the patch under bhyve and verified the origin string in dmesg as well as setting of kern.vm_guest and hw.hv_vendor sysctls.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

jhb retitled this revision from to Rework hypervisor detection..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)

I will also post this to virtualization@ for review. I believe the Hyper-V folks will like this change. We should perhaps add setting of VM_GUEST_HV to this routine as well instead of in the hyperv drivers.

sys/x86/include/vmware.h
31

Jung-uk, this file is purely your code from a change you added to tsc.c. As such, you should choose the license block that goes on this file. Let me know what to use.

neel edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Oct 26 2014, 9:05 PM
delphij added a reviewer: delphij.
delphij added a subscriber: delphij.

Looks good to me.

jhb edited edge metadata.
  • Whitespace fix.
  • Update license for vmware.h per jkim@.
jkim edited edge metadata.

Looks good.

sys/x86/include/vmware.h
31

Please use the standard FreeBSD license (2-clause) with my copyright, i.e.,

Copyright (c) 2011-2014 Jung-uk Kim <jkim@FreeBSD.org>

jhb edited edge metadata.
  • De-XXX.
  • Merge branch 'master' into vm_guest
jhb updated this revision to Diff 2141.

Closed by commit rS273800 (authored by @jhb).