From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH] ptp_kvm: try to detect hypercall availability Date: Wed, 15 Feb 2017 20:27:20 +0100 Message-ID: <20170215192720.553-1-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, Richard Cochran , Marcelo Tosatti , Paolo Bonzini To: linux@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:54256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210AbdBOT1j (ORCPT ); Wed, 15 Feb 2017 14:27:39 -0500 Sender: kvm-owner@vger.kernel.org List-ID: No point in registering the device if it cannot work. The hypercall does not advertise itself, so we have to call it. Signed-off-by: Radim Krčmář --- drivers/ptp/ptp_kvm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/ptp/ptp_kvm.c b/drivers/ptp/ptp_kvm.c index 0a54e8326a90..0803286ca6b7 100644 --- a/drivers/ptp/ptp_kvm.c +++ b/drivers/ptp/ptp_kvm.c @@ -176,12 +176,19 @@ static void __exit ptp_kvm_exit(void) static int __init ptp_kvm_init(void) { + long ret; + clock_pair_gpa = slow_virt_to_phys(&clock_pair); hv_clock = pvclock_pvti_cpu0_va(); if (!hv_clock) return -ENODEV; + ret = kvm_hypercall2(KVM_HC_CLOCK_PAIRING, clock_pair_gpa, + KVM_CLOCK_PAIRING_WALLCLOCK); + if (ret == -KVM_ENOSYS || ret == -KVM_EOPNOTSUPP) + return -ENODEV: + kvm_ptp_clock.caps = ptp_kvm_caps; kvm_ptp_clock.ptp_clock = ptp_clock_register(&kvm_ptp_clock.caps, NULL); -- 2.11.1