History log of /openbsd-current/sys/dev/pv/pvclock.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.11 24-May-2024 jsg

remove unneeded includes


# 1.10 14-May-2024 jsg

remove prototypes with no matching function


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.9 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.8 05-Nov-2021 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.7 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.6 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.10 14-May-2024 jsg

remove prototypes with no matching function


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.9 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.8 05-Nov-2021 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.7 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.6 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.9 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.8 05-Nov-2021 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.7 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.6 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.8 05-Nov-2021 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.7 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.6 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.7 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.6 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.6 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


Revision tags: OPENBSD_6_7_BASE
# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.5 13-Dec-2019 pd

pvclock(4): attach even if when PVCLOCK_FLAG_TSC_STABLE is unset

Attaches pvclock with lower priority (500) in case of unstable tsc
(PVCLOCK_FLAG_TSC_STABLE) instead of not attaching at all. In this state, we do
make sure to return a monotonically increasing number.

This mostly helps openbsd guests on openbsd vmm(4) where a pvclock with unstable
tsc is still better than i8254.

ok mlarkin@


Revision tags: OPENBSD_6_6_BASE
# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.4 13-May-2019 pd

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@


Revision tags: OPENBSD_6_5_BASE
# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.3 05-Dec-2018 reyk

Correctly disable pvclock(4) on old hardware that lack a stable clock

I falsely assumed that the KVM_FEATURE_CLOCKSOURCE_STABLE_BIT
indicates that the actual clock values are stable, but it turned out
that this isn't always the case. To detect if the clock value is
stable, we now read it once in pvclock_attach() and check for the
PVCLOCK_FLAG_TSC_STABLE flag. This needs further investigation.

Reported and fix tested by johnw.mail at gmail.com

OK chris@ phessler@


# 1.2 24-Nov-2018 phessler

only attach pvclock(4) inside a KVM guest

tested by brynet@
OK reyk@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@


# 1.1 23-Nov-2018 reyk

Add the pvclock(4) guest driver for paravirtual clocks

This improves timekeeping on KVM guests as it runs much better than
the virtualized acpihpet or acpitimer timecounters and the invtsc is
not always available.

Many thanks to Janne Johansson, landry@, and benno@ for testing amd64/i386.

OK mlarkin@ phessler@