From: "Jan Beulich" Subject: Re: [PATCH v4 06/10] hvm/hpet: In hpet_save, call hpet_get_comparator. Date: Mon, 05 May 2014 08:54:59 +0100 Message-ID: <53675FF3020000780000EDB6@mail.emea.novell.com> References: <1399061888-25756-1-git-send-email-dslutz@verizon.com> <1399061888-25756-7-git-send-email-dslutz@verizon.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1399061888-25756-7-git-send-email-dslutz@verizon.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: Don Slutz Cc: Tim Deegan , Keir Fraser , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 02.05.14 at 22:18, wrote: > This changes save data to consistent/expected values. It is not > technically required because hpet_get_comparator() will adjust from > any value to the correct value. And hpet_get_comparator() is > effectivly called in hpet_load via hpet_set_timer. > > However it does look strange to people that the output from > xen-hvmctx for the comparator values do not change when the master > clock does. > > The software-developers-hpet-spec-1-0a.pdf says that the comparator > will allways be greater than master clock for a periodic timer. > > Signed-off-by: Don Slutz Acked-by: Jan Beulich > --- > v4: > Correctly set guest_time. > Fix formatting of comments. > > xen/arch/x86/hvm/hpet.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c > index 0789947..b611304 100644 > --- a/xen/arch/x86/hvm/hpet.c > +++ b/xen/arch/x86/hvm/hpet.c > @@ -495,12 +495,14 @@ static int hpet_save(struct domain *d, > hvm_domain_context_t *h) > { > HPETState *hp = domain_vhpet(d); > int rc; > + uint64_t guest_time; > > spin_lock(&hp->lock); > + guest_time = guest_time_hpet(hp); > > /* Write the proper value into the main counter */ > if ( hpet_enabled(hp) ) > - hp->hpet.mc64 = hp->mc_offset + guest_time_hpet(hp); > + hp->hpet.mc64 = hp->mc_offset + guest_time; > > /* Save the HPET registers */ > rc = _hvm_init_entry(h, HVM_SAVE_CODE(HPET), 0, HVM_SAVE_LENGTH(HPET)); > @@ -524,8 +526,18 @@ static int hpet_save(struct domain *d, hvm_domain_context_t *h) > C(period[1]); > C(period[2]); > #undef C > - /* save the 64 bit comparator in the 64 bit timer[n].cmp field > - * regardless of whether or not the timer is in 32 bit mode. */ > + /* > + * read the comparator to get it updated so hpet_save will > + * return the expected value. > + */ > + hpet_get_comparator(hp, 0, guest_time); > + hpet_get_comparator(hp, 1, guest_time); > + hpet_get_comparator(hp, 2, guest_time); > + /* > + * save the 64 bit comparator in the 64 bit timer[n].cmp > + * field regardless of whether or not the timer is in 32 bit > + * mode. > + */ > rec->timers[0].cmp = hp->hpet.comparator64[0]; > rec->timers[1].cmp = hp->hpet.comparator64[1]; > rec->timers[2].cmp = hp->hpet.comparator64[2]; > -- > 1.8.4