From: "Jan Beulich" Subject: Re: [PATCH v5 2/6] x86/hvm: Setup TSC scaling ratio Date: Wed, 24 Feb 2016 08:51:17 -0700 Message-ID: <56CDDF8502000078000D5CDF@prv-mh.provo.novell.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> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20160224154247.GB14964@hz-desktop.sh.intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Haozhong Zhang 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 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? Jan