KVM_{GET,SET}_TSC_OFFSET ioctls
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest5 patches 11 repliesIn review
- v25 patches 0 repliesSuperseded
- v14 patches 5 repliesSuperseded
Changes in v3 from the cover letter
- Mark kvm_write_tsc_offset() as static (whoops)
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | kvm: x86: refactor masterclock sync heuristics out of kvm_write_tscarch/ | +54 | 0 replies | |
| 2/5 | kvm: x86: add KVM_{GET,SET}_TSC_OFFSET ioctlsDocumentation/ arch/ arch/ +1 more | +86 | 0 replies | |
| 3/5 | kvm: vmx: check tsc offsetting with nested_cpu_has()arch/ | +1 | 0 replies | |
| 4/5 | selftests: kvm: use a helper function for reading cpuidtools/ tools/ | +17 | 0 replies | |
| 5/5 | selftests: kvm: introduce tsc_offset_testtools/ tools/ tools/ +5 more | +393 | 0 replies |
Reviews trailers per patch
All 5 patches have a Reviewed-by or Acked-by.
| Patch | Jim Mattson | Peter Shier |
|---|---|---|
| 1/5 | R-b | R-b |
| 2/5 | R-b | R-b |
| 3/5 | R-b | R-b |
| 4/5 | R-b | R-b |
| 5/5 | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/5] KVM_{GET,SET}_TSC_OFFSET ioctls
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
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog