15 Oct, 2020

1 commit

  • Pull Hyper-V updates from Wei Liu:

    - a series from Boqun Feng to support page size larger than 4K

    - a few miscellaneous clean-ups

    * tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    hv: clocksource: Add notrace attribute to read_hv_sched_clock_*() functions
    x86/hyperv: Remove aliases with X64 in their name
    PCI: hv: Document missing hv_pci_protocol_negotiation() parameter
    scsi: storvsc: Support PAGE_SIZE larger than 4K
    Driver: hv: util: Use VMBUS_RING_SIZE() for ringbuffer sizes
    HID: hyperv: Use VMBUS_RING_SIZE() for ringbuffer sizes
    Input: hyperv-keyboard: Use VMBUS_RING_SIZE() for ringbuffer sizes
    hv_netvsc: Use HV_HYP_PAGE_SIZE for Hyper-V communication
    hv: hyperv.h: Introduce some hvpfn helper functions
    Drivers: hv: vmbus: Move virt_to_hvpfn() to hyperv header
    Drivers: hv: Use HV_HYP_PAGE in hv_synic_enable_regs()
    Drivers: hv: vmbus: Introduce types of GPADL
    Drivers: hv: vmbus: Move __vmbus_open()
    Drivers: hv: vmbus: Always use HV_HYP_PAGE_SIZE for gpadl
    drivers: hv: remove cast from hyperv_die_event

    Linus Torvalds
     

28 Sep, 2020

1 commit

  • For a Hyper-V vmbus, the size of the ringbuffer has two requirements:

    1) it has to take one PAGE_SIZE for the header

    2) it has to be PAGE_SIZE aligned so that double-mapping can work

    VMBUS_RING_SIZE() could calculate a correct ringbuffer size which
    fulfills both requirements, therefore use it to make sure vmbus work
    when PAGE_SIZE != HV_HYP_PAGE_SIZE (4K).

    Note that since the argument for VMBUS_RING_SIZE() is the size of
    payload (data part), so it will be minus 4k (the size of header when
    PAGE_SIZE = 4k) than the original value to keep the ringbuffer total
    size unchanged when PAGE_SIZE = 4k.

    Signed-off-by: Boqun Feng
    Cc: Michael Kelley
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20200916034817.30282-11-boqun.feng@gmail.com
    Signed-off-by: Wei Liu

    Boqun Feng
     

24 Aug, 2020

2 commits

  • There could be instances where a system stall prevents the timesync
    packets to be consumed. And this might lead to more than one packet
    pending in the ring buffer. Current code empties one packet per callback
    and it might be a stale one. So drain all the packets from ring buffer
    on each callback.

    Signed-off-by: Vineeth Pillai
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20200821152849.99517-1-viremana@linux.microsoft.com
    Signed-off-by: Wei Liu

    Vineeth Pillai
     
  • If for any reason, host timesync messages were not processed by
    the guest, hv_ptp_gettime() returns a stale value and the
    caller (clock_gettime, PTP ioctl etc) has no means to know this
    now. Return an error so that the caller knows about this.

    Signed-off-by: Vineeth Pillai
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20200821152523.99364-1-viremana@linux.microsoft.com
    Signed-off-by: Wei Liu

    Vineeth Pillai
     

03 Feb, 2020

1 commit

  • Pull Hyper-V updates from Sasha Levin:

    - Most of the commits here are work to enable host-initiated
    hibernation support by Dexuan Cui.

    - Fix for a warning shown when host sends non-aligned balloon requests
    by Tianyu Lan.

    * tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    hv_utils: Add the support of hibernation
    hv_utils: Support host-initiated hibernation request
    hv_utils: Support host-initiated restart request
    Tools: hv: Reopen the devices if read() or write() returns errors
    video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.
    Drivers: hv: vmbus: Ignore CHANNELMSG_TL_CONNECT_RESULT(23)
    video: hyperv_fb: Fix hibernation for the deferred IO feature
    Input: hyperv-keyboard: Add the support of hibernation
    hv_balloon: Balloon up according to request page number

    Linus Torvalds
     

27 Jan, 2020

