Skip to content

Commit

Permalink
ptp_kvm: try to detect hypercall availability
Browse files Browse the repository at this point in the history
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ář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Radim Krčmář authored and Paolo Bonzini committed Feb 16, 2017
1 parent 681bcea commit 4306f20
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/ptp/ptp_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4306f20

Please sign in to comment.