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

Re: [Xen-devel] [PATCH v5 2/6] x86/hvm: Setup TSC scaling ratio



On 02/24/16 08:51, Jan Beulich wrote:
> >>> On 24.02.16 at 16:42, <haozhong.zhang@xxxxxxxxx> wrote:
> > On 02/24/16 08:01, Jan Beulich wrote:
> >> >>> On 23.02.16 at 03:05, <haozhong.zhang@xxxxxxxxx> 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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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