From: Andrey Smetanin <asmetanin@virtuozzo.com>
To: Paolo Bonzini <pbonzini@redhat.com>, <kvm@vger.kernel.org>
Cc: Gleb Natapov <gleb@kernel.org>,
Roman Kagan <rkagan@virtuozzo.com>,
"Denis V. Lunev" <den@openvz.org>, <qemu-devel@nongnu.org>
Subject: Re: [PATCH v1] kvm/x86: Hyper-V tsc page setup
Date: Fri, 22 Jan 2016 14:11:46 +0300 [thread overview]
Message-ID: <56A20E72.6050404@virtuozzo.com> (raw)
In-Reply-To: <56A20C30.4020608@redhat.com>
On 01/22/2016 02:02 PM, Paolo Bonzini wrote:
>
>
> On 22/01/2016 11:15, Andrey Smetanin wrote:
>>>
>>> - unless KVM can use a master clock, it is incorrect to set up the TSC
>>> page this way; the sequence needs to be 0xFFFFFFFF in that case
>> 0xFFFFFFFF is not an invalid value for tsc page,
>> see https://lkml.org/lkml/2015/11/2/655
>
> oh, I see now.
>
>>> - writing the TSC page must be done while all VCPUs are stopped, because
>>> the TSC page doesn't provide the possibility for the guest to retry in
>>> the middle of an update (like seqcount in Linux doess)
>> I think Windows guest gives tsc page address at boot time and protects
>> against other vcpu's tsc page access.
>
> Sometimes the TSC is detected to be unstable and Linux switches to
> another clocksource. At least in that case you can get a write to the
> TSC page while the guest is running.
I can't understand how write is possible.
Linux Hyper-V driver hv_vmbus.ko does the following inside hv_init()
drivers/hv/hv.c(line 256):
wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
So page is setup only once before registration clock source.
>
> In that case it would be enough to write a zero to tsc_sequence, which
> _can_ be done atomically while the guest is running. However, KVM
> already has a mechanism to stop all VCPUs (KVM_REQ_MASTERCLOCK_UPDATE)
> so we might as well use it.
>
> Paolo
>
WARNING: multiple messages have this Message-ID (diff)
From: Andrey Smetanin <asmetanin@virtuozzo.com>
To: Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org
Cc: Gleb Natapov <gleb@kernel.org>, "Denis V. Lunev" <den@openvz.org>,
Roman Kagan <rkagan@virtuozzo.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v1] kvm/x86: Hyper-V tsc page setup
Date: Fri, 22 Jan 2016 14:11:46 +0300 [thread overview]
Message-ID: <56A20E72.6050404@virtuozzo.com> (raw)
In-Reply-To: <56A20C30.4020608@redhat.com>
On 01/22/2016 02:02 PM, Paolo Bonzini wrote:
>
>
> On 22/01/2016 11:15, Andrey Smetanin wrote:
>>>
>>> - unless KVM can use a master clock, it is incorrect to set up the TSC
>>> page this way; the sequence needs to be 0xFFFFFFFF in that case
>> 0xFFFFFFFF is not an invalid value for tsc page,
>> see https://lkml.org/lkml/2015/11/2/655
>
> oh, I see now.
>
>>> - writing the TSC page must be done while all VCPUs are stopped, because
>>> the TSC page doesn't provide the possibility for the guest to retry in
>>> the middle of an update (like seqcount in Linux doess)
>> I think Windows guest gives tsc page address at boot time and protects
>> against other vcpu's tsc page access.
>
> Sometimes the TSC is detected to be unstable and Linux switches to
> another clocksource. At least in that case you can get a write to the
> TSC page while the guest is running.
I can't understand how write is possible.
Linux Hyper-V driver hv_vmbus.ko does the following inside hv_init()
drivers/hv/hv.c(line 256):
wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
So page is setup only once before registration clock source.
>
> In that case it would be enough to write a zero to tsc_sequence, which
> _can_ be done atomically while the guest is running. However, KVM
> already has a mechanism to stop all VCPUs (KVM_REQ_MASTERCLOCK_UPDATE)
> so we might as well use it.
>
> Paolo
>
next prev parent reply other threads:[~2016-01-22 11:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-24 9:33 [PATCH v1] kvm/x86: Hyper-V tsc page setup Andrey Smetanin
2015-12-24 9:33 ` [Qemu-devel] " Andrey Smetanin
2016-01-05 21:48 ` Peter Hornyack
2016-01-05 21:48 ` [Qemu-devel] " Peter Hornyack
2016-01-06 9:22 ` Andrey Smetanin
2016-01-06 9:22 ` [Qemu-devel] " Andrey Smetanin
2016-01-12 7:43 ` Andrey Smetanin
2016-01-12 7:43 ` [Qemu-devel] " Andrey Smetanin
2016-01-19 7:48 ` Denis V. Lunev
2016-01-19 7:48 ` [Qemu-devel] " Denis V. Lunev
2016-01-20 14:05 ` Paolo Bonzini
2016-01-20 14:05 ` [Qemu-devel] " Paolo Bonzini
2016-01-20 14:41 ` Andrey Smetanin
2016-01-20 14:41 ` [Qemu-devel] " Andrey Smetanin
2016-01-20 14:44 ` Denis V. Lunev
2016-01-20 14:44 ` [Qemu-devel] " Denis V. Lunev
2016-01-20 14:52 ` Roman Kagan
2016-01-20 14:52 ` [Qemu-devel] " Roman Kagan
2016-01-20 14:54 ` Denis V. Lunev
2016-01-20 14:54 ` [Qemu-devel] " Denis V. Lunev
2016-01-20 21:10 ` Paolo Bonzini
2016-01-20 21:10 ` [Qemu-devel] " Paolo Bonzini
2016-01-22 10:08 ` Paolo Bonzini
2016-01-22 10:08 ` [Qemu-devel] " Paolo Bonzini
2016-01-22 10:15 ` Andrey Smetanin
2016-01-22 10:15 ` [Qemu-devel] " Andrey Smetanin
2016-01-22 11:02 ` Paolo Bonzini
2016-01-22 11:02 ` [Qemu-devel] " Paolo Bonzini
2016-01-22 11:11 ` Andrey Smetanin [this message]
2016-01-22 11:11 ` Andrey Smetanin
2016-01-22 11:31 ` Andrey Smetanin
2016-01-22 11:31 ` [Qemu-devel] " Andrey Smetanin
2016-01-22 11:53 ` Paolo Bonzini
2016-01-22 11:53 ` [Qemu-devel] " Paolo Bonzini
2016-01-22 11:59 ` Andrey Smetanin
2016-01-22 11:59 ` [Qemu-devel] " Andrey Smetanin
2016-01-22 13:13 ` Andrey Smetanin
2016-01-22 13:13 ` [Qemu-devel] " Andrey Smetanin
2016-01-22 13:21 ` Paolo Bonzini
2016-01-22 13:21 ` [Qemu-devel] " Paolo Bonzini
2016-01-22 13:34 ` Andrey Smetanin
2016-01-22 13:34 ` [Qemu-devel] " Andrey Smetanin
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=56A20E72.6050404@virtuozzo.com \
--to=asmetanin@virtuozzo.com \
--cc=den@openvz.org \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkagan@virtuozzo.com \
/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.