From: Vadim Rozenfeld <vrozenfe@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com, pl@dlh.net
Subject: Re: [RFC PATCH 2/2] Hyper-V iTSC handler
Date: Thu, 16 May 2013 18:58:02 +1000 [thread overview]
Message-ID: <1368694682.18400.6.camel@localhost> (raw)
In-Reply-To: <20130516083349.GL26453@redhat.com>
On Thu, 2013-05-16 at 11:33 +0300, Gleb Natapov wrote:
> On Mon, May 13, 2013 at 09:45:17PM +1000, Vadim Rozenfeld wrote:
> > Signed-off: Vadim Rozenfeld <vrozenfe@redhat.com>
> >
> > The following patch allows to activate a partition reference
> > time enlightenment that is based on the host platform's support
> > for an Invariant Time Stamp Counter (iTSC).
> > NOTE: This code will survive migration due to lack of VM stop/resume
> > handlers.
> >
> Do you mean "will _not_ survive migration"?
Sorry for typo. Yes, it will not,
because offset, scale and sequence must be
readjusted.
>
> > ---
> > arch/x86/include/uapi/asm/hyperv.h | 10 ++++++++++
> > arch/x86/kvm/x86.c | 18 +++++++++++++-----
> > include/uapi/linux/kvm.h | 1 +
> > 3 files changed, 24 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
> > index 9711819..2d9e666 100644
> > --- a/arch/x86/include/uapi/asm/hyperv.h
> > +++ b/arch/x86/include/uapi/asm/hyperv.h
> > @@ -182,6 +182,9 @@
> > #define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_MASK \
> > (~((1ull << HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
> >
> > +#define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001
> > +#define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12
> > +
> > #define HV_PROCESSOR_POWER_STATE_C0 0
> > #define HV_PROCESSOR_POWER_STATE_C1 1
> > #define HV_PROCESSOR_POWER_STATE_C2 2
> > @@ -194,4 +197,11 @@
> > #define HV_STATUS_INVALID_ALIGNMENT 4
> > #define HV_STATUS_INSUFFICIENT_BUFFERS 19
> >
> > +typedef struct _HV_REFERENCE_TSC_PAGE {
> > + uint32_t TscSequence;
> > + uint32_t Rserved1;
> > + uint64_t TscScale;
> > + int64_t TscOffset;
> > +} HV_REFERENCE_TSC_PAGE, * PHV_REFERENCE_TSC_PAGE;
> > +
> Use kernel types: __u32/__u64/__s64.
>
> > #endif
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 1a4036d..5788e8f 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -1809,14 +1809,21 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
> > break;
> > }
> > case HV_X64_MSR_REFERENCE_TSC: {
> > - u64 gfn;
> > unsigned long addr;
> > - u32 tsc_ref;
> > - gfn = data >> HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT;
> > - addr = gfn_to_hva(kvm, gfn);
> > + HV_REFERENCE_TSC_PAGE tsc_ref;
> > + tsc_ref.TscSequence =
> > + boot_cpu_has(X86_FEATURE_CONSTANT_TSC) ? 1 : 0;
> > + tsc_ref.TscScale =
> > + ((10000LL << 32) /vcpu->arch.virtual_tsc_khz) << 32;
> > + tsc_ref.TscOffset = 0;
> > + if (!(data & HV_X64_MSR_TSC_REFERENCE_ENABLE)) {
> > + kvm->arch.hv_tsc_page = data;
> > + break;
> > + }
> > + addr = gfn_to_hva(vcpu->kvm, data >>
> > + HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT);
> > if (kvm_is_error_hva(addr))
> > return 1;
> > - tsc_ref = 0;
> > if(__copy_to_user((void __user *)addr, &tsc_ref, sizeof(tsc_ref)))
> > return 1;
> > kvm->arch.hv_tsc_page = data;
> > @@ -2553,6 +2560,7 @@ int kvm_dev_ioctl_check_extension(long ext)
> > case KVM_CAP_HYPERV:
> > case KVM_CAP_HYPERV_VAPIC:
> > case KVM_CAP_HYPERV_SPIN:
> > + case KVM_CAP_HYPERV_TSC:
> > case KVM_CAP_PCI_SEGMENT:
> > case KVM_CAP_DEBUGREGS:
> > case KVM_CAP_X86_ROBUST_SINGLESTEP:
> > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> > index a5c86fc..8eff540 100644
> > --- a/include/uapi/linux/kvm.h
> > +++ b/include/uapi/linux/kvm.h
> > @@ -666,6 +666,7 @@ struct kvm_ppc_smmu_info {
> > #define KVM_CAP_IRQ_MPIC 90
> > #define KVM_CAP_PPC_RTAS 91
> > #define KVM_CAP_IRQ_XICS 92
> > +#define KVM_CAP_HYPERV_TSC 93
> >
> > #ifdef KVM_CAP_IRQ_ROUTING
> >
> > --
> > 1.8.1.2
>
> --
> Gleb.
next prev parent reply other threads:[~2013-05-16 8:58 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-13 11:45 [RFC PATCH 0/2] Hyper-V timers Vadim Rozenfeld
2013-05-13 11:45 ` [RFC PATCH 1/2] Hyper-H reference counter Vadim Rozenfeld
2013-05-13 23:30 ` Eric Northup
2013-05-14 9:46 ` Vadim Rozenfeld
2013-05-16 8:18 ` Gleb Natapov
2013-05-16 8:53 ` Vadim Rozenfeld
2013-05-14 14:14 ` Peter Lieven
2013-05-15 10:24 ` Vadim Rozenfeld
2013-05-16 8:10 ` Gleb Natapov
2013-05-16 8:34 ` Gleb Natapov
2013-05-16 9:13 ` Vadim Rozenfeld
2013-05-16 9:21 ` Gleb Natapov
2013-05-16 9:28 ` Vadim Rozenfeld
2013-05-16 13:37 ` Paolo Bonzini
2013-05-16 14:22 ` Vadim Rozenfeld
2013-05-16 14:48 ` Paolo Bonzini
2013-05-16 13:44 ` Paolo Bonzini
2013-05-16 14:26 ` Vadim Rozenfeld
2013-05-16 14:45 ` Paolo Bonzini
2013-05-19 6:37 ` Vadim Rozenfeld
2013-05-20 8:05 ` Paolo Bonzini
2013-05-20 8:36 ` Gleb Natapov
2013-05-20 8:42 ` Paolo Bonzini
2013-05-20 8:49 ` Gleb Natapov
2013-05-20 8:56 ` Paolo Bonzini
2013-05-20 9:13 ` Gleb Natapov
2013-05-20 9:25 ` Gleb Natapov
2013-05-20 9:32 ` Paolo Bonzini
2013-05-20 9:41 ` Gleb Natapov
2013-05-20 10:06 ` Peter Lieven
2013-05-20 10:25 ` Vadim Rozenfeld
2013-05-20 10:27 ` Gleb Natapov
2013-05-20 10:44 ` Vadim Rozenfeld
2013-05-20 10:21 ` Vadim Rozenfeld
2013-05-20 9:12 ` Vadim Rozenfeld
2013-05-16 14:40 ` Paolo Bonzini
2013-05-13 11:45 ` [RFC PATCH 2/2] Hyper-V iTSC handler Vadim Rozenfeld
2013-05-16 8:33 ` Gleb Natapov
2013-05-16 8:58 ` Vadim Rozenfeld [this message]
2013-05-16 8:02 ` [RFC PATCH 0/2] Hyper-V timers Gleb Natapov
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=1368694682.18400.6.camel@localhost \
--to=vrozenfe@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pl@dlh.net \
/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