return (now);
}
+void
+hv_delay(int usecs)
+{
+ uint64_t interval, start;
+
+ /* 10 MHz fixed frequency */
+ interval = (uint64_t)usecs * 10;
+ start = rdmsr(MSR_HV_TIME_REF_COUNT);
+ while (rdmsr(MSR_HV_TIME_REF_COUNT) - start < interval)
+ CPU_BUSY_CYCLE();
+}
+
int
hv_init_hypercall(struct hv_softc *sc)
{
-/* $OpenBSD: pvbus.c,v 1.22 2020/08/26 03:29:06 visa Exp $ */
+/* $OpenBSD: pvbus.c,v 1.23 2021/08/31 15:52:10 patrick Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
#include <dev/pv/pvvar.h>
#include <dev/pv/pvreg.h>
+#include <dev/pv/hypervreg.h>
+
+#include "hyperv.h"
int has_hv_cpuid = 0;
hv->hv_features = regs[0];
}
+extern void hv_delay(int usecs);
+
void
pvbus_hyperv(struct pvbus_hv *hv)
{
HYPERV_VERSION_EBX_MAJOR_S;
hv->hv_minor = (regs[1] & HYPERV_VERSION_EBX_MINOR_M) >>
HYPERV_VERSION_EBX_MINOR_S;
+
+#if NHYPERV > 0
+ if (hv->hv_features & CPUID_HV_MSR_TIME_REFCNT &&
+ delay_func == i8254_delay)
+ delay_func = hv_delay;
+#endif
}
void