diff options
author | pd <pd@cvs.openbsd.org> | 2019-05-13 15:40:35 +0000 |
---|---|---|
committer | pd <pd@cvs.openbsd.org> | 2019-05-13 15:40:35 +0000 |
commit | 760ccb62a573ddfbd9b3f6c50cf10866ab83c7f4 (patch) | |
tree | 4e293c550fdb986272cc13da2a2e588dc4e451ce /sys/dev/pv | |
parent | e3bd4763aecb73b31263f47ec75697ec3c1496fd (diff) |
vmm: add host side pvclock
Emulate kvm pvclock in vmm(4). Compatible with pvclock(4) in OpenBSD. Linux
does not attach to this (yet).
Fixes by reyk@ and tested extensively by reyk@, tb@ and phessler@
ok mlarkin@ phessler@ reyk@
Diffstat (limited to 'sys/dev/pv')
-rw-r--r-- | sys/dev/pv/pvbus.c | 4 | ||||
-rw-r--r-- | sys/dev/pv/pvclock.c | 23 | ||||
-rw-r--r-- | sys/dev/pv/pvreg.h | 22 |
3 files changed, 26 insertions, 23 deletions
diff --git a/sys/dev/pv/pvbus.c b/sys/dev/pv/pvbus.c index 885cf702c20..6c7b0be643f 100644 --- a/sys/dev/pv/pvbus.c +++ b/sys/dev/pv/pvbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pvbus.c,v 1.18 2018/01/18 11:43:20 mikeb Exp $ */ +/* $OpenBSD: pvbus.c,v 1.19 2019/05/13 15:40:34 pd Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -90,7 +90,7 @@ struct pvbus_type { { "VMwareVMware", "VMware" }, { "XenVMMXenVMM", "Xen", pvbus_xen, pvbus_xen_print }, { "bhyve bhyve ", "bhyve" }, - { VMM_HV_SIGNATURE, "OpenBSD" }, + { VMM_HV_SIGNATURE, "OpenBSD", pvbus_kvm }, }; struct bus_dma_tag pvbus_dma_tag = { diff --git a/sys/dev/pv/pvclock.c b/sys/dev/pv/pvclock.c index 05eebf783c2..1325f89887b 100644 --- a/sys/dev/pv/pvclock.c +++ b/sys/dev/pv/pvclock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pvclock.c,v 1.3 2018/12/05 18:02:51 reyk Exp $ */ +/* $OpenBSD: pvclock.c,v 1.4 2019/05/13 15:40:34 pd Exp $ */ /* * Copyright (c) 2018 Reyk Floeter <reyk@openbsd.org> @@ -41,25 +41,6 @@ struct pvclock_softc { struct timecounter *sc_tc; }; -struct pvclock_wall_clock { - uint32_t wc_version; - uint32_t wc_sec; - uint32_t wc_nsec; -} __packed; - -struct pvclock_time_info { - uint32_t ti_version; - uint32_t ti_pad0; - uint64_t ti_tsc_timestamp; - uint64_t ti_system_time; - uint32_t ti_tsc_to_system_mul; - int8_t ti_tsc_shift; - uint8_t ti_flags; - uint8_t ti_pad[2]; -} __packed; - -#define PVCLOCK_FLAG_TSC_STABLE 0x01 -#define PVCLOCK_SYSTEM_TIME_ENABLE 0x01 #define DEVNAME(_s) ((_s)->sc_dev.dv_xname) int pvclock_match(struct device *, void *, void *); @@ -104,6 +85,8 @@ pvclock_match(struct device *parent, void *match, void *aux) * only support the "kvmclock". */ hv = &pva->pva_hv[PVBUS_KVM]; + if (hv->hv_base == 0) + hv = &pva->pva_hv[PVBUS_OPENBSD]; if (hv->hv_base != 0) { /* * We only implement support for the 2nd version of pvclock. diff --git a/sys/dev/pv/pvreg.h b/sys/dev/pv/pvreg.h index df83489d0cf..c5c60ce0e8f 100644 --- a/sys/dev/pv/pvreg.h +++ b/sys/dev/pv/pvreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pvreg.h,v 1.5 2018/11/23 12:37:40 reyk Exp $ */ +/* $OpenBSD: pvreg.h,v 1.6 2019/05/13 15:40:34 pd Exp $ */ /* * Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org> @@ -46,6 +46,26 @@ #define KVM_MSR_WALL_CLOCK 0x4b564d00 #define KVM_MSR_SYSTEM_TIME 0x4b564d01 +struct pvclock_wall_clock { + uint32_t wc_version; + uint32_t wc_sec; + uint32_t wc_nsec; +} __packed; + +struct pvclock_time_info { + uint32_t ti_version; + uint32_t ti_pad0; + uint64_t ti_tsc_timestamp; + uint64_t ti_system_time; + uint32_t ti_tsc_to_system_mul; + int8_t ti_tsc_shift; + uint8_t ti_flags; + uint8_t ti_pad[2]; +} __packed; + +#define PVCLOCK_FLAG_TSC_STABLE 0x01 +#define PVCLOCK_SYSTEM_TIME_ENABLE 0x01 + /* * Hyper-V */ |