From: Tim Deegan Subject: Re: [PATCH v3 11/11] hvm/hpet: handle 1st period special Date: Fri, 2 May 2014 15:19:44 +0200 Message-ID: <20140502131944.GC64491@deinos.phlegethon.org> References: <1397756585-27091-1-git-send-email-dslutz@verizon.com> <1397756585-27091-12-git-send-email-dslutz@verizon.com> <535A7205020000780000C510@nat28.tlf.novell.com> <20140501103111.GA77240@deinos.phlegethon.org> <5362AC36.70609@terremark.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <5362AC36.70609@terremark.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: Don Slutz Cc: Keir Fraser , Jan Beulich , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org At 16:19 -0400 on 01 May (1398957542), Don Slutz wrote: > On 05/01/14 06:31, Tim Deegan wrote: > > Couldn't it be fixed more simply by detecting comparator values in the > > past in hpet_get_comparator()? > > This statement only works using 64-bit arithmetic for the main counter never > 63 > changing by more then 2 . (Which is a boundary case that should not > happen in my life time.) > > > Without patch #11 (this patch) and without patch #8 (Use signed divide...) > and adding: > > > commit 8c450bed530b13c3f3d18b9dafb3d1b1d69ac1f2 > Author: Don Slutz > Date: Thu May 1 14:02:47 2014 -0400 > > hvm/hpet: Detect comparator values in the past > > Signed-off-by: Don Slutz > > diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c > index 4e4da20..d93dd69 100644 > --- a/xen/arch/x86/hvm/hpet.c > +++ b/xen/arch/x86/hvm/hpet.c > @@ -98,10 +98,12 @@ static uint64_t hpet_get_comparator(HPETState *h, unsigned int tn, > uint64_t period = h->hpet.period[tn]; > if (period) > { > - elapsed = hpet_read_maincounter(h, guest_time) + > - period - comparator; > - comparator += (elapsed / period) * period; > - h->hpet.comparator64[tn] = comparator; > + elapsed = hpet_read_maincounter(h, guest_time) - comparator; > + if ( (int64_t)elapsed >= 0 ) > + { > + comparator += ((elapsed + period) / period) * period; > + h->hpet.comparator64[tn] = comparator; > + } > } > } > > > > Which I think was what you mean. > > It looks to be "ok" (ignoring the boundary case). So should > I send it as v4? Yes, that looks good. You can add Acked-by: Tim Deegan to it too. Cheers, Tim.