All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Vadim Rozenfeld <vrozenfe@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com, pl@dlhnet.de
Subject: Re: [RFC PATCH v4 2/2] add support for Hyper-V partition reference time enlightenment
Date: Thu, 16 Jan 2014 14:53:26 +0100	[thread overview]
Message-ID: <52D7E456.1000806@redhat.com> (raw)
In-Reply-To: <1389691337-12050-3-git-send-email-vrozenfe@redhat.com>

Il 14/01/2014 10:22, Vadim Rozenfeld ha scritto:
> @@ -1883,6 +1884,13 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
>  		addr = gfn_to_hva(kvm, gfn);
>  		if (kvm_is_error_hva(addr))
>  			return 1;
> +		if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC)
> +		    && ka->use_master_clock) {
> +			tsc_ref.tsc_sequence = 1;

I think that after the first migration the sequence number will always
be 2: set_msr_hyperv_pw will set it to 1, and KVM_SET_KVMCLOCK will
increment it.  Can you check this?

The solution would be to propagate the "struct msr_data *" argument from
kvm_set_msr_common to kvm_set_msr_hyper_pw.  Then, here in this "if" you
can test msr_info->host_initiated, and increment the tsc_sequence
instead of resetting.  Like

	if ((!msr_info->host_initiated || tsc_ref.tsc_sequence) &&
	    boot_cpu_has(X86_FEATURE_CONSTANT_TSC) &&
	    ka->use_master_clock) {
		tsc_ref.tsc_sequence = msr_info->host_initiated
			? tsc_ref.tsc_sequence + 1
			: 1;

> +			tsc_ref.tsc_scale = ((10000LL << 32) /
> +					     vcpu->arch.virtual_tsc_khz) << 32;
> +			tsc_ref.tsc_offset = kvm->arch.kvmclock_offset;
> +		}
>  		if (__copy_to_user((void __user *)addr, &tsc_ref, sizeof(tsc_ref)))
>  			return 1;
>  		mark_page_dirty(kvm, gfn);
> @@ -3871,6 +3879,27 @@ long kvm_arch_vm_ioctl(struct file *filp,
>  		local_irq_enable();
>  		kvm->arch.kvmclock_offset = delta;
>  		kvm_gen_update_masterclock(kvm);
> +		if (kvm->arch.hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE) {
> +			HV_REFERENCE_TSC_PAGE tsc_ref;
> +			struct kvm_arch *ka = &kvm->arch;
> +			r = kvm_read_guest(kvm, kvm->arch.hv_tsc_page,
> +					   &tsc_ref, sizeof(tsc_ref));
> +			if (r)
> +				goto out;
> +			if (tsc_ref.tsc_sequence
> +			    && boot_cpu_has(X86_FEATURE_CONSTANT_TSC)
> +			    && ka->use_master_clock) {
> +				tsc_ref.tsc_sequence++;
> +				tsc_ref.tsc_scale = ((10000LL << 32) /
> +					__get_cpu_var(cpu_tsc_khz)) << 32;

Since on migration kvm_set_hyperv_pw will always be called, do you need
to write tsc_ref.scale at all here?

Paolo

> +                        	tsc_ref.tsc_offset = kvm->arch.kvmclock_offset;
> +			} else
> +				tsc_ref.tsc_sequence = 0;
> +			r = kvm_write_guest(kvm, kvm->arch.hv_tsc_page,
> +					    &tsc_ref, sizeof(tsc_ref));
> +			if (r)
> +				goto out;
> +		}
>  		break;
>  	}
>  	case KVM_GET_CLOCK: {
> 


      parent reply	other threads:[~2014-01-16 13:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14  9:22 [RFC PATCH v4 0/2] Hyper-V timers Vadim Rozenfeld
2014-01-14  9:22 ` [RFC PATCH v4 1/2] add support for Hyper-V reference time counter Vadim Rozenfeld
2014-01-14 11:06   ` Paolo Bonzini
2014-01-14  9:22 ` [RFC PATCH v4 2/2] add support for Hyper-V partition reference time enlightenment Vadim Rozenfeld
2014-01-14 11:03   ` Paolo Bonzini
2014-01-14 19:10     ` Marcelo Tosatti
2014-01-14 19:20   ` Marcelo Tosatti
2014-01-16 13:53   ` Paolo Bonzini [this message]

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=52D7E456.1000806@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pl@dlhnet.de \
    --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.