summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2016-11-22 13:51:22 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2016-11-22 13:51:22 +0000
commitb77118e3ea2f0d44269205407314ae1ecd1e66a3 (patch)
tree3872f6b88cec2fa1ad265a7822a4ba8b02cf7381
parenta936abe8eb1ed634d49f59e28f45d864ef538ea5 (diff)
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@.
-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;