xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Keir Fraser <keir.xen@gmail.com>
To: Tim Deegan <tim@xen.org>, xen-devel@lists.xen.org
Cc: JBeulich@suse.com, suravee.suthikulpanit@amd.com
Subject: Re: [PATCH 2/4] x86/hvm: Run the RTC periodic timer on a consistent time series.
Date: Thu, 28 Mar 2013 13:27:38 +0000	[thread overview]
Message-ID: <CD79F5CA.1F979%keir.xen@gmail.com> (raw)
In-Reply-To: <1364476936-15824-3-git-send-email-tim@xen.org>

On 28/03/2013 13:22, "Tim Deegan" <tim@xen.org> wrote:

> When the RTC periodic timer gets restarted, align it to the VM's boot
> time, not to whatever time it is now.  Otherwise every read of REG_C
> will restart the current period
> 
> Signed-off-by: Tim Deegan <tim@xen.org>

Looks rather sensible.

Acked-by: Keir Fraser <keir@xen.org>

> ---
>  xen/arch/x86/hvm/rtc.c        |    6 ++++--
>  xen/include/asm-x86/hvm/vpt.h |    3 ++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c
> index 368d3c8..710ae89 100644
> --- a/xen/arch/x86/hvm/rtc.c
> +++ b/xen/arch/x86/hvm/rtc.c
> @@ -91,7 +91,7 @@ void rtc_periodic_interrupt(void *opaque)
>   * RTC_RATE_SELECT settings */
>  static void rtc_timer_update(RTCState *s)
>  {
> -    int period_code, period;
> +    int period_code, period, delta;
>      struct vcpu *v = vrtc_vcpu(s);
>  
>      ASSERT(spin_is_locked(&s->lock));
> @@ -109,7 +109,8 @@ static void rtc_timer_update(RTCState *s)
>          {
>              period = 1 << (period_code - 1); /* period in 32 Khz cycles */
>              period = DIV_ROUND(period * 1000000000ULL, 32768); /* in ns */
> -            create_periodic_time(v, &s->pt, period, period, RTC_IRQ, NULL,
> s);
> +            delta = period - ((NOW() - s->start_time) % period);
> +            create_periodic_time(v, &s->pt, delta, period, RTC_IRQ, NULL, s);
>              break;
>          }
>          /* fall through */
> @@ -741,6 +742,7 @@ void rtc_init(struct domain *d)
>      s->hw.cmos_data[RTC_REG_D] = RTC_VRT;
>  
>      s->current_tm = gmtime(get_localtime(d));
> +    s->start_time = NOW();
>  
>      rtc_copy_date(s);
>  
> diff --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h
> index c75297b..2e9c7d2 100644
> --- a/xen/include/asm-x86/hvm/vpt.h
> +++ b/xen/include/asm-x86/hvm/vpt.h
> @@ -104,8 +104,9 @@ typedef struct RTCState {
>      struct hvm_hw_rtc hw;
>      /* RTC's idea of the current time */
>      struct tm current_tm;
> +    /* periodic timer */
> +    s_time_t start_time;
>      /* second update */
> -    int64_t next_second_time;
>      struct periodic_time pt;
>      /* update-ended timer */
>      struct timer update_timer;

  reply	other threads:[~2013-03-28 13:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 13:22 [PATCH 0/4] x86/hvm: RTC periodic timer adjustments Tim Deegan
2013-03-28 13:22 ` [PATCH 1/4] x86/hvm: Centralize and simplify the RTC IRQ logic Tim Deegan
2013-03-28 13:33   ` Andrew Cooper
2013-03-28 13:42     ` Tim Deegan
2013-03-28 13:49   ` Jan Beulich
2013-03-28 14:08     ` Tim Deegan
2013-03-28 14:22       ` Jan Beulich
2013-03-28 14:38         ` Tim Deegan
2013-03-28 15:19           ` Jan Beulich
2013-03-28 15:30             ` Tim Deegan
2013-03-28 15:41               ` Jan Beulich
2013-03-28 19:57               ` Keir Fraser
2013-03-28 13:22 ` [PATCH 2/4] x86/hvm: Run the RTC periodic timer on a consistent time series Tim Deegan
2013-03-28 13:27   ` Keir Fraser [this message]
2013-03-28 13:22 ` [PATCH 3/4] x86/hvm: Avoid needlessly resetting the periodic timer Tim Deegan
2013-03-28 13:41   ` Jan Beulich
2013-03-28 13:58     ` Tim Deegan
2013-03-28 13:22 ` [PATCH 4/4] x86/hvm: Let the guest miss a few ticks before resetting the timer Tim Deegan
2013-03-28 13:53   ` Jan Beulich
2013-03-28 14:42     ` Tim Deegan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CD79F5CA.1F979%keir.xen@gmail.com \
    --to=keir.xen@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).