xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH] x86/vtsc: update vcpu_time after hvm_set_guest_time
Date: Tue, 4 Jun 2013 12:12:58 +0200	[thread overview]
Message-ID: <51ADBDAA.3020602@citrix.com> (raw)
In-Reply-To: <51ADBAD7.7000505@eu.citrix.com>

On 04/06/13 12:00, George Dunlap wrote:
> On 06/04/2013 10:58 AM, Roger Pau Monné wrote:
>> On 04/06/13 11:47, George Dunlap wrote:
>>> On 06/04/2013 10:10 AM, Roger Pau Monne wrote:
>>>> When using a vtsc, hvm_set_guest_time changes hvm_vcpu.stime_offset,
>>>> which is used in the vcpu time structure to calculate the
>>>> tsc_timestamp, so after updating stime_offset we need to propagate the
>>>> change to vcpu_time in order for the guest to get the right time if
>>>> using the PV clock.
>>>>
>>>> This was not done correctly, since in context_switch
>>>> update_vcpu_system_time was called before vmx_do_resume, which caused
>>>> the vcpu_info time structure to be updated with the wrong values. This
>>>> patch fixes this by calling update_vcpu_system_time after the call to
>>>> hvm_set_guest_time has happened.
>>>
>>> Would it make more sense to actually do this in hvm_set_guest_time()
>>> instead, so that this window where the vcpu system_time is closed for
>>> all callers, not just hvm_do_resume?
>>>
>>> You could gate calling update_vcpu_system_time on:
>>> 1. Whether stime_offset actually changed
>>> 2. Whether v is currently running
>>
>> This was my first approach, but I thought it was better to fix the
>> actual call to update_vcpu_system_time to happen in the right place
>> (before the context switch), rather than adding more calls to
>> update_vcpu_system_time all over the place.
>>
>> If later we decide for whatever reason to add more offsets to the vtsc,
>> we will also have to add more calls to update_vcpu_system_time in every
>> place that we modify those offsets, which doesn't seem right.
> 
> But you will have to add those anyway if the guest is running. Otherwise
> you'll have this same window, where vcpu_info.system_time is out of sync
> with hvm_vcpu.stime_offset, and this same kind of bug can happen.

This could be solved by also adding a call to update_vcpu_system_time in
pt_intr_post, but given that I'm not sure any more if it's not best to
just do the call to update_vcpu_system_time in hvm_set_guest_time and
get done with it.


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

  reply	other threads:[~2013-06-04 10:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04  9:10 [PATCH] x86/vtsc: update vcpu_time after hvm_set_guest_time Roger Pau Monne
2013-06-04  9:24 ` Jan Beulich
2013-06-04  9:46   ` Roger Pau Monné
2013-06-04  9:56     ` George Dunlap
2013-06-04 10:41       ` Jan Beulich
2013-06-04  9:47 ` George Dunlap
2013-06-04  9:58   ` Roger Pau Monné
2013-06-04 10:00     ` George Dunlap
2013-06-04 10:12       ` Roger Pau Monné [this message]
2013-06-04 11:15   ` Roger Pau Monné
2013-06-04 11:45     ` Jan Beulich
2013-06-04 12:48       ` Roger Pau Monné
2013-06-04 10:24 ` Alex Bligh
2013-06-04 10:28   ` George Dunlap

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=51ADBDAA.3020602@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@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).