From: Peter Lieven <pl@dlhnet.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Vadim Rozenfeld <vrozenfe@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org, gleb@redhat.com, pl@dlh.net
Subject: Re: [RFC PATCH v2 1/2] add support for Hyper-V reference time counter
Date: Thu, 23 May 2013 12:45:34 +0200 [thread overview]
Message-ID: <519DF34E.9040409@dlhnet.de> (raw)
In-Reply-To: <519DE747.9070303@redhat.com>
On 23.05.2013 11:54, Paolo Bonzini wrote:
> Il 23/05/2013 08:17, Peter Lieven ha scritto:
>> On 22.05.2013 23:55, Paolo Bonzini wrote:
>>> Il 22/05/2013 09:32, Vadim Rozenfeld ha scritto:
>>>>>> @@ -1827,6 +1829,29 @@ static int set_msr_hyperv_pw(struct kvm_vcpu
>>>>>> *vcpu, u32 msr, u64 data)
>>>>>> if (__copy_to_user((void __user *)addr, instructions, 4))
>>>>>> return 1;
>>>>>> kvm->arch.hv_hypercall = data;
>>>>>> + local_irq_disable();
>>>>>> + kvm->arch.hv_ref_count = get_kernel_ns();
>>>>>> + local_irq_enable();
>>>>>> + break;
>>>> local_irq_disable/local_irq_enable not needed.
>>>>
>>>>
>>>> What is the reasoning behind reading this time value at msr write time?
>>>> [VR] Windows writs this MSR only once, during HAL initialization.
>>>> So, I decided to treat this call as a partition crate event.
>>>>
>>>
>>> But is it expected by Windows that the reference count starts counting
>>> up from 0 at partition creation time? If you could just use
>>> (get_kernel_ns() + kvm->arch.kvmclock_offset) / 100, it would also be
>>> simpler for migration purposes.
>>
>> I can just report, that I have used the patch that does it that way and
>> it works.
>
> What do you mean by "that way"? :)
Ups sorry… I meant the way it was implemented in the old patch (I sent a few days ago).
@@ -1426,6 +1428,21 @@ static int set_msr_hyperv_pw(struct kvm_
if (__copy_to_user((void *)addr, instructions, 4))
return 1;
kvm->arch.hv_hypercall = data;
+ kvm->arch.hv_ref_count = get_kernel_ns();
+ break;
+ }
+ case HV_X64_MSR_REFERENCE_TSC: {
+ u64 gfn;
+ unsigned long addr;
+ u32 hv_tsc_sequence;
+ gfn = data >> HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT;
+ addr = gfn_to_hva(kvm, gfn);
+ if (kvm_is_error_hva(addr))
+ return 1;
+ hv_tsc_sequence = 0x0; //invalid
+ if (__copy_to_user((void *)addr, (void __user *) &hv_tsc_sequence, sizeof(hv_tsc_sequence)))
+ return 1;
+ kvm->arch.hv_reference_tsc = data;
break;
}
default:
@@ -1826,6 +1843,17 @@ static int get_msr_hyperv_pw(struct kvm_
case HV_X64_MSR_HYPERCALL:
data = kvm->arch.hv_hypercall;
break;
+ case HV_X64_MSR_TIME_REF_COUNT: {
+ u64 now_ns;
+ local_irq_disable();
+ now_ns = get_kernel_ns();
+ data = div_u64(now_ns + kvm->arch.kvmclock_offset - kvm->arch.hv_ref_count,100);
+ local_irq_enable();
+ break;
+ }
+ case HV_X64_MSR_REFERENCE_TSC:
+ data = kvm->arch.hv_reference_tsc;
+ break;
default:
pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
return 1;
Peter
next prev parent reply other threads:[~2013-05-23 10:45 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-19 7:06 [RFC PATCH v2 0/2] Hyper-V timers Vadim Rozenfeld
2013-05-19 7:06 ` [RFC PATCH v2 1/2] add support for Hyper-V reference time counter Vadim Rozenfeld
2013-05-19 13:47 ` Gleb Natapov
2013-05-19 14:37 ` Paolo Bonzini
2013-05-22 0:46 ` Marcelo Tosatti
2013-05-22 3:28 ` Gleb Natapov
2013-05-22 3:32 ` Marcelo Tosatti
2013-05-22 3:38 ` Gleb Natapov
2013-05-22 14:31 ` Marcelo Tosatti
2013-05-22 7:32 ` Vadim Rozenfeld
2013-05-22 21:55 ` Paolo Bonzini
2013-05-23 6:17 ` Peter Lieven
2013-05-23 9:54 ` Paolo Bonzini
2013-05-23 10:45 ` Peter Lieven [this message]
2013-05-23 12:25 ` Vadim Rozenfeld
2013-05-23 13:18 ` Paolo Bonzini
2013-05-23 13:20 ` Peter Lieven
2013-05-23 13:23 ` Paolo Bonzini
2013-05-23 13:30 ` Peter Lieven
2013-05-23 13:40 ` Paolo Bonzini
2013-05-19 7:06 ` [RFC PATCH v2 2/2] add support for Hyper-V invariant TSC Vadim Rozenfeld
2013-05-22 0:50 ` Marcelo Tosatti
2013-05-22 7:22 ` Vadim Rozenfeld
2013-05-22 21:23 ` Marcelo Tosatti
2013-05-23 6:18 ` Peter Lieven
2013-05-23 9:13 ` Gleb Natapov
2013-05-23 13:35 ` Marcelo Tosatti
2013-05-23 15:14 ` Gleb Natapov
2013-05-24 9:57 ` Vadim Rozenfeld
2013-05-23 12:33 ` Vadim Rozenfeld
2013-05-23 12:44 ` Peter Lieven
2013-05-23 12:45 ` Gleb Natapov
2013-05-23 12:54 ` Vadim Rozenfeld
2013-05-23 9:12 ` Gleb Natapov
2013-05-23 13:53 ` Marcelo Tosatti
2013-05-23 15:31 ` Gleb Natapov
2013-05-24 10:11 ` Vadim Rozenfeld
2013-05-24 19:41 ` Marcelo Tosatti
2013-05-27 12:33 ` Vadim Rozenfeld
2013-05-23 12:21 ` Vadim Rozenfeld
2013-05-23 13:47 ` Marcelo Tosatti
2013-05-24 10:01 ` Vadim Rozenfeld
2013-05-23 16:44 ` Paolo Bonzini
2013-05-24 10:16 ` Vadim Rozenfeld
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=519DF34E.9040409@dlhnet.de \
--to=pl@dlhnet.de \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@dlh.net \
--cc=vrozenfe@redhat.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.