From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751130AbdAUICh (ORCPT ); Sat, 21 Jan 2017 03:02:37 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:32894 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750894AbdAUICc (ORCPT ); Sat, 21 Jan 2017 03:02:32 -0500 Subject: Re: [patch 5/5] PTP: add kvm PTP driver To: Radim Krcmar , Marcelo Tosatti References: <20170120122025.665985919@redhat.com> <20170120122503.842086637@redhat.com> <20170120141255.GA1365@potion> <20170120150025.GB6350@amt.cnet> <20170120180848.GG6291@potion> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Cochran , Miroslav Lichvar From: Paolo Bonzini Message-ID: <0fbe9289-1019-cbda-ce13-3f6dad23f4a6@redhat.com> Date: Sat, 21 Jan 2017 09:02:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170120180848.GG6291@potion> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/01/2017 19:08, Radim Krcmar wrote: > 2017-01-20 13:00-0200, Marcelo Tosatti: >> On Fri, Jan 20, 2017 at 03:12:56PM +0100, Radim Krcmar wrote: >>> 2017-01-20 10:20-0200, Marcelo Tosatti: >>>> + do { >>>> + /* >>>> + * We are measuring the delay between >>>> + * kvm_hypercall and rdtsc using TSC, >>>> + * and converting that delta to >>>> + * tsc_to_system_mul and tsc_shift >>>> + * So any changes to tsc_to_system_mul >>>> + * and tsc_shift in this region >>>> + * invalidate the measurement. >>>> + */ >>>> + version = pvclock_read_begin(src); >>>> + >>>> + ret = kvm_hypercall2(KVM_HC_CLOCK_PAIRING, >>>> + clock_off_gpa, >>>> + KVM_CLOCK_PAIRING_WALLCLOCK); >>>> + if (ret != 0) { >>>> + pr_err("clock offset hypercall ret %lu\n", ret); >>>> + spin_unlock(&kvm_ptp_lock); >>>> + preempt_enable_notrace(); >>>> + return -EOPNOTSUPP; >>>> + } >>>> + >>>> + tspec.tv_sec = clock_off.sec; >>>> + tspec.tv_nsec = clock_off.nsec; >>>> + ret = __pvclock_read_cycles(src, clock_off.tsc); >>>> + flags = src->flags; >>>> + } while (pvclock_read_retry(src, version)); >>>> + >>>> + preempt_enable_notrace(); >>>> + >>>> + system_counter->cycles = ret; >>>> + system_counter->cs = get_kvmclock_cs(); >>> >>> Can't we use clocksource_tsc and just pass the tsc without kvmclock in >>> the middle? >> >> No, it has to be the kvmclock value. > > What happens if the guest switches from kvmclock to tsc? get_device_system_crosststamp handles it, that's why there is a clocksource field in system_counter. Paolo > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >