summaryrefslogtreecommitdiffstats
path: root/sys/dev/pv/hyperv.c
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2016-11-22 13:51:21 +0000
committermikeb <mikeb@openbsd.org>2016-11-22 13:51:21 +0000
commit7dd9c50fc5aa02c4350eac8d1fda5cb82d8810c6 (patch)
treea494680f5b5ef11ba647703dce80cc94bce0cc4d /sys/dev/pv/hyperv.c
parentReturn different error number to know which test is failing. (diff)
downloadwireguard-openbsd-7dd9c50fc5aa02c4350eac8d1fda5cb82d8810c6.tar.xz
wireguard-openbsd-7dd9c50fc5aa02c4350eac8d1fda5cb82d8810c6.zip
Use CPUID flags to determine working components
This adds a few checks to make sure we're not trying to use features that are not advertised with CPUID feature flags and avoid attaching when Xen viridium emulation is turned on. Prompted by a report from Kirill Miazine <km at krot ! org>, thanks! Discussed with reyk@.
Diffstat (limited to 'sys/dev/pv/hyperv.c')
-rw-r--r--sys/dev/pv/hyperv.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/dev/pv/hyperv.c b/sys/dev/pv/hyperv.c
index e3b6db5ed0e..1318d0011e3 100644
--- a/sys/dev/pv/hyperv.c
+++ b/sys/dev/pv/hyperv.c
@@ -263,7 +263,7 @@ hv_match(struct device *parent, void *match, void *aux)
struct pv_attach_args *pva = aux;
struct pvbus_hv *hv = &pva->pva_hv[PVBUS_HYPERV];
- if (hv->hv_base == 0)
+ if ((hv->hv_major == 0 && hv->hv_minor == 0) || hv->hv_base == 0)
return (0);
return (1);
@@ -279,11 +279,18 @@ hv_attach(struct device *parent, struct device *self, void *aux)
sc->sc_pvbus = hv;
sc->sc_dmat = pva->pva_dmat;
+ if (!(hv->hv_features & CPUID_HV_MSR_HYPERCALL) ||
+ !(hv->hv_features & CPUID_HV_MSR_SYNIC)) {
+ printf(": not functional\n");
+ return;
+ }
+
printf("\n");
hv_set_version(sc);
- tc_init(&hv_timecounter);
+ if (hv->hv_features & CPUID_HV_MSR_TIME_REFCNT)
+ tc_init(&hv_timecounter);
if (hv_init_hypercall(sc))
return;