From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751508AbbI2EBY (ORCPT ); Tue, 29 Sep 2015 00:01:24 -0400 Received: from mga01.intel.com ([192.55.52.88]:39877 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbbI2EBW (ORCPT ); Tue, 29 Sep 2015 00:01:22 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,606,1437462000"; d="scan'208";a="815153685" Date: Tue, 29 Sep 2015 12:01:17 +0800 From: Haozhong Zhang To: Eric Northup Cc: KVM , Gleb Natapov , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , the arch/x86 maintainers , Joerg Roedel , Wanpeng Li , Xiao Guangrong , Mihai =?utf-8?B?RG9uyJt1?= , Andy Lutomirski , Kai Huang , Linux Kernel Mailing List Subject: Re: [PATCH 01/12] KVM: x86: Collect information for setting TSC scaling ratio Message-ID: <20150929040117.GK3583@hzzhang-OptiPlex-9020.sh.intel.com> Mail-Followup-To: Eric Northup , KVM , Gleb Natapov , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , the arch/x86 maintainers , Joerg Roedel , Wanpeng Li , Xiao Guangrong , Mihai =?utf-8?B?RG9uyJt1?= , Andy Lutomirski , Kai Huang , Linux Kernel Mailing List References: <1443418691-24050-1-git-send-email-haozhong.zhang@intel.com> <1443418691-24050-2-git-send-email-haozhong.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2015 at 08:28:57PM -0700, Eric Northup wrote: > On Sun, Sep 27, 2015 at 10:38 PM, Haozhong Zhang > wrote: > > > > 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 > > --- > > arch/x86/include/asm/kvm_host.h | 8 ++++++++ > > arch/x86/kvm/svm.c | 5 +++++ > > arch/x86/kvm/x86.c | 8 ++++++++ > > 3 files changed, 21 insertions(+) > > > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > > index 2beee03..5b9b86e 100644 > > --- a/arch/x86/include/asm/kvm_host.h > > +++ b/arch/x86/include/asm/kvm_host.h > > @@ -965,6 +965,14 @@ extern bool kvm_has_tsc_control; > > extern u32 kvm_min_guest_tsc_khz; > > /* maximum supported tsc_khz for guests */ > > extern u32 kvm_max_guest_tsc_khz; > > +/* number of bits of the fractional part of the TSC scaling ratio */ > > +extern u8 kvm_tsc_scaling_ratio_frac_bits; > > +/* reserved bits of TSC scaling ratio (SBZ) */ > > +extern u64 kvm_tsc_scaling_ratio_rsvd; > > +/* default TSC scaling ratio (= 1.0) */ > > +extern u64 kvm_default_tsc_scaling_ratio; > > +/* maximum allowed value of TSC scaling ratio */ > > +extern u64 kvm_max_tsc_scaling_ratio; > > Do we need all 3 of kvm_max_guest_tsc_khz, kvm_max_tsc_scaling_ratio, > and kvm_tsc_scaling_ratio_rsvd (since only SVM has reserved bits - and > just for complaining if the high bits are set, which can already be > expressed by max_tsc_scaling ratio) > > kvm_max_tsc_scaling_ratio seems to be write-only. > You are right. I'll remove kvm_tsc_scaling_ratio_rsvd and just use kvm_max_tsc_scaling_ratio to verify TSC scaling ratio in set_tsc_khz(). > > > > enum emulation_result { > > EMULATE_DONE, /* no further processing */ > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > > index 94b7d15..eff7db7 100644 > > --- a/arch/x86/kvm/svm.c > > +++ b/arch/x86/kvm/svm.c > > @@ -963,7 +963,12 @@ static __init int svm_hardware_setup(void) > > max = min(0x7fffffffULL, __scale_tsc(tsc_khz, TSC_RATIO_MAX)); > > > > kvm_max_guest_tsc_khz = max; > > + > > + kvm_max_tsc_scaling_ratio = TSC_RATIO_MAX; > > + kvm_tsc_scaling_ratio_frac_bits = 32; > > + kvm_tsc_scaling_ratio_rsvd = TSC_RATIO_RSVD; > > } > > + kvm_default_tsc_scaling_ratio = TSC_RATIO_DEFAULT; > > > > if (nested) { > > printk(KERN_INFO "kvm: Nested Virtualization enabled\n"); > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 991466b..f888225 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -106,6 +106,14 @@ bool kvm_has_tsc_control; > > EXPORT_SYMBOL_GPL(kvm_has_tsc_control); > > u32 kvm_max_guest_tsc_khz; > > EXPORT_SYMBOL_GPL(kvm_max_guest_tsc_khz); > > +u8 kvm_tsc_scaling_ratio_frac_bits; > > +EXPORT_SYMBOL_GPL(kvm_tsc_scaling_ratio_frac_bits); > > +u64 kvm_tsc_scaling_ratio_rsvd; > > +EXPORT_SYMBOL_GPL(kvm_tsc_scaling_ratio_rsvd); > > +u64 kvm_default_tsc_scaling_ratio; > > +EXPORT_SYMBOL_GPL(kvm_default_tsc_scaling_ratio); > > +u64 kvm_max_tsc_scaling_ratio; > > +EXPORT_SYMBOL_GPL(kvm_max_tsc_scaling_ratio); > > > > /* tsc tolerance in parts per million - default to 1/2 of the NTP threshold */ > > static u32 tsc_tolerance_ppm = 250; > > -- > > 2.4.8 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe kvm" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html