Skip to content

Add API for accurate KVM/PV clock migration

Jack Allister kvm linux-doc linux-kselftest lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 7 repliesIn review
  2. v12 patches 19 repliesSuperseded

Changes in v2 from the cover letter

- Moved new IOCTLs from vm to vcpu level.
- Adds extra error checks as suggested by Dongli Zhang / David Woodhouse.
- Adds on-demand calculation of PVTI if non currently present in vcpu.
- Adds proper synchronization for PV clock during correction.
- Added option to test without TSC scaling in sefltest.
- Updated commit messages to better explain the situation (thanks David).

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: x86: Add KVM_[GS]ET_CLOCK_GUEST for accurate KVM clock migrationDocumentation/virt/kvm/api.rst arch/x86/kvm/x86.c include/uapi/linux/kvm.h+164 -05 replies
2/2KVM: selftests: Add KVM/PV clock selftest to prove timer correctiontools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/x86_64/pvclock_test.c+193 -02 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchPaul Durrant
1/2
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] Add API for accurate KVM/PV clock migration

Guest VMs can be provided with a para-virtualized clock source to perform timekeeping. A KVM guest can map in a PV clock via the MSR_KVM_SYSTEM_TIME/MSR_KVM_SYSTEM_TIME_NEW virtualized MSRs. Where as on a Xen guest this can be provided via the vcpu/shared info pages.

These PV clocks both use a common structure which is mapped between host <-> guest to provide the PVTI (paravirtual time information) for the clock. This reference information is a guest TSC timestamp and a host system time at a singular point in time.

Upon a live-update of a host or live-migration of an instance the PVTI may be recalculated by KVM. Using the existing KVM_[GS]ET_CLOCK functionality the relationship between the TSC and PV clock cannot be precisely saved and restored by userspace.

This series adds in two patches, one to add in a new interface to allow a VMM/userspace to perform a correction of the PVTI structure. Then a second to verify the imprecision after a simulation of a live-update/migration and then to verify the correction is to within ±1ns.

v1: https://lore.kernel.org/all/[email protected]/

v2:
- Moved new IOCTLs from vm to vcpu level.
- Adds extra error checks as suggested by Dongli Zhang / David Woodhouse.
- Adds on-demand calculation of PVTI if non currently present in vcpu.
- Adds proper synchronization for PV clock during correction.
- Added option to test without TSC scaling in sefltest.
- Updated commit messages to better explain the situation (thanks David).

Jack Allister (2):
KVM: x86: Add KVM_[GS]ET_CLOCK_GUEST for accurate KVM clock migration
KVM: selftests: Add KVM/PV clock selftest to prove timer correction

 Documentation/virt/kvm/api.rst                |  37 ++++
 arch/x86/kvm/x86.c                            | 124 +++++++++++
 include/uapi/linux/kvm.h                      |   3 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/x86_64/pvclock_test.c       | 192 ++++++++++++++++++
 5 files changed, 357 insertions(+)
 create mode 100644 tools/testing/selftests/kvm/x86_64/pvclock_test.c

base-commit: 8cb4a9a82b21623dbb4b3051dd30d98356cf95bc

Signature · 1 line
2.40.1