25 May, 2017

2 commits

  • It was found that ICTIMESYNCFLAG_SYNC packets are handled incorrectly
    on WS2012R2, e.g. after the guest is paused and resumed its time is set
    to something different from host's time. The problem is that we call
    adj_guesttime() with reftime=0 for these old hosts and we don't account
    for that in 'if (adj_flags & ICTIMESYNCFLAG_SYNC)' branch and
    hv_set_host_time().

    While we could've solved this by adding a check like
    'if (ts_srv_version > TS_VERSION_3)' to hv_set_host_time() I prefer
    to do some refactoring. We don't need to have two separate containers
    for host samples, struct host_ts which we use for PTP is enough.

    Throw away 'struct adj_time_work' and create hv_get_adj_host_time()
    accessor to host_ts to avoid code duplication.

    Fixes: 3716a49a81ba ("hv_utils: implement Hyper-V PTP source")
    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • Turns out that our implementation of .getcrosststamp() never actually
    worked. Hyper-V is sending time samples every 5 seconds and this is
    too much for get_device_system_crosststamp() as it's interpolation
    algorithm (which nobody is currently using in kernel, btw) accounts
    for a 'slow' device but we're not slow in Hyper-V, our time reference
    is too far away.

    .getcrosststamp() is not currently used, get_device_system_crosststamp()
    almost always returns -EINVAL and client falls back to using PTP_SYS_OFFSET
    so this patch doesn't change much. I also tried doing interpolation
    manually (e.g. the same way hv_ptp_gettime() works and it turns out that
    we're getting even lower quality:

    PTP_SYS_OFFSET_PRECISE with manual interpolation:
    * PHC0 0 3 37 4 -3974ns[-5338ns] +/- 977ns
    * PHC0 0 3 77 7 +2227ns[+3184ns] +/- 576ns
    * PHC0 0 3 177 10 +3060ns[+5220ns] +/- 548ns
    * PHC0 0 3 377 12 +3937ns[+4371ns] +/- 1414ns
    * PHC0 0 3 377 6 +764ns[+1240ns] +/- 1047ns
    * PHC0 0 3 377 7 -1210ns[-3731ns] +/- 479ns
    * PHC0 0 3 377 9 +153ns[-1019ns] +/- 406ns
    * PHC0 0 3 377 12 -872ns[-1793ns] +/- 443ns
    * PHC0 0 3 377 5 +701ns[+3599ns] +/- 426ns
    * PHC0 0 3 377 5 -923ns[ -375ns] +/- 1062ns

    PTP_SYS_OFFSET:
    * PHC0 0 3 7 5 +72ns[+8020ns] +/- 251ns
    * PHC0 0 3 17 5 -885ns[-3661ns] +/- 254ns
    * PHC0 0 3 37 6 -454ns[-5732ns] +/- 258ns
    * PHC0 0 3 77 10 +1183ns[+3754ns] +/- 164ns
    * PHC0 0 3 377 5 +579ns[+1137ns] +/- 110ns
    * PHC0 0 3 377 7 +501ns[+1064ns] +/- 96ns
    * PHC0 0 3 377 9 +1641ns[+3342ns] +/- 106ns
    * PHC0 0 3 377 8 -47ns[ +77ns] +/- 160ns
    * PHC0 0 3 377 5 +54ns[ +107ns] +/- 102ns
    * PHC0 0 3 377 8 -354ns[ -617ns] +/- 89ns

    This fact wasn't noticed during the initial testing of the PTP device
    somehow but got revealed now. Let's just drop .getcrosststamp()
    implementation for now as it doesn't seem to be suitable for us.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     

16 Mar, 2017

1 commit

  • Without the patch, I always get a "BUG: spinlock bad magic" warning.

    Fixes: 3716a49a81ba ("hv_utils: implement Hyper-V PTP source")

    Signed-off-by: Dexuan Cui
    Cc: Vitaly Kuznetsov
    Cc: "K. Y. Srinivasan"
    Cc: Haiyang Zhang
    Cc: Stephen Hemminger
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Dexuan Cui
     

15 Feb, 2017

1 commit

  • Change the simple boolean batched_reading into a tri-value.
    For future NAPI support in netvsc driver, the callback needs to
    occur directly in interrupt handler.

    Batched mode is also changed to disable host interrupts immediately
    in interrupt routine (to avoid unnecessary host signals), and the
    tasklet is rescheduled if more data is detected.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     

10 Feb, 2017

2 commits

  • Fix a typo.

    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     
  • With TimeSync version 4 protocol support we started updating system time
    continuously through the whole lifetime of Hyper-V guests. Every 5 seconds
    there is a time sample from the host which triggers do_settimeofday[64]().
    While the time from the host is very accurate such adjustments may cause
    issues:
    - Time is jumping forward and backward, some applications may misbehave.
    - In case an NTP server runs in parallel and uses something else for time
    sync (network, PTP,...) system time will never converge.
    - Systemd starts annoying you by printing "Time has been changed" every 5
    seconds to the system log.

    Instead of doing in-kernel time adjustments offload the work to an
    NTP client by exposing TimeSync messages as a PTP device. Users may now
    decide what they want to use as a source.

    I tested the solution with chrony, the config was:

    refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0

    The result I'm seeing is accurate enough, the time delta between the guest
    and the host is almost always within [-10us, +10us], the in-kernel solution
    was giving us comparable results.

    I also tried implementing PPS device instead of PTP by using not currently
    used Hyper-V synthetic timers (we use only one of four for clockevent) but
    with PPS source only chrony wasn't able to give me the required accuracy,
    the delta often more that 100us.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     

31 Jan, 2017

3 commits

  • Log the negotiated IC versions.

    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     
  • Previously, we were assuming that each IC protocol version was tied to a
    specific host version. For example, some Windows 10 preview hosts only
    support v3 TimeSync even though driver assumes v4 is supported by all
    Windows 10 hosts.

    The guest will stop trying to negotiate even though older supported
    versions may still be offered by the host.

    Make IC version negotiation more robust by going through all versions
    that are supported by the guest.

    Fixes: 3da0401b4d0e ("Drivers: hv: utils: Fix the mapping between host
    version and protocol to use")

    Reported-by: Rolf Neugebauer
    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     
  • do_settimeofday() is deprecated, use do_settimeofday64() instead.

    Signed-off-by: Vitaly Kuznetsov
    Acked-by: John Stultz
    Acked-by: Thomas Gleixner
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     

20 Jan, 2017

1 commit


07 Nov, 2016

1 commit


25 Oct, 2016

1 commit

  • The host keeps sending heartbeat packets independent of the
    guest responding to them. Even though we respond to the heartbeat messages at
    interrupt level, we can have situations where there maybe multiple heartbeat
    messages pending that have not been responded to. For instance this occurs when the
    VM is paused and the host continues to send the heartbeat messages.
    Address this issue by draining and responding to all
    the heartbeat messages that maybe pending.

    Signed-off-by: Long Li
    Signed-off-by: K. Y. Srinivasan
    CC: Stable
    Signed-off-by: Greg Kroah-Hartman

    Long Li
     

09 Sep, 2016

1 commit


08 Sep, 2016

3 commits

  • This enables support for more accurate TimeSync v4 samples when hosted
    under Windows Server 2016 and newer hosts.

    The new time samples include a "vmreferencetime" field that represents
    the guest's TSC value when the host generated its time sample. This value
    lets the guest calculate the latency in receiving the time sample. The
    latency is added to the sample host time prior to updating the clock.

    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     
  • Only the first 50 samples after boot were being used to discipline the
    clock. After the first 50 samples, any samples from the host were ignored
    and the guest clock would eventually drift from the host clock.

    This patch allows TimeSync-enabled guests to continuously synchronize the
    clock with the host clock, even after the first 50 samples.

    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     
  • Different Windows host versions may reuse the same protocol version when
    negotiating the TimeSync, Shutdown, and Heartbeat protocols. We should only
    refer to the protocol version to avoid conflating the two concepts.

    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     

02 Mar, 2016

1 commit

  • Pass the channel information to the util drivers that need to defer
    reading the channel while they are processing a request. This would address
    the following issue reported by Vitaly:

    Commit 3cace4a61610 ("Drivers: hv: utils: run polling callback always in
    interrupt context") removed direct *_transaction.state = HVUTIL_READY
    assignments from *_handle_handshake() functions introducing the following
    race: if a userspace daemon connects before we get first non-negotiation
    request from the server hv_poll_channel() won't set transaction state to
    HVUTIL_READY as (!channel) condition will fail, we set it to non-NULL on
    the first real request from the server.

    Signed-off-by: K. Y. Srinivasan
    Reported-by: Vitaly Kuznetsov
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     

02 Mar, 2015

2 commits


10 Jul, 2014

1 commit


19 Feb, 2014

1 commit

  • Implement the file copy service for Linux guests on Hyper-V. This permits the
    host to copy a file (over VMBUS) into the guest. This facility is part of
    "guest integration services" supported on the Windows platform.
    Here is a link that provides additional details on this functionality:

    http://technet.microsoft.com/en-us/library/dn464282.aspx

    In V1 version of the patch I have addressed comments from
    Olaf Hering and Dan Carpenter

    In V2 version of this patch I did some minor cleanup (making some globals
    static). In V4 version of the patch I have addressed all of Olaf's
    most recent set of comments/concerns.

    In V5 version of the patch I had addressed Greg's most recent comments.
    I would like to thank Greg for suggesting that I use misc device; it has
    significantly simplified the code.

    In V6 version of the patch I have cleaned up error message based on Olaf's
    comments. I have also rebased the patch based on the current tip.

    In this version of the patch, I have addressed the latest comments from Greg.

    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     

30 Sep, 2013

1 commit


27 Sep, 2013

1 commit

  • The current code does not correctly negotiate the version numbers for the util
    driver when hosted on earlier hosts. The version numbers presented by this
    driver were not compatible with the version numbers supported by Windows Server
    2008. Fix this problem.

    I would like to thank Olaf Hering (ohering@suse.com) for identifying the problem.

    Reported-by: Olaf Hering
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     

26 Sep, 2013

1 commit

  • The variable execute_shutdown is only assigned the values true and
    false. Change its type to bool.

    The simplified semantic patch that find this problem is as
    follows (http://coccinelle.lip6.fr/):

    @exists@
    type T;
    identifier b;
    @@
    - T
    + bool
    b = ...;
    ... when any
    b = \(true\|false\)

    Signed-off-by: Peter Senna Tschudin
    Signed-off-by: Greg Kroah-Hartman

    Peter Senna Tschudin
     

02 Aug, 2013

1 commit

  • Remove HV_DRV_VERSION, it has no meaning for upstream drivers.

    Initially it was supposed to show the "Linux Integration Services"
    version, now it is not in sync anymore with the out-of-tree drivers
    available from the MSFT website.

    The only place where a version string is still required is the KVP
    command "IntegrationServicesVersion" which is handled by
    tools/hv/hv_kvp_daemon.c. To satisfy such KVP request from the host pass
    the current string to the daemon during KVP userland registration.

    Signed-off-by: Olaf Hering
    Acked-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Olaf Hering
     

27 Jul, 2013

1 commit


16 Mar, 2013

1 commit

  • This driver supports host initiated backup of the guest. On Windows guests,
    the host can generate application consistent backups using the Windows VSS
    framework. On Linux, we ensure that the backup will be file system consistent.
    This driver allows the host to initiate a "Freeze" operation on all the mounted
    file systems in the guest. Once the mounted file systems in the guest are frozen,
    the host snapshots the guest's file systems. Once this is done, the guest's file
    systems are "thawed".

    This driver has a user-level component (daemon) that invokes the appropriate
    operation on all the mounted file systems in response to the requests from
    the host. The duration for which the guest is frozen is very short - a few seconds.
    During this interval, the diff disk is comitted.

    In this version of the patch I have addressed the feedback from Olaf Herring.
    Also, some of the connector related issues have been fixed.

    Signed-off-by: K. Y. Srinivasan
    Reviewed-by: Haiyang Zhang
    Cc: Evgeniy Polyakov
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     

26 Jan, 2013

2 commits


18 Jan, 2013

1 commit


17 Aug, 2012

1 commit


14 May, 2012

1 commit


03 Feb, 2012

1 commit


11 Oct, 2011

2 commits