Re: [RFC PATCH v4 2/2] add support for Hyper-V partition reference time enlightenment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: {
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux