xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: andrew.cooper3@citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH v2] x86/time: Don't use virtual TSC if host and guest frequencies are equal
Date: Fri, 17 Mar 2017 11:13:33 -0400	[thread overview]
Message-ID: <4c69d82a-e90f-9465-d63a-4e3ca46469e9@oracle.com> (raw)
In-Reply-To: <58CC074A02000078001445FB@prv-mh.provo.novell.com>

On 03/17/2017 10:56 AM, Jan Beulich wrote:
>>>> On 17.03.17 at 15:50, <boris.ostrovsky@oracle.com> wrote:
>> On 03/17/2017 10:24 AM, Jan Beulich wrote:
>>>>>> On 17.03.17 at 14:36, <boris.ostrovsky@oracle.com> wrote:
>>>> On 03/17/2017 03:48 AM, Jan Beulich wrote:
>>>>>>>> On 16.03.17 at 20:35, <boris.ostrovsky@oracle.com> wrote:
>>>>>> --- a/xen/arch/x86/time.c
>>>>>> +++ b/xen/arch/x86/time.c
>>>>>> @@ -2051,17 +2051,12 @@ void tsc_set_info(struct domain *d,
>>>>>>          d->arch.vtsc_offset = get_s_time() - elapsed_nsec;
>>>>>>          d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
>>>>>>          set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
>>>>>> -        /*
>>>>>> -         * In default mode use native TSC if the host has safe TSC and:
>>>>>> -         *  HVM/PVH: host and guest frequencies are the same (either
>>>>>> -         *           "naturally" or via TSC scaling)
>>>>>> -         *  PV: guest has not migrated yet (and thus arch.tsc_khz == 
>> cpu_khz)
>>>>>> -         */
>>>>>> +
>>>>>> +        ASSERT(incarnation || d->arch.tsc_khz == cpu_khz);
>>>>> Hmm, is this valid for other than TSC_MODE_DEFAULT?
>>>> It is valid for all modes but I thought that the ASSERT is really only
>>>> "interesting" for DEFAULT and ALWAYS_EMULATE since this is when we
>>>> decide whether or not to set vtsc.
>>>>
>>>> Since I need to rebase this anyway (due to PVH1 removal) I can move this
>>>> down right after the switch if you feel it would be useful.
>>> Actually I think the other way around: For ALWAYS_EMULATE as
>>> well as for PVRDTSCP I don't think the assertion is valid, the more
>>> that d->arch.tsc_khz gets set from input to the function. That last
>>> fact actually makes the ASSERT() dubious in all cases, I'm afraid.
>> It is valid (in the sense that it will evaluate to true) because we
>> always first call tsc_set_info with DEFAULT mode and with gtsc_khz=0
>> from arch_domain_create(). So d->arch.tsc_khz will be primed to cpu_khz.
> It is valid for this specific call. A malicious tool stack could easily
> pass incarnation zero to the domctl together with a random
> gtsc_khz.


So how do you want to go about this then? Original (but rebased) patch,
remove incarnation check and add a comment stating that there is no need
to check it?

-boris


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

  reply	other threads:[~2017-03-17 15:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 19:35 [PATCH v2] x86/time: Don't use virtual TSC if host and guest frequencies are equal Boris Ostrovsky
2017-03-17  7:48 ` Jan Beulich
2017-03-17 13:36   ` Boris Ostrovsky
2017-03-17 14:24     ` Jan Beulich
2017-03-17 14:50       ` Boris Ostrovsky
2017-03-17 14:56         ` Jan Beulich
2017-03-17 15:13           ` Boris Ostrovsky [this message]
2017-03-17 15:20             ` 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=4c69d82a-e90f-9465-d63a-4e3ca46469e9@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@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).