--- /usr/src/sys.old/kern/subr_param.c 2007-12-16 01:37:33.000000000 -0600 +++ kern/subr_param.c 2007-12-28 02:51:28.000000000 -0600 @@ -108,8 +108,29 @@ void init_param1(void) { + char *envptr; hz = HZ; + /* Neither QEMU or VMWare can keep up with guests running at + * 1000 hz. This leads to highly inaccurate timekeeping by + * the guest. To work around this, force 100 hz when we + * detect that we are a guest of one of these two. + */ + envptr = getenv("hint.acpi.0.oem"); + if (envptr) { + if (memcmp(envptr, "QEMU", 4) == 0) + hz = 100; + freeenv(envptr); + envptr = NULL; + } + envptr = getenv("smbios.system.maker"); + if (envptr) { + if (memcmp(envptr, "VMware, Inc.", 12) == 0) + hz = 100; + freeenv(envptr); + envptr = NULL; + } + TUNABLE_INT_FETCH("kern.hz", &hz); tick = 1000000 / hz;