aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaozhong Zhang <haozhong.zhang@intel.com>2015-10-20 03:39:01 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-11-10 06:06:14 -0500
commitbc9b961b357ea8129d75613b7af4fdf57ced9b9f (patch)
tree48a66aa2209463b4c59bb47510400780ca83902c
parent893590c73426585dfd9f33358b19f18d9395fb2f (diff)
KVM: x86: Collect information for setting TSC scaling ratio
The number of bits of the fractional part of the 64-bit TSC scaling ratio in VMX and SVM is different. This patch makes the architecture code to collect the number of fractional bits and other related information into variables that can be accessed in the common code. Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/include/asm/kvm_host.h4
-rw-r--r--arch/x86/kvm/svm.c3
-rw-r--r--arch/x86/kvm/x86.c4
3 files changed, 11 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index b0322d8df03b..5333767560c0 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -988,6 +988,10 @@ u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
988extern bool kvm_has_tsc_control; 988extern bool kvm_has_tsc_control;
989/* maximum supported tsc_khz for guests */ 989/* maximum supported tsc_khz for guests */
990extern u32 kvm_max_guest_tsc_khz; 990extern u32 kvm_max_guest_tsc_khz;
991/* number of bits of the fractional part of the TSC scaling ratio */
992extern u8 kvm_tsc_scaling_ratio_frac_bits;
993/* maximum allowed value of TSC scaling ratio */
994extern u64 kvm_max_tsc_scaling_ratio;
991 995
992enum emulation_result { 996enum emulation_result {
993 EMULATE_DONE, /* no further processing */ 997 EMULATE_DONE, /* no further processing */
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f2c8e4917688..74712ead9787 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -908,6 +908,9 @@ static __init int svm_hardware_setup(void)
908 max = min(0x7fffffffULL, __scale_tsc(tsc_khz, TSC_RATIO_MAX)); 908 max = min(0x7fffffffULL, __scale_tsc(tsc_khz, TSC_RATIO_MAX));
909 909
910 kvm_max_guest_tsc_khz = max; 910 kvm_max_guest_tsc_khz = max;
911
912 kvm_max_tsc_scaling_ratio = TSC_RATIO_MAX;
913 kvm_tsc_scaling_ratio_frac_bits = 32;
911 } 914 }
912 915
913 if (nested) { 916 if (nested) {
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ec85e6f0364f..e728c539ecfb 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -109,6 +109,10 @@ bool __read_mostly kvm_has_tsc_control;
109EXPORT_SYMBOL_GPL(kvm_has_tsc_control); 109EXPORT_SYMBOL_GPL(kvm_has_tsc_control);
110u32 __read_mostly kvm_max_guest_tsc_khz; 110u32 __read_mostly kvm_max_guest_tsc_khz;
111EXPORT_SYMBOL_GPL(kvm_max_guest_tsc_khz); 111EXPORT_SYMBOL_GPL(kvm_max_guest_tsc_khz);
112u8 __read_mostly kvm_tsc_scaling_ratio_frac_bits;
113EXPORT_SYMBOL_GPL(kvm_tsc_scaling_ratio_frac_bits);
114u64 __read_mostly kvm_max_tsc_scaling_ratio;
115EXPORT_SYMBOL_GPL(kvm_max_tsc_scaling_ratio);
112 116
113/* tsc tolerance in parts per million - default to 1/2 of the NTP threshold */ 117/* tsc tolerance in parts per million - default to 1/2 of the NTP threshold */
114static u32 __read_mostly tsc_tolerance_ppm = 250; 118static u32 __read_mostly tsc_tolerance_ppm = 250;