Index: sys/amd64/conf/GENERIC =================================================================== --- sys/amd64/conf/GENERIC +++ sys/amd64/conf/GENERIC @@ -349,9 +349,6 @@ device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device -# HyperV drivers and enchancement support -device hyperv # HyperV drivers - # Xen HVM Guest Optimizations # NOTE: XENHVM depends on xenpci. They must be added or removed together. options XENHVM # Xen HVM kernel infrastructure Index: sys/boot/i386/libi386/i386_module.c =================================================================== --- sys/boot/i386/libi386/i386_module.c +++ sys/boot/i386/libi386/i386_module.c @@ -31,6 +31,37 @@ * i386-specific module functionality. * */ +#include +#include +#include +#include + +#define HV_UNKNOWN 0 +#define HV_XEN 1 +#define HV_HYPERV 2 + +/* See the kernel's function identify_hypervisor(). */ +static int +get_hypervisor(void) +{ + unsigned int regs[4]; + char hv_vendor[13]; + + do_cpuid(1, regs); + if (regs[2] & 0x80000000) { + do_cpuid(0x40000000, regs); + if (regs[0] >= 0x40000000) { + ((u_int *)&hv_vendor)[0] = regs[1]; + ((u_int *)&hv_vendor)[1] = regs[2]; + ((u_int *)&hv_vendor)[2] = regs[3]; + hv_vendor[12] = '\0'; + if (strcmp(hv_vendor, "Microsoft Hv") == 0) + return (HV_HYPERV); + } + } + + return (HV_UNKNOWN); +} /* * Use voodoo to load modules required by current hardware. @@ -38,7 +69,14 @@ int i386_autoload(void) { + switch(get_hypervisor()) { + case HV_HYPERV: + mod_loadkld("hyperv.ko", 0, NULL); + break; + default: + break; + } - /* XXX use PnP to locate stuff here */ - return(0); + /* XXX use PnP to locate stuff here */ + return(0); } Index: sys/i386/conf/GENERIC =================================================================== --- sys/i386/conf/GENERIC +++ sys/i386/conf/GENERIC @@ -366,9 +366,6 @@ device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device -# HyperV drivers and enchancement support -device hyperv # HyperV drivers - # Xen HVM Guest Optimizations # NOTE: XENHVM depends on xenpci. They must be added or removed together. options XENHVM # Xen HVM kernel infrastructure