From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haozhong Zhang Subject: Re: [PATCH v5 2/6] x86/hvm: Setup TSC scaling ratio Date: Thu, 25 Feb 2016 00:05:34 +0800 Message-ID: <20160224160534.GC10229@hz-desktop.sh.intel.com> References: <1456193104-12761-1-git-send-email-haozhong.zhang@intel.com> <1456193104-12761-3-git-send-email-haozhong.zhang@intel.com> <56CDD3DB02000078000D5BED@prv-mh.provo.novell.com> <20160224154247.GB14964@hz-desktop.sh.intel.com> <56CDDF8502000078000D5CDF@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <56CDDF8502000078000D5CDF@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Kevin Tian , Keir Fraser , Suravee Suthikulpanit , Andrew Cooper , xen-devel@lists.xen.org, Aravind Gopalakrishnan , Jun Nakajima , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org On 02/24/16 08:51, Jan Beulich wrote: > >>> On 24.02.16 at 16:42, wrote: > > On 02/24/16 08:01, Jan Beulich wrote: > >> >>> On 23.02.16 at 03:05, wrote: > >> > + /* ratio = (gtsc_khz << hvm_funcs.tsc_scaling.ratio_frac_bits) / cpu_khz */ > >> > + asm ( > >> > + "shldq %2,%1,%0; salq %2,%1; divq %3" > >> > + : "+&d" (dummy), "+&a" (ratio) > >> > + : "c" (hvm_funcs.tsc_scaling.ratio_frac_bits), > >> > + "rm" ((u64) cpu_khz) ); > >> > >> And this DIVQ can't possibly #DE, e.g. when gtsc_khz is much larger > >> than cpu_khz? > >> > > > > Oops, it could. Following check should be added before asm(): > > /* the quotient is too large to fit in the integral part of TSC > > scaling ratio */ > > if ( gtsc_khz / cpu_khz > > > (hvm_funcs.tsc_scaling.max_ratio >> > > hvm_funcs.tsc_scaling.ratio_frac_bits ) > > return 0; > > Well, wouldn't that need to be >= then, since the division truncates? > No. The division truncation on (gtsc_khz/cpu_khz) gets the integral part that is the part I want to check whether can fit in the integral part of TSC scaling ratio. Haozhong