From: Ian Campbell <ian.campbell@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Matt Wilson <msw@linux.com>, Christoph Egger <chegger@amazon.de>,
Ian Jackson <ian.jackson@eu.citrix.com>,
xen-devel@lists.xen.org, Paul Durrant <paul.durrant@citrix.com>,
Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [PATCH v2] x86/viridian: Add Partition Reference Time enlightenment
Date: Tue, 14 Oct 2014 11:04:49 +0100 [thread overview]
Message-ID: <1413281089.10417.21.camel@citrix.com> (raw)
In-Reply-To: <543D0F5A020000780003E9B8@mail.emea.novell.com>
On Tue, 2014-10-14 at 10:56 +0100, Jan Beulich wrote:
> >>> On 14.10.14 at 09:45, <ian.campbell@citrix.com> wrote:
> > On Mon, 2014-10-13 at 09:10 +0100, Jan Beulich wrote:
> >> >>> On 10.10.14 at 18:36, <msw@linux.com> wrote:
> >> > On Mon, Sep 29, 2014 at 11:28:44AM +0100, Paul Durrant wrote:
> >> >> + /*
> >> >> + * The guest will calculate reference time according to the following
> >> >> + * formula:
> >> >> + *
> >> >> + * ReferenceTime = ((RDTSC() * TscScale) >> 64) + TscOffset
> >> >> + *
> >> >> + * Windows uses a 100ns tick, so we need a scale which is cpu
> >> >> + * ticks per 100ns shifted left by 64.
> >> >> + */
> >> >> + p->TscScale = ((10000ul << 32) / d->arch.tsc_khz) << 32;
> >> >> +
> >> >> + do {
> >> >> + p->TscSequence++;
> >> >> + } while ( p->TscSequence == 0xFFFFFFFF ||
> >> >> + p->TscSequence == 0 ); /* Avoid both 'invalid' values */
> >> >
> >> > Anthony Liguori and I were looking this over today and he pointed
> >> > something out: couldn't a second vCPU of the guest write 0 or
> >> > 0xffffffff in a tight loop to cause a hypervisor DoS?
> >>
> >> Yes, this is at least a theoretical issue that should be fixed. I don't
> >> think it's a practical issue though: I'd expect the compiler to eliminate
> >> the two reads of the field and instead directly use the result of the
> >> increment.
> >
> > Wouldn't that just mean the attacker needs to write fffffffe or ffffffff
> > instead?
>
> No. The effect of what I said would amount to
>
> x = p->TscSequence;
> do {
> x++;
> } while ( !(x + 1) || !x )
> p->TscSequence = x;
>
> (or something equivalent without using a loop).
Ah right. Perhaps it would better to write it that way and use some sort
of ACCESS_ONCE like macrot enforce it actually ends up that way rather
than rely on the vagaries of the compiler?
next prev parent reply other threads:[~2014-10-14 10:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-29 10:28 [PATCH v2] x86/viridian: Add Partition Reference Time enlightenment Paul Durrant
2014-10-10 11:55 ` Egger, Christoph
2014-10-13 8:53 ` Egger, Christoph
2014-10-13 9:31 ` Jan Beulich
2014-10-13 10:33 ` Paul Durrant
2014-10-10 16:36 ` Matt Wilson
2014-10-13 8:10 ` Jan Beulich
2014-10-14 7:45 ` Ian Campbell
2014-10-14 9:56 ` Jan Beulich
2014-10-14 10:04 ` Ian Campbell [this message]
2014-10-14 10:12 ` Jan Beulich
2014-10-14 10:16 ` Paul Durrant
-- strict thread matches above, loose matches on Subject: below --
2014-10-13 14:24 Paul Durrant
2014-10-13 14:25 ` Paul Durrant
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=1413281089.10417.21.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=anthony@codemonkey.ws \
--cc=chegger@amazon.de \
--cc=ian.jackson@eu.citrix.com \
--cc=keir@xen.org \
--cc=msw@linux.com \
--cc=paul.durrant@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--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).