3 commits

  • Add util_pre_suspend() and util_pre_resume() for some hv_utils devices
    (e.g. kvp/vss/fcopy), because they need special handling before
    util_suspend() calls vmbus_close().

    For kvp, all the possible pending work items should be cancelled.

    For vss and fcopy, some extra clean-up needs to be done, i.e. fake a
    THAW message for hv_vss_daemon and fake a CANCEL_FCOPY message for
    hv_fcopy_daemon, otherwise when the VM resums back, the daemons
    can end up in an inconsistent state (i.e. the file systems are
    frozen but will never be thawed; the file transmitted via fcopy
    may not be complete). Note: there is an extra patch for the daemons:
    "Tools: hv: Reopen the devices if read() or write() returns errors",
    because the hv_utils driver can not guarantee the whole transaction
    finishes completely once util_suspend() starts to run (at this time,
    all the userspace processes are frozen).

    util_probe() disables channel->callback_event to avoid the race with
    the channel callback.

    Signed-off-by: Dexuan Cui
    Reviewed-by: Michael Kelley
    Signed-off-by: Sasha Levin

    Dexuan Cui
     
  • Update the Shutdown IC version to 3.2, which is required for the host to
    send the hibernation request.

    The user is expected to create the below udev rule file, which is applied
    upon the host-initiated hibernation request:

    root@localhost:~# cat /usr/lib/udev/rules.d/40-vm-hibernation.rules
    SUBSYSTEM=="vmbus", ACTION=="change", DRIVER=="hv_utils", ENV{EVENT}=="hibernate", RUN+="/usr/bin/systemctl hibernate"

    Signed-off-by: Dexuan Cui
    Reviewed-by: Michael Kelley
    Signed-off-by: Sasha Levin

    Dexuan Cui
     
  • The hv_utils driver currently supports a "shutdown" operation initiated
    from the Hyper-V host. Newer versions of Hyper-V also support a "restart"
    operation. So add support for the updated protocol version that has
    "restart" support, and perform a clean reboot when such a message is
    received from Hyper-V.

    To test the restart functionality, run this PowerShell command on the
    Hyper-V host:

    Restart-VM -Type Reboot

    Signed-off-by: Dexuan Cui
    Reviewed-by: Michael Kelley
    Signed-off-by: Sasha Levin

    Dexuan Cui
     

17 Jan, 2020

1 commit

  • hyperv_timer.c exports hyperv_cs, which is used by stimers and the
    timesync mechanism. However, the clocksource dependency is not
    needed: these mechanisms only depend on the partition reference
    counter (which can be read via a MSR or via the TSC Reference Page).

    Introduce the (function) pointer hv_read_reference_counter, as an
    embodiment of the partition reference counter read, and export it
    in place of the hyperv_cs pointer. The latter can be removed.

    This should clarify that there's no relationship between Hyper-V
    stimers & timesync and the Linux clocksource abstractions. No
    functional or semantic change.

    Suggested-by: Michael Kelley
    Signed-off-by: Andrea Parri
    Reviewed-by: Michael Kelley
    Signed-off-by: Daniel Lezcano
    Link: https://lore.kernel.org/r/20200109160650.16150-2-parri.andrea@gmail.com

    Andrea Parri
     

22 Nov, 2019

2 commits


03 Jul, 2019

1 commit

  • Continue consolidating Hyper-V clock and timer code into an ISA
    independent Hyper-V clocksource driver.

    Move the existing clocksource code under drivers/hv and arch/x86 to the new
    clocksource driver while separating out the ISA dependencies. Update
    Hyper-V initialization to call initialization and cleanup routines since
    the Hyper-V synthetic clock is not independently enumerated in ACPI.

    Update Hyper-V clocksource users in KVM and VDSO to get definitions from
    the new include file.

    No behavior is changed and no new functionality is added.

    Suggested-by: Marc Zyngier
    Signed-off-by: Michael Kelley
    Signed-off-by: Thomas Gleixner
    Reviewed-by: Vitaly Kuznetsov
    Cc: "bp@alien8.de"
    Cc: "will.deacon@arm.com"
    Cc: "catalin.marinas@arm.com"
    Cc: "mark.rutland@arm.com"
    Cc: "linux-arm-kernel@lists.infradead.org"
    Cc: "gregkh@linuxfoundation.org"
    Cc: "linux-hyperv@vger.kernel.org"
    Cc: "olaf@aepfle.de"
    Cc: "apw@canonical.com"
    Cc: "jasowang@redhat.com"
    Cc: "marcelo.cerri@canonical.com"
    Cc: Sunil Muthuswamy
    Cc: KY Srinivasan
    Cc: "sashal@kernel.org"
    Cc: "vincenzo.frascino@arm.com"
    Cc: "linux-arch@vger.kernel.org"
    Cc: "linux-mips@vger.kernel.org"
    Cc: "linux-kselftest@vger.kernel.org"
    Cc: "arnd@arndb.de"
    Cc: "linux@armlinux.org.uk"
    Cc: "ralf@linux-mips.org"
    Cc: "paul.burton@mips.com"
    Cc: "daniel.lezcano@linaro.org"
    Cc: "salyzyn@android.com"
    Cc: "pcc@google.com"
    Cc: "shuah@kernel.org"
    Cc: "0x7f454c46@gmail.com"
    Cc: "linux@rasmusvillemoes.dk"
    Cc: "huw@codeweavers.com"
    Cc: "sfr@canb.auug.org.au"
    Cc: "pbonzini@redhat.com"
    Cc: "rkrcmar@redhat.com"
    Cc: "kvm@vger.kernel.org"
    Link: https://lkml.kernel.org/r/1561955054-1838-3-git-send-email-mikelley@microsoft.com

    Michael Kelley
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms and conditions of the gnu general public license
    version 2 as published by the free software foundation this program
    is distributed in the hope it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to the free
    software foundation inc 59 temple place suite 330 boston ma 02111
    1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 33 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Reviewed-by: Alexios Zavras
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190530000435.254582722@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

12 Nov, 2018

1 commit


03 Jul, 2018

1 commit


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