All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Paul Durrant <Paul.Durrant@citrix.com>,
	'Jan Beulich' <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"Tim (Xen.org)" <tim@xen.org>,
	George Dunlap <George.Dunlap@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Ian Jackson <Ian.Jackson@citrix.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v5 10/11] viridian: add implementation of synthetic timers
Date: Thu, 14 Mar 2019 09:58:03 +0000	[thread overview]
Message-ID: <505c75a6681d499e83066d620fbf7f89@AMSPEX02CL02.citrite.net> (raw)
In-Reply-To: <5ea47ce70ae54813b9e5189db2f423b3@AMSPEX02CL02.citrite.net>

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xenproject.org] On Behalf Of Paul Durrant
> Sent: 13 March 2019 14:37
> To: 'Jan Beulich' <JBeulich@suse.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Wei Liu <wei.liu2@citrix.com>; Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Tim (Xen.org) <tim@xen.org>;
> George Dunlap <George.Dunlap@citrix.com>; Julien Grall <julien.grall@arm.com>; xen-devel <xen-
> devel@lists.xenproject.org>; Ian Jackson <Ian.Jackson@citrix.com>; Roger Pau Monne
> <roger.pau@citrix.com>
> Subject: Re: [Xen-devel] [PATCH v5 10/11] viridian: add implementation of synthetic timers
> 
[snip]
> 
> > As to safety of this, I have two concerns:
> >
> > 1) TscSequence gets updated as a result of a guest action (an MSR
> > write). This makes it non-obvious that the loop above will get
> > exited in due course.
> >
> 
> True. The domain could try to DoS this call. This could be avoided by doing a domain_pause() if we
> test continuously fails for a number of iterations, or maybe just one iteration.
> 
> > 2) The way update_reference_tsc() deals with the two "invalid"
> > values suggests ~0 and 0 should be special cased in general. I
> > _think_ this is not necessary here, but it also seems to me as if
> > the VM ever having a way to observe either of those two values
> > would be wrong too. Shouldn't the function avoid to ever store
> > ~0 into that field, i.e. increment into a local variable, update
> > that local variable to skip the two "invalid" values, and only then
> > store into the field?
> >
> > Otoh, making it into that function being a result of an MSR write,
> > it may welll be that the spec precludes the guest from reading
> > the reference page while an update was invoked from one of its
> > vCPU-s. If this was the case, then I also wouldn't have to
> > wonder any longer how this entire mechanism can be race free
> > in the first place (without a double increment like we do in the
> > pv-clock protocol).
> 
> From observation, it looks like Windows initializes the reference tsc page before it brings secondary
> CPUs online and then doesn't touch the MSR again, so we should probably only tolerate one mismatch in
> time_now() before doing domain_pause().

Actually it occurred to me last night that I'm being completely thick by coding it this way. The viridian code sets TscScale, not the guest, so we don't even need to reference the HV_REFERENCE_TSC_PAGE struct. Looking again, I'm also concerned that there's a small TOCTOU race in testing whether the reference tsc page is valid where the guest could unmap it on another CPU and cause a NULL pointer deref in time_now(), so I'll re-work this entirely.

  Paul

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-03-14  9:58 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11 13:41 [PATCH v5 00/11] viridian: implement more enlightenments Paul Durrant
2019-03-11 13:41 ` [PATCH v5 01/11] viridian: add init hooks Paul Durrant
2019-03-13 12:23   ` Jan Beulich
2019-03-11 13:41 ` [PATCH v5 02/11] viridian: separately allocate domain and vcpu structures Paul Durrant
2019-03-13 12:25   ` Jan Beulich
2019-03-11 13:41 ` [PATCH v5 03/11] viridian: use stack variables for viridian_vcpu and viridian_domain Paul Durrant
2019-03-13 12:33   ` Jan Beulich
2019-03-11 13:41 ` [PATCH v5 04/11] viridian: make 'fields' struct anonymous Paul Durrant
2019-03-13 12:34   ` Jan Beulich
2019-03-11 13:41 ` [PATCH v5 05/11] viridian: extend init/deinit hooks into synic and time modules Paul Durrant
2019-03-11 13:41 ` [PATCH v5 06/11] viridian: add missing context save helpers " Paul Durrant
2019-03-11 13:41 ` [PATCH v5 07/11] viridian: use viridian_map/unmap_guest_page() for reference tsc page Paul Durrant
2019-03-11 13:41 ` [PATCH v5 08/11] viridian: stop directly calling viridian_time_ref_count_freeze/thaw() Paul Durrant
2019-03-13 12:36   ` Jan Beulich
2019-03-11 13:41 ` [PATCH v5 09/11] viridian: add implementation of synthetic interrupt MSRs Paul Durrant
2019-03-13 13:14   ` Jan Beulich
2019-03-13 13:25     ` Paul Durrant
2019-03-13 14:23       ` Jan Beulich
2019-03-13 14:51         ` Paul Durrant
2019-03-13 16:13     ` Paul Durrant
2019-03-14  7:47       ` Jan Beulich
2019-03-14  8:46         ` Paul Durrant
2019-03-11 13:41 ` [PATCH v5 10/11] viridian: add implementation of synthetic timers Paul Durrant
2019-03-13 13:06   ` Paul Durrant
2019-03-13 14:10     ` Jan Beulich
2019-03-13 14:05   ` Jan Beulich
2019-03-13 14:37     ` Paul Durrant
2019-03-13 15:36       ` Jan Beulich
2019-03-13 15:43         ` Paul Durrant
2019-03-14  9:58       ` Paul Durrant [this message]
2019-03-11 13:41 ` [PATCH v5 11/11] viridian: add implementation of the HvSendSyntheticClusterIpi hypercall Paul Durrant
2019-03-13 14:08   ` Jan Beulich

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=505c75a6681d499e83066d620fbf7f89@AMSPEX02CL02.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.