All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] KVM_{GET,SET}_TSC_OFFSET ioctls
@ 2020-07-22  3:26 Oliver Upton
  2020-07-22  3:26 ` [PATCH v3 1/5] kvm: x86: refactor masterclock sync heuristics out of kvm_write_tsc Oliver Upton
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Oliver Upton @ 2020-07-22  3:26 UTC (permalink / raw)
  To: kvm
  Cc: Paolo Bonzini, Peter Shier, Sean Christopherson, Peter Hornyack,
	Oliver Upton

To date, VMMs have typically restored the guest's TSCs by value using
the KVM_SET_MSRS ioctl for each vCPU. However, restoring the TSCs by
value introduces some challenges with synchronization as the TSCs
continue to tick throughout the restoration process. As such, KVM has
some heuristics around TSC writes to infer whether or not the guest or
host is attempting to synchronize the TSCs.

Instead of guessing at the intentions of a VMM, it'd be better to
provide an interface that allows for explicit synchronization of the
guest's TSCs. To that end, this series introduces the
KVM_{GET,SET}_TSC_OFFSET ioctls, yielding control of the TSC offset to
userspace.

v2 => v3:
 - Mark kvm_write_tsc_offset() as static (whoops)

v1 => v2:
 - Added clarification to the documentation of KVM_SET_TSC_OFFSET to
   indicate that it can be used instead of an IA32_TSC MSR restore
   through KVM_SET_MSRS
 - Fixed KVM_SET_TSC_OFFSET to participate in the existing TSC
   synchronization heuristics, thereby enabling the KVM masterclock when
   all vCPUs are in phase.

Oliver Upton (4):
  kvm: x86: refactor masterclock sync heuristics out of kvm_write_tsc
  kvm: vmx: check tsc offsetting with nested_cpu_has()
  selftests: kvm: use a helper function for reading cpuid
  selftests: kvm: introduce tsc_offset_test

Peter Hornyack (1):
  kvm: x86: add KVM_{GET,SET}_TSC_OFFSET ioctls

 Documentation/virt/kvm/api.rst                |  31 ++
 arch/x86/include/asm/kvm_host.h               |   1 +
 arch/x86/kvm/vmx/vmx.c                        |   2 +-
 arch/x86/kvm/x86.c                            | 147 ++++---
 include/uapi/linux/kvm.h                      |   5 +
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/include/test_util.h |   3 +
 .../selftests/kvm/include/x86_64/processor.h  |  15 +
 .../selftests/kvm/include/x86_64/svm_util.h   |  10 +-
 .../selftests/kvm/include/x86_64/vmx.h        |   9 +
 tools/testing/selftests/kvm/lib/kvm_util.c    |   1 +
 tools/testing/selftests/kvm/lib/x86_64/vmx.c  |  11 +
 .../selftests/kvm/x86_64/tsc_offset_test.c    | 362 ++++++++++++++++++
 14 files changed, 550 insertions(+), 49 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/tsc_offset_test.c

-- 
2.28.0.rc0.142.g3c755180ce-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-09-24 15:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22  3:26 [PATCH v3 0/5] KVM_{GET,SET}_TSC_OFFSET ioctls Oliver Upton
2020-07-22  3:26 ` [PATCH v3 1/5] kvm: x86: refactor masterclock sync heuristics out of kvm_write_tsc Oliver Upton
2020-07-22  3:26 ` [PATCH v3 2/5] kvm: x86: add KVM_{GET,SET}_TSC_OFFSET ioctls Oliver Upton
2020-07-22  3:26 ` [PATCH v3 3/5] kvm: vmx: check tsc offsetting with nested_cpu_has() Oliver Upton
2020-07-22  3:26 ` [PATCH v3 4/5] selftests: kvm: use a helper function for reading cpuid Oliver Upton
2020-07-22  3:26 ` [PATCH v3 5/5] selftests: kvm: introduce tsc_offset_test Oliver Upton
2020-07-28 16:33 ` [PATCH v3 0/5] KVM_{GET,SET}_TSC_OFFSET ioctls Oliver Upton
2020-08-05 16:06   ` Oliver Upton
2020-08-05 18:46     ` Paolo Bonzini
2020-08-05 21:33       ` Oliver Upton
2020-08-05 22:01         ` Jim Mattson
2020-08-12 13:41           ` Paolo Bonzini
2020-08-14 16:55             ` Oliver Upton
2020-08-17 16:49               ` Paolo Bonzini
2020-08-17 19:40                 ` Oliver Upton
2020-09-24 13:43                   ` Paolo Bonzini
2020-09-24 15:14                     ` Maxim Levitsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.