[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 00/14] Add VMX TSC scaling support

This patchset adds support for VMX TSC scaling feature which is
available on Intel Skylake Server CPU. The specification of VMX TSC
scaling can be found at

VMX TSC scaling allows guest TSC which is read by guest rdtsc(p)
instructions increases in a rate that is customized by the hypervisor
and can be different than the host TSC frequency. Basically, VMX TSC
scaling adds a 64-bit field called TSC multiplier in VMCS so that, if
VMX TSC scaling is enabled, TSC read by guest rdtsc(p) instructions
will be calculated by the following formula:

  guest EDX:EAX = (Host TSC * TSC multiplier) >> 48 + VMX TSC Offset

where, Host TSC = Host MSR_IA32_TSC + Host MSR_IA32_TSC_ADJUST.

If the destination host supports VMX TSC scaling, this patchset allows
guest programs in a HVM container in the default TSC mode or PVRDTSCP
(native_paravirt) TSC mode to observe the same TSC frequency across
the migration.

This patchset is composed of following four parts.
 1. Patch 1 - 6 fix bugs in the current TSC scaling implementation
    on SVM TSC ratio.
 2. Patch 7 - 12 abstract the possible common code between VMX TSC
    scaling and SVM TSC ratio.
 3. Patch 13 adds the arch-specific code to support VMX TSC scaling.
 4. Patch 14 updates corresponding documents.

Compared to v1, some patches in v2 are reordered or merged and some
new patches are added in v2 as well. Relations of patches between v1
and v2 are listed below.
  v2                 Relation to v1
  Patch 1-3          New
  Patch 4            Update of Patch 2
  Patch 5            Reorder of Patch 6
  Patch 6            Patch 9
  Patch 7            New
  Patch 8-10         Update of Patch 3-5
  Patch 11-12        Patch 7-8
  Patch 13           Merge of Patch 10-12
  Patch 14           New

Changes in v2:
 * Remove unnecessary v1 patch 1&13.
 * Add and move all bug-fix patches to the beginning of this series.
   (Patch 1 - 6)
 * Update changes in tsc_set_info() and tsc_get_info() to make both
   functions consistent with each other. (Patch 2 - 4)
 * Move a part of scaling logic out of [vmx|svm]_set_tsc_offset().
   (Patch 7)
 * Remove redundant hvm_funcs.tsc_scaling_ratio_rsvd. (Patch 8)
 * Reimplement functions that calculate TSC ratio and scale TSC.
   (Patch 9&10)
 * Merge setting VMX TSC multiplier into patch 13.
 * Move initialing tsc_scaling_ratio in VMX ahead to
   vmx_vcpu_initialise() so as to make construct_vmcs() naturally
   use this field instead of a constant. (Patch 13)
 * Update documents related to tsc_mode.
 * Other code cleanup and style fixes.

Haozhong Zhang (14):
  svm: Fix incorrect TSC scaling
  x86/time.c: Fix domain type check in tsc_set_info()
  x86/time.c: Use correct guest TSC frequency in tsc_set_info()
  x86/time.c: Use correct guest TSC frequency in tsc_get_info()
  x86/hvm: Scale host TSC when setting/getting guest TSC
  x86/time.c: Scale host TSC in pvclock properly
  svm: Remove redundant TSC scaling in svm_set_tsc_offset()
  x86/hvm: Collect information of TSC scaling ratio
  x86/hvm: Setup TSC scaling ratio
  x86/hvm: Replace architecture TSC scaling by a common function
  x86/hvm: Move saving/loading vcpu's TSC to common code
  x86/hvm: Detect TSC scaling through hvm_funcs
  vmx: Add VMX RDTSC(P) scaling support
  docs: Add descriptions of TSC scaling in xl.cfg and tscmode.txt

 docs/man/xl.cfg.pod.5              |  15 +++++-
 docs/misc/tscmode.txt              |  14 ++++++
 xen/arch/x86/hvm/hvm.c             |  65 ++++++++++++++++++++----
 xen/arch/x86/hvm/svm/svm.c         |  72 +++++++++++++++-----------
 xen/arch/x86/hvm/vmx/vmcs.c        |  12 +++--
 xen/arch/x86/hvm/vmx/vmx.c         |  20 ++++++--
 xen/arch/x86/time.c                |  57 ++++++++++++++++-----
 xen/include/asm-x86/hvm/hvm.h      |  18 +++++++
 xen/include/asm-x86/hvm/svm/svm.h  |   3 --
 xen/include/asm-x86/hvm/vcpu.h     |   2 +
 xen/include/asm-x86/hvm/vmx/vmcs.h |   7 +++
 xen/include/asm-x86/math64.h       | 100 +++++++++++++++++++++++++++++++++++++
 12 files changed, 322 insertions(+), 63 deletions(-)
 create mode 100644 xen/include/asm-x86/math64.h


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.