28 Sep, 2022

1 commit

  • [ Upstream commit f0880e2cb7e1f8039a048fdd01ce45ab77247221 ]

    Passed through PCI device sometimes misbehave on Gen1 VMs when Hyper-V
    DRM driver is also loaded. Looking at IOMEM assignment, we can see e.g.

    $ cat /proc/iomem
    ...
    f8000000-fffbffff : PCI Bus 0000:00
    f8000000-fbffffff : 0000:00:08.0
    f8000000-f8001fff : bb8c4f33-2ba2-4808-9f7f-02f3b4da22fe
    ...
    fe0000000-fffffffff : PCI Bus 0000:00
    fe0000000-fe07fffff : bb8c4f33-2ba2-4808-9f7f-02f3b4da22fe
    fe0000000-fe07fffff : 2ba2:00:02.0
    fe0000000-fe07fffff : mlx4_core

    the interesting part is the 'f8000000' region as it is actually the
    VM's framebuffer:

    $ lspci -v
    ...
    0000:00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA (prog-if 00 [VGA controller])
    Flags: bus master, fast devsel, latency 0, IRQ 11
    Memory at f8000000 (32-bit, non-prefetchable) [size=64M]
    ...

    hv_vmbus: registering driver hyperv_drm
    hyperv_drm 5620e0c7-8062-4dce-aeb7-520c7ef76171: [drm] Synthvid Version major 3, minor 5
    hyperv_drm 0000:00:08.0: vgaarb: deactivate vga console
    hyperv_drm 0000:00:08.0: BAR 0: can't reserve [mem 0xf8000000-0xfbffffff]
    hyperv_drm 5620e0c7-8062-4dce-aeb7-520c7ef76171: [drm] Cannot request framebuffer, boot fb still active?

    Note: "Cannot request framebuffer" is not a fatal error in
    hyperv_setup_gen1() as the code assumes there's some other framebuffer
    device there but we actually have some other PCI device (mlx4 in this
    case) config space there!

    The problem appears to be that vmbus_allocate_mmio() can use dedicated
    framebuffer region to serve any MMIO request from any device. The
    semantics one might assume of a parameter named "fb_overlap_ok"
    aren't implemented because !fb_overlap_ok essentially has no effect.
    The existing semantics are really "prefer_fb_overlap". This patch
    implements the expected and needed semantics, which is to not allocate
    from the frame buffer space when !fb_overlap_ok.

    Note, Gen2 VMs are usually unaffected by the issue because
    framebuffer region is already taken by EFI fb (in case kernel supports
    it) but Gen1 VMs may have this region unclaimed by the time Hyper-V PCI
    pass-through driver tries allocating MMIO space if Hyper-V DRM/FB drivers
    load after it. Devices can be brought up in any sequence so let's
    resolve the issue by always ignoring 'fb_mmio' region for non-FB
    requests, even if the region is unclaimed.

    Reviewed-by: Michael Kelley
    Signed-off-by: Vitaly Kuznetsov
    Link: https://lore.kernel.org/r/20220827130345.1320254-4-vkuznets@redhat.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Vitaly Kuznetsov
     

05 Sep, 2022

1 commit

  • commit b3d6dd09ff00fdcf4f7c0cb54700ffd5dd343502 upstream.

    DM_STATUS_REPORT expects the numbers of pages in the unit of 4k pages
    (HV_HYP_PAGE) instead of guest pages, so to make it work when guest page
    sizes are larger than 4k, convert the numbers of guest pages into the
    numbers of HV_HYP_PAGEs.

    Note that the numbers of guest pages are still used for tracing because
    tracing is internal to the guest kernel.

    Reported-by: Vitaly Kuznetsov
    Signed-off-by: Boqun Feng
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20220325023212.1570049-2-boqun.feng@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Greg Kroah-Hartman

    Boqun Feng
     

22 Jun, 2022

1 commit

  • [ Upstream commit 656c5ba50b7172a0ea25dc1b37606bd51d01fe8d ]

    In case of invalid sub channel, release cpu lock before returning.

    Fixes: a949e86c0d780 ("Drivers: hv: vmbus: Resolve race between init_vp_index() and CPU hotplug")
    Signed-off-by: Saurabh Sengar
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/1654794996-13244-1-git-send-email-ssengar@linux.microsoft.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Saurabh Sengar
     

09 Jun, 2022

1 commit

  • [ Upstream commit 82cd4bacff88a11e36f143e2cb950174b09c86c3 ]

    vmbus_request_addr() returns 0 (zero) if the transaction ID passed
    to as argument is 0. This is unfortunate for two reasons: first,
    netvsc_send_completion() does not check for a NULL cmd_rqst (before
    dereferencing the corresponding NVSP message); second, 0 is a *valid*
    value of cmd_rqst in netvsc_send_tx_complete(), cf. the call of
    vmbus_sendpacket() in netvsc_send_pkt().

    vmbus_request_addr() has included the code in question since its
    introduction with commit e8b7db38449ac ("Drivers: hv: vmbus: Add
    vmbus_requestor data structure for VMBus hardening"); such code was
    motivated by the early use of vmbus_requestor by hv_storvsc. Since
    hv_storvsc moved to a tag-based mechanism to generate and retrieve
    transaction IDs with commit bf5fd8cae3c8f ("scsi: storvsc: Use
    blk_mq_unique_tag() to generate requestIDs"), vmbus_request_addr()
    can be modified to return VMBUS_RQST_ERROR if the ID is 0. This
    change solves the issues in hv_netvsc (and makes the handling of
    messages with transaction ID of 0 consistent with the semantics
    "the ID is not contained in the requestor/invalid ID").

    vmbus_next_request_id(), vmbus_request_addr() should still reserve
    the ID of 0 for Hyper-V, because Hyper-V will "ignore" (not respond
    to) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED packets/requests with
    transaction ID of 0 from the guest.

    Fixes: bf5fd8cae3c8f ("scsi: storvsc: Use blk_mq_unique_tag() to generate requestIDs")
    Signed-off-by: Andrea Parri (Microsoft)
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20220419122325.10078-2-parri.andrea@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Andrea Parri (Microsoft)
     

30 May, 2022

1 commit

  • commit 703f7066f40599c290babdb79dd61319264987e9 upstream.

    Since commit
    ee3e00e9e7101 ("random: use registers from interrupted code for CPU's w/o a cycle counter")

    the irq_flags argument is no longer used.

    Remove unused irq_flags.

    Cc: Borislav Petkov
    Cc: Dave Hansen
    Cc: Dexuan Cui
    Cc: H. Peter Anvin
    Cc: Haiyang Zhang
    Cc: Ingo Molnar
    Cc: K. Y. Srinivasan
    Cc: Stephen Hemminger
    Cc: Thomas Gleixner
    Cc: Wei Liu
    Cc: linux-hyperv@vger.kernel.org
    Cc: x86@kernel.org
    Signed-off-by: Sebastian Andrzej Siewior
    Acked-by: Wei Liu
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Andrzej Siewior
     

20 Apr, 2022

3 commits

  • [ Upstream commit be5802795cf8d0b881745fa9ba7790293b382280 ]

    Currently there are known potential issues for balloon and hot-add on
    ARM64:

    * Unballoon requests from Hyper-V should only unballoon ranges
    that are guest page size aligned, otherwise guests cannot handle
    because it's impossible to partially free a page. This is a
    problem when guest page size > 4096 bytes.

    * Memory hot-add requests from Hyper-V should provide the NUMA
    node id of the added ranges or ARM64 should have a functional
    memory_add_physaddr_to_nid(), otherwise the node id is missing
    for add_memory().

    These issues require discussions on design and implementation. In the
    meanwhile, post_status() is working and essential to guest monitoring.
    Therefore instead of disabling the entire hv_balloon driver, the
    ballooning (when page size > 4096 bytes) and hot-add are disabled
    accordingly for now. Once the issues are fixed, they can be re-enable in
    these cases.

    Signed-off-by: Boqun Feng
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20220325023212.1570049-3-boqun.feng@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Boqun Feng
     
  • [ Upstream commit b6cae15b5710c8097aad26a2e5e752c323ee5348 ]

    When reading a packet from a host-to-guest ring buffer, there is no
    memory barrier between reading the write index (to see if there is
    a packet to read) and reading the contents of the packet. The Hyper-V
    host uses store-release when updating the write index to ensure that
    writes of the packet data are completed first. On the guest side,
    the processor can reorder and read the packet data before the write
    index, and sometimes get stale packet data. Getting such stale packet
    data has been observed in a reproducible case in a VM on ARM64.

    Fix this by using virt_load_acquire() to read the write index,
    ensuring that reads of the packet data cannot be reordered
    before it. Preventing such reordering is logically correct, and
    with this change, getting stale data can no longer be reproduced.

    Signed-off-by: Michael Kelley
    Reviewed-by: Andrea Parri (Microsoft)
    Link: https://lore.kernel.org/r/1648394710-33480-1-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Michael Kelley
     
  • [ Upstream commit 9f8b577f7b43b2170628d6c537252785dcc2dcea ]

    hv_panic_page might contain guest-sensitive information, do not dump it
    over to Hyper-V by default in isolated guests.

    While at it, update some comments in hyperv_{panic,die}_event().

    Reported-by: Dexuan Cui
    Signed-off-by: Andrea Parri (Microsoft)
    Reviewed-by: Dexuan Cui
    Link: https://lore.kernel.org/r/20220301141135.2232-1-parri.andrea@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Andrea Parri (Microsoft)
     

14 Apr, 2022

2 commits

  • commit eaa03d34535872d29004cb5cf77dc9dec1ba9a25 upstream.

    Following the recommendation in Documentation/memory-barriers.txt for
    virtual machine guests.

    Fixes: 8b6a877c060ed ("Drivers: hv: vmbus: Replace the per-CPU channel lists with a global array of channels")
    Signed-off-by: Andrea Parri (Microsoft)
    Link: https://lore.kernel.org/r/20220328154457.100872-1-parri.andrea@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Greg Kroah-Hartman

    Andrea Parri (Microsoft)
     
  • [ Upstream commit 792f232d57ff28bbd5f9c4abe0466b23d5879dc8 ]

    The vmbus driver relies on the panic notifier infrastructure to perform
    some operations when a panic event is detected. Since vmbus can be built
    as module, it is required that the driver handles both registering and
    unregistering such panic notifier callback.

    After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback")
    though, the panic notifier registration is done unconditionally in the module
    initialization routine whereas the unregistering procedure is conditionally
    guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability
    is set.

    This patch fixes that by unconditionally unregistering the panic notifier
    in the module's exit routine as well.

    Fixes: 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback")
    Signed-off-by: Guilherme G. Piccoli
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20220315203535.682306-1-gpiccoli@igalia.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Guilherme G. Piccoli
     

08 Apr, 2022

2 commits

  • [ Upstream commit 1d7286729aa616772be334eb908e11f527e1e291 ]

    For a couple of times I have encountered a situation where

    hv_balloon: Unhandled message: type: 12447

    is being flooded over 1 million times per second with various values,
    filling the log and consuming cycles, making debugging difficult.

    Add rate limiting to the message.

    Most other Hyper-V drivers already have similar rate limiting in their
    message callbacks.

    The cause of the floods in my case was probably fixed by 96d9d1fa5cd5
    ("Drivers: hv: balloon: account for vmbus packet header in
    max_pkt_size").

    Fixes: 9aa8b50b2b3d ("Drivers: hv: Add Hyper-V balloon driver")
    Signed-off-by: Anssi Hannula
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20220222141400.98160-1-anssi.hannula@bitwise.fi
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Anssi Hannula
     
  • commit 1dc2f2b81a6a9895da59f3915760f6c0c3074492 upstream.

    The hyperv utilities use PTP clock interfaces and should depend a
    a kconfig symbol such that they will be built as a loadable module or
    builtin so that linker errors do not happen.

    Prevents these build errors:

    ld: drivers/hv/hv_util.o: in function `hv_timesync_deinit':
    hv_util.c:(.text+0x37d): undefined reference to `ptp_clock_unregister'
    ld: drivers/hv/hv_util.o: in function `hv_timesync_init':
    hv_util.c:(.text+0x738): undefined reference to `ptp_clock_register'

    Fixes: 3716a49a81ba ("hv_utils: implement Hyper-V PTP source")
    Signed-off-by: Randy Dunlap
    Reported-by: kernel test robot
    Cc: Arnd Bergmann
    Cc: "K. Y. Srinivasan"
    Cc: Haiyang Zhang
    Cc: Stephen Hemminger
    Cc: Wei Liu
    Cc: Dexuan Cui
    Cc: linux-hyperv@vger.kernel.org
    Cc: Greg Kroah-Hartman
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20211126023316.25184-1-rdunlap@infradead.org
    Signed-off-by: Wei Liu
    Cc: Petr Štetiar
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

23 Feb, 2022

1 commit

  • [ Upstream commit 8bc69f86328e87a0ffa79438430cc82f3aa6a194 ]

    kobject_init_and_add() takes reference even when it fails.
    According to the doc of kobject_init_and_add():

    If this function returns an error, kobject_put() must be called to
    properly clean up the memory associated with the object.

    Fix memory leak by calling kobject_put().

    Fixes: c2e5df616e1a ("vmbus: add per-channel sysfs info")
    Signed-off-by: Miaoqian Lin
    Reviewed-by: Juan Vazquez
    Link: https://lore.kernel.org/r/20220203173008.43480-1-linmq006@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Miaoqian Lin
     

02 Feb, 2022

1 commit

  • [ Upstream commit 96d9d1fa5cd505078534113308ced0aa56d8da58 ]

    Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V
    out of the ring buffer") introduced a notion of maximum packet size in
    vmbus channel and used that size to initialize a buffer holding all
    incoming packet along with their vmbus packet header. hv_balloon uses
    the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches
    its maximum message size, however vmbus_open expects this size to also
    include vmbus packet header. This leads to 4096 bytes
    dm_unballoon_request messages being truncated to 4080 bytes. When the
    driver tries to read next packet it starts from a wrong read_index,
    receives garbage and prints a lot of "Unhandled message: type:
    " in dmesg.

    Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for
    the header.

    Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
    Suggested-by: Michael Kelley (LINUX)
    Suggested-by: Andrea Parri (Microsoft)
    Signed-off-by: Yanming Liu
    Reviewed-by: Michael Kelley
    Reviewed-by: Andrea Parri (Microsoft)
    Link: https://lore.kernel.org/r/20220119202052.3006981-1-yanminglr@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Sasha Levin

    Yanming Liu
     

25 Nov, 2021

1 commit

  • commit 8a7eb2d476c6823cd44d8c25a6230a52417d7ef8 upstream.

    Baihua reported an error when boot an ARM64 guest with PAGE_SIZE=64k and
    BALLOON is enabled:

    hv_vmbus: registering driver hv_balloon
    hv_vmbus: probe failed for device 1eccfd72-4b41-45ef-b73a-4a6e44c12924 (-22)

    The cause of this is that the ringbuffer size for hv_balloon is not
    adjusted with VMBUS_RING_SIZE(), which makes the size not large enough
    for ringbuffers on guest with PAGE_SIZE=64k. Therefore use
    VMBUS_RING_SIZE() to calculate the ringbuffer size. Note that the old
    size (20 * 1024) counts a 4k header in the total size, while
    VMBUS_RING_SIZE() expects the parameter as the payload size, so use
    16 * 1024.

    Cc: # 5.15.x
    Reported-by: Baihua Lu
    Signed-off-by: Boqun Feng
    Tested-by: Vitaly Kuznetsov
    Link: https://lore.kernel.org/r/20211101150026.736124-1-boqun.feng@gmail.com
    Signed-off-by: Wei Liu
    Signed-off-by: Greg Kroah-Hartman

    Boqun Feng
     

23 Oct, 2021

2 commits

  • …ernel/git/hyperv/linux

    Pull hyper-v fix from Wei Liu:

    - Fix vmbus ARM64 build (Arnd Bergmann)

    * tag 'hyperv-fixes-signed-20211022' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    hyperv/vmbus: include linux/bitops.h

    Linus Torvalds
     
  • On arm64 randconfig builds, hyperv sometimes fails with this
    error:

    In file included from drivers/hv/hv_trace.c:3:
    In file included from drivers/hv/hyperv_vmbus.h:16:
    In file included from arch/arm64/include/asm/sync_bitops.h:5:
    arch/arm64/include/asm/bitops.h:11:2: error: only can be included directly
    In file included from include/asm-generic/bitops/hweight.h:5:
    include/asm-generic/bitops/arch_hweight.h:9:9: error: implicit declaration of function '__sw_hweight32' [-Werror,-Wimplicit-function-declaration]
    include/asm-generic/bitops/atomic.h:17:7: error: implicit declaration of function 'BIT_WORD' [-Werror,-Wimplicit-function-declaration]

    Include the correct header first.

    Signed-off-by: Arnd Bergmann
    Link: https://lore.kernel.org/r/20211018131929.2260087-1-arnd@kernel.org
    Signed-off-by: Wei Liu

    Arnd Bergmann
     

16 Sep, 2021

1 commit

  • …ernel/git/hyperv/linux

    Pull hyperv fixes from Wei Liu:

    - Fix kernel crash caused by uio driver (Vitaly Kuznetsov)

    - Remove on-stack cpumask from HV APIC code (Wei Liu)

    * tag 'hyperv-fixes-signed-20210915' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    x86/hyperv: remove on-stack cpumask from hv_send_ipi_mask_allbutself
    asm-generic/hyperv: provide cpumask_to_vpset_noself
    Drivers: hv: vmbus: Fix kernel crash upon unbinding a device from uio_hv_generic driver

    Linus Torvalds
     

03 Sep, 2021

1 commit

  • The following crash happens when a never-used device is unbound from
    uio_hv_generic driver:

    kernel BUG at mm/slub.c:321!
    invalid opcode: 0000 [#1] SMP PTI
    CPU: 0 PID: 4001 Comm: bash Kdump: loaded Tainted: G X --------- --- 5.14.0-0.rc2.23.el9.x86_64 #1
    Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090008 12/07/2018
    RIP: 0010:__slab_free+0x1d5/0x3d0
    ...
    Call Trace:
    ? pick_next_task_fair+0x18e/0x3b0
    ? __cond_resched+0x16/0x40
    ? vunmap_pmd_range.isra.0+0x154/0x1c0
    ? __vunmap+0x22d/0x290
    ? hv_ringbuffer_cleanup+0x36/0x40 [hv_vmbus]
    kfree+0x331/0x380
    ? hv_uio_remove+0x43/0x60 [uio_hv_generic]
    hv_ringbuffer_cleanup+0x36/0x40 [hv_vmbus]
    vmbus_free_ring+0x21/0x60 [hv_vmbus]
    hv_uio_remove+0x4f/0x60 [uio_hv_generic]
    vmbus_remove+0x23/0x30 [hv_vmbus]
    __device_release_driver+0x17a/0x230
    device_driver_detach+0x3c/0xa0
    unbind_store+0x113/0x130
    ...

    The problem appears to be that we free 'ring_info->pkt_buffer' twice:
    first, when the device is unbound from in-kernel driver (netvsc in this
    case) and second from hv_uio_remove(). Normally, ring buffer is supposed
    to be re-initialized from hv_uio_open() but this happens when UIO device
    is being opened and this is not guaranteed to happen.

    Generally, it is OK to call hv_ringbuffer_cleanup() twice for the same
    channel (which is being handed over between in-kernel drivers and UIO) even
    if we didn't call hv_ringbuffer_init() in between. We, however, need to
    avoid kfree() call for an already freed pointer.

    Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
    Signed-off-by: Vitaly Kuznetsov
    Reviewed-by: Andrea Parri
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20210831143916.144983-1-vkuznets@redhat.com
    Signed-off-by: Wei Liu

    Vitaly Kuznetsov
     

02 Sep, 2021

1 commit

  • …rnel/git/hyperv/linux

    Pull hyperv updates from Wei Liu:

    - make Hyper-V code arch-agnostic (Michael Kelley)

    - fix sched_clock behaviour on Hyper-V (Ani Sinha)

    - fix a fault when Linux runs as the root partition on MSHV (Praveen
    Kumar)

    - fix VSS driver (Vitaly Kuznetsov)

    - cleanup (Sonia Sharma)

    * tag 'hyperv-next-signed-20210831' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    hv_utils: Set the maximum packet size for VSS driver to the length of the receive buffer
    Drivers: hv: Enable Hyper-V code to be built on ARM64
    arm64: efi: Export screen_info
    arm64: hyperv: Initialize hypervisor on boot
    arm64: hyperv: Add panic handler
    arm64: hyperv: Add Hyper-V hypercall and register access utilities
    x86/hyperv: fix root partition faults when writing to VP assist page MSR
    hv: hyperv.h: Remove unused inline functions
    drivers: hv: Decouple Hyper-V clock/timer code from VMbus drivers
    x86/hyperv: add comment describing TSC_INVARIANT_CONTROL MSR setting bit 0
    Drivers: hv: Move Hyper-V misc functionality to arch-neutral code
    Drivers: hv: Add arch independent default functions for some Hyper-V handlers
    Drivers: hv: Make portions of Hyper-V init code be arch neutral
    x86/hyperv: fix for unwanted manipulation of sched_clock when TSC marked unstable
    asm-generic/hyperv: Add missing #include of nmi.h

    Linus Torvalds
     

26 Aug, 2021

1 commit

  • Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out
    of the ring buffer") introduced a notion of maximum packet size and for
    KVM and FCOPY drivers set it to the length of the receive buffer. VSS
    driver wasn't updated, this means that the maximum packet size is now
    VMBUS_DEFAULT_MAX_PKT_SIZE (4k). Apparently, this is not enough. I'm
    observing a packet of 6304 bytes which is being truncated to 4096. When
    VSS driver tries to read next packet from ring buffer it starts from the
    wrong offset and receives garbage.

    Set the maximum packet size to 'HV_HYP_PAGE_SIZE * 2' in VSS driver. This
    matches the length of the receive buffer and is in line with other utils
    drivers.

    Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
    Signed-off-by: Vitaly Kuznetsov
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20210825133857.847866-1-vkuznets@redhat.com
    Signed-off-by: Wei Liu

    Vitaly Kuznetsov
     

05 Aug, 2021

1 commit

  • Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on
    ARM64, causing the Hyper-V specific code to be built. Exclude the
    Hyper-V enlightened clocks/timers code from being built for ARM64.

    Signed-off-by: Michael Kelley
    Reviewed-by: Boqun Feng
    Acked-by: Marc Zyngier
    Acked-by: Mark Rutland
    Acked-by: Catalin Marinas
    Link: https://lore.kernel.org/r/1628092359-61351-6-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     

27 Jul, 2021

1 commit


21 Jul, 2021

1 commit

  • The driver core ignores the return value of this callback because there
    is only little it can do when a device disappears.

    This is the final bit of a long lasting cleanup quest where several
    buses were converted to also return void from their remove callback.
    Additionally some resource leaks were fixed that were caused by drivers
    returning an error code in the expectation that the driver won't go
    away.

    With struct bus_type::remove returning void it's prevented that newly
    implemented buses return an ignored error code and so don't anticipate
    wrong expectations for driver authors.

    Reviewed-by: Tom Rix (For fpga)
    Reviewed-by: Mathieu Poirier
    Reviewed-by: Cornelia Huck (For drivers/s390 and drivers/vfio)
    Acked-by: Russell King (Oracle) (For ARM, Amba and related parts)
    Acked-by: Mark Brown
    Acked-by: Chen-Yu Tsai (for sunxi-rsb)
    Acked-by: Pali Rohár
    Acked-by: Mauro Carvalho Chehab (for media)
    Acked-by: Hans de Goede (For drivers/platform)
    Acked-by: Alexandre Belloni
    Acked-By: Vinod Koul
    Acked-by: Juergen Gross (For xen)
    Acked-by: Lee Jones (For mfd)
    Acked-by: Johannes Thumshirn (For mcb)
    Acked-by: Johan Hovold
    Acked-by: Srinivas Kandagatla (For slimbus)
    Acked-by: Kirti Wankhede (For vfio)
    Acked-by: Maximilian Luz
    Acked-by: Heikki Krogerus (For ulpi and typec)
    Acked-by: Samuel Iglesias Gonsálvez (For ipack)
    Acked-by: Geoff Levand (For ps3)
    Acked-by: Yehezkel Bernat (For thunderbolt)
    Acked-by: Alexander Shishkin (For intel_th)
    Acked-by: Dominik Brodowski (For pcmcia)
    Acked-by: Rafael J. Wysocki (For ACPI)
    Acked-by: Bjorn Andersson (rpmsg and apr)
    Acked-by: Srinivas Pandruvada (For intel-ish-hid)
    Acked-by: Dan Williams (For CXL, DAX, and NVDIMM)
    Acked-by: William Breathitt Gray (For isa)
    Acked-by: Stefan Richter (For firewire)
    Acked-by: Benjamin Tissoires (For hid)
    Acked-by: Thorsten Scherer (For siox)
    Acked-by: Sven Van Asbroeck (For anybuss)
    Acked-by: Ulf Hansson (For MMC)
    Acked-by: Wolfram Sang # for I2C
    Acked-by: Sudeep Holla
    Acked-by: Geert Uytterhoeven
    Acked-by: Dmitry Torokhov
    Acked-by: Finn Thain
    Signed-off-by: Uwe Kleine-König
    Link: https://lore.kernel.org/r/20210713193522.1770306-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     

19 Jul, 2021

2 commits

  • The vmbus module uses a rotational algorithm to assign target CPUs to
    a device's channels. Depending on the timing of different device's channel
    offers, different channels of a device may be assigned to the same CPU.

    For example on a VM with 2 CPUs, if NIC A and B's channels are offered
    in the following order, NIC A will have both channels on CPU0, and
    NIC B will have both channels on CPU1 -- see below. This kind of
    assignment causes RSS load that is spreading across different channels
    to end up on the same CPU.

    Timing of channel offers:
    NIC A channel 0
    NIC B channel 0
    NIC A channel 1
    NIC B channel 1

    VMBUS ID 14: Class_ID = {f8615163-df3e-46c5-913f-f2d2f965ed0e} - Synthetic network adapter
    Device_ID = {cab064cd-1f31-47d5-a8b4-9d57e320cccd}
    Sysfs path: /sys/bus/vmbus/devices/cab064cd-1f31-47d5-a8b4-9d57e320cccd
    Rel_ID=14, target_cpu=0
    Rel_ID=17, target_cpu=0

    VMBUS ID 16: Class_ID = {f8615163-df3e-46c5-913f-f2d2f965ed0e} - Synthetic network adapter
    Device_ID = {244225ca-743e-4020-a17d-d7baa13d6cea}
    Sysfs path: /sys/bus/vmbus/devices/244225ca-743e-4020-a17d-d7baa13d6cea
    Rel_ID=16, target_cpu=1
    Rel_ID=18, target_cpu=1

    Update the vmbus CPU assignment algorithm to avoid duplicate CPU
    assignments within a device.

    The new algorithm iterates num_online_cpus + 1 times.
    The existing rotational algorithm to find "next NUMA & CPU" is still here.
    But if the resulting CPU is already used by the same device, it will try
    the next CPU.
    In the last iteration, it assigns the channel to the next available CPU
    like the existing algorithm. This is not normally expected, because
    during device probe, we limit the number of channels of a device to
    be
    Reviewed-by: Michael Kelley
    Tested-by: Michael Kelley
    Link: https://lore.kernel.org/r/1626459673-17420-1-git-send-email-haiyangz@microsoft.com
    Signed-off-by: Wei Liu

    Haiyang Zhang
     
  • Hyper-V clock/timer code in hyperv_timer.c is mostly independent from
    other VMbus drivers, but building for ARM64 without hyperv_timer.c
    shows some remaining entanglements. A default implementation of
    hv_read_reference_counter can just read a Hyper-V synthetic register
    and be independent of hyperv_timer.c, so move this code out and into
    hv_common.c. Then it can be used by the timesync driver even if
    hyperv_timer.c isn't built on a particular architecture. If
    hyperv_timer.c *is* built, it can override with a faster implementation.

    Also provide stubs for stimer functions called by the VMbus driver when
    hyperv_timer.c isn't built.

    No functional changes.

    Signed-off-by: Michael Kelley
    Link: https://lore.kernel.org/r/1626220906-22629-1-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     

15 Jul, 2021

3 commits

  • The check for whether hibernation is possible, and the enabling of
    Hyper-V panic notification during kexec, are both architecture neutral.
    Move the code from under arch/x86 and into drivers/hv/hv_common.c where
    it can also be used for ARM64.

    No functional change.

    Signed-off-by: Michael Kelley
    Link: https://lore.kernel.org/r/1626287687-2045-4-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     
  • Architecture independent Hyper-V code calls various arch-specific handlers
    when needed. To aid in supporting multiple architectures, provide weak
    defaults that can be overridden by arch-specific implementations where
    appropriate. But when arch-specific overrides aren't needed or haven't
    been implemented yet for a particular architecture, these stubs reduce
    the amount of clutter under arch/.

    No functional change.

    Signed-off-by: Michael Kelley
    Link: https://lore.kernel.org/r/1626287687-2045-3-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     
  • The code to allocate and initialize the hv_vp_index array is
    architecture neutral. Similarly, the code to allocate and
    populate the hypercall input and output arg pages is architecture
    neutral. Move both sets of code out from arch/x86 and into
    utility functions in drivers/hv/hv_common.c that can be shared
    by Hyper-V initialization on ARM64.

    No functional changes. However, the allocation of the hypercall
    input and output arg pages is done differently so that the
    size is always the Hyper-V page size, even if not the same as
    the guest page size (such as with ARM64's 64K page size).

    Signed-off-by: Michael Kelley
    Link: https://lore.kernel.org/r/1626287687-2045-2-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     

03 Jul, 2021

1 commit

  • Merge more updates from Andrew Morton:
    "190 patches.

    Subsystems affected by this patch series: mm (hugetlb, userfaultfd,
    vmscan, kconfig, proc, z3fold, zbud, ras, mempolicy, memblock,
    migration, thp, nommu, kconfig, madvise, memory-hotplug, zswap,
    zsmalloc, zram, cleanups, kfence, and hmm), procfs, sysctl, misc,
    core-kernel, lib, lz4, checkpatch, init, kprobes, nilfs2, hfs,
    signals, exec, kcov, selftests, compress/decompress, and ipc"

    * emailed patches from Andrew Morton : (190 commits)
    ipc/util.c: use binary search for max_idx
    ipc/sem.c: use READ_ONCE()/WRITE_ONCE() for use_global_lock
    ipc: use kmalloc for msg_queue and shmid_kernel
    ipc sem: use kvmalloc for sem_undo allocation
    lib/decompressors: remove set but not used variabled 'level'
    selftests/vm/pkeys: exercise x86 XSAVE init state
    selftests/vm/pkeys: refill shadow register after implicit kernel write
    selftests/vm/pkeys: handle negative sys_pkey_alloc() return code
    selftests/vm/pkeys: fix alloc_random_pkey() to make it really, really random
    kcov: add __no_sanitize_coverage to fix noinstr for all architectures
    exec: remove checks in __register_bimfmt()
    x86: signal: don't do sas_ss_reset() until we are certain that sigframe won't be abandoned
    hfsplus: report create_date to kstat.btime
    hfsplus: remove unnecessary oom message
    nilfs2: remove redundant continue statement in a while-loop
    kprobes: remove duplicated strong free_insn_page in x86 and s390
    init: print out unknown kernel parameters
    checkpatch: do not complain about positive return values starting with EPOLL
    checkpatch: improve the indented label test
    checkpatch: scripts/spdxcheck.py now requires python3
    ...

    Linus Torvalds
     

02 Jul, 2021

1 commit

  • kernel.h is being used as a dump for all kinds of stuff for a long time.
    Here is the attempt to start cleaning it up by splitting out panic and
    oops helpers.

    There are several purposes of doing this:
    - dropping dependency in bug.h
    - dropping a loop by moving out panic_notifier.h
    - unload kernel.h from something which has its own domain

    At the same time convert users tree-wide to use new headers, although for
    the time being include new header back to kernel.h to avoid twisted
    indirected includes for existing users.

    [akpm@linux-foundation.org: thread_info.h needs limits.h]
    [andriy.shevchenko@linux.intel.com: ia64 fix]
    Link: https://lkml.kernel.org/r/20210520130557.55277-1-andriy.shevchenko@linux.intel.com

    Link: https://lkml.kernel.org/r/20210511074137.33666-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Bjorn Andersson
    Co-developed-by: Andrew Morton
    Acked-by: Mike Rapoport
    Acked-by: Corey Minyard
    Acked-by: Christian Brauner
    Acked-by: Arnd Bergmann
    Acked-by: Kees Cook
    Acked-by: Wei Liu
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Acked-by: Sebastian Reichel
    Acked-by: Luis Chamberlain
    Acked-by: Stephen Boyd
    Acked-by: Thomas Bogendoerfer
    Acked-by: Helge Deller # parisc
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     

30 Jun, 2021

1 commit

  • …rnel/git/hyperv/linux

    Pull hyperv updates from Wei Liu:
    "Just a few minor enhancement patches and bug fixes"

    * tag 'hyperv-next-signed-20210629' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    PCI: hv: Add check for hyperv_initialized in init_hv_pci_drv()
    Drivers: hv: Move Hyper-V extended capability check to arch neutral code
    drivers: hv: Fix missing error code in vmbus_connect()
    x86/hyperv: fix logical processor creation
    hv_utils: Fix passing zero to 'PTR_ERR' warning
    scsi: storvsc: Use blk_mq_unique_tag() to generate requestIDs
    Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer
    hv_balloon: Remove redundant assignment to region_start

    Linus Torvalds
     

05 Jun, 2021

1 commit

  • The extended capability query code is currently under arch/x86, but it
    is architecture neutral, and is used by arch neutral code in the Hyper-V
    balloon driver. Hence the balloon driver fails to build on other
    architectures.

    Fix by moving the ext cap code out from arch/x86. Because it is also
    called from built-in architecture specific code, it can't be in a module,
    so the Makefile treats as built-in even when CONFIG_HYPERV is "m". Also
    drivers/Makefile is tweaked because this is the first occurrence of a
    Hyper-V file that is built-in even when CONFIG_HYPERV is "m".

    While here, update the hypercall status check to use the new helper
    function instead of open coding. No functional change.

    Signed-off-by: Michael Kelley
    Reviewed-by: Sunil Muthuswamy
    Link: https://lore.kernel.org/r/1622669804-2016-1-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     

02 Jun, 2021

1 commit

  • Eliminate the follow smatch warning:

    drivers/hv/connection.c:236 vmbus_connect() warn: missing error code
    'ret'.

    Reported-by: Abaci Robot
    Signed-off-by: Jiapeng Chong
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/1621940321-72353-1-git-send-email-jiapeng.chong@linux.alibaba.com
    Signed-off-by: Wei Liu

    Jiapeng Chong
     

18 May, 2021

1 commit

  • Sparse warn this:

    drivers/hv/hv_util.c:753 hv_timesync_init() warn:
    passing zero to 'PTR_ERR'

    Use PTR_ERR_OR_ZERO instead of PTR_ERR to fix this.

    Signed-off-by: YueHaibing
    Link: https://lore.kernel.org/r/20210514070116.16800-1-yuehaibing@huawei.com
    [ wei: change %ld to %d ]
    Signed-off-by: Wei Liu

    YueHaibing
     

15 May, 2021

3 commits

  • Use blk_mq_unique_tag() to generate requestIDs for StorVSC, avoiding
    all issues with allocating enough entries in the VMbus requestor.

    Suggested-by: Michael Kelley
    Signed-off-by: Andrea Parri (Microsoft)
    Reviewed-by: Michael Kelley
    Acked-by: Martin K. Petersen
    Link: https://lore.kernel.org/r/20210510210841.370472-1-parri.andrea@gmail.com
    Signed-off-by: Wei Liu

    Andrea Parri (Microsoft)
     
  • Pointers to ring-buffer packets sent by Hyper-V are used within the
    guest VM. Hyper-V can send packets with erroneous values or modify
    packet fields after they are processed by the guest. To defend
    against these scenarios, return a copy of the incoming VMBus packet
    after validating its length and offset fields in hv_pkt_iter_first().
    In this way, the packet can no longer be modified by the host.

    Signed-off-by: Andres Beltran
    Co-developed-by: Andrea Parri (Microsoft)
    Signed-off-by: Andrea Parri (Microsoft)
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/20210408161439.341988-1-parri.andrea@gmail.com
    Signed-off-by: Wei Liu

    Andres Beltran
     
  • Variable region_start is set to pg_start but this value is never
    read as it is overwritten later on, hence it is a redundant
    assignment and can be removed.

    Cleans up the following clang-analyzer warning:

    drivers/hv/hv_balloon.c:1013:3: warning: Value stored to 'region_start'
    is never read [clang-analyzer-deadcode.DeadStores].

    Reported-by: Abaci Robot
    Signed-off-by: Jiapeng Chong
    Link: https://lore.kernel.org/r/1619691681-86256-1-git-send-email-jiapeng.chong@linux.alibaba.com
    Signed-off-by: Wei Liu

    Jiapeng Chong
     

28 Apr, 2021

1 commit

  • Pull printk updates from Petr Mladek:

    - Stop synchronizing kernel log buffer readers by logbuf_lock. As a
    result, the access to the buffer is fully lockless now.

    Note that printk() itself still uses locks because it tries to flush
    the messages to the console immediately. Also the per-CPU temporary
    buffers are still there because they prevent infinite recursion and
    serialize backtraces from NMI. All this is going to change in the
    future.

    - kmsg_dump API rework and cleanup as a side effect of the logbuf_lock
    removal.

    - Make bstr_printf() aware that %pf and %pF formats could deference the
    given pointer.

    - Show also page flags by %pGp format.

    - Clarify the documentation for plain pointer printing.

    - Do not show no_hash_pointers warning multiple times.

    - Update Senozhatsky email address.

    - Some clean up.

    * tag 'printk-for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: (24 commits)
    lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf()
    printk: clarify the documentation for plain pointer printing
    kernel/printk.c: Fixed mundane typos
    printk: rename vprintk_func to vprintk
    vsprintf: dump full information of page flags in pGp
    mm, slub: don't combine pr_err with INFO
    mm, slub: use pGp to print page flags
    MAINTAINERS: update Senozhatsky email address
    lib/vsprintf: do not show no_hash_pointers message multiple times
    printk: console: remove unnecessary safe buffer usage
    printk: kmsg_dump: remove _nolock() variants
    printk: remove logbuf_lock
    printk: introduce a kmsg_dump iterator
    printk: kmsg_dumper: remove @active field
    printk: add syslog_lock
    printk: use atomic64_t for devkmsg_user.seq
    printk: use seqcount_latch for clear_seq
    printk: introduce CONSOLE_LOG_MAX
    printk: consolidate kmsg_dump_get_buffer/syslog_print_all code
    printk: refactor kmsg_dump_get_buffer()
    ...

    Linus Torvalds
     

21 Apr, 2021

1 commit

  • There is not a consistent pattern for checking Hyper-V hypercall status.
    Existing code uses a number of variants. The variants work, but a consistent
    pattern would improve the readability of the code, and be more conformant
    to what the Hyper-V TLFS says about hypercall status.

    Implemented new helper functions hv_result(), hv_result_success(), and
    hv_repcomp(). Changed the places where hv_do_hypercall() and related variants
    are used to use the helper functions.

    Signed-off-by: Joseph Salisbury
    Reviewed-by: Michael Kelley
    Link: https://lore.kernel.org/r/1618620183-9967-2-git-send-email-joseph.salisbury@linux.microsoft.com
    Signed-off-by: Wei Liu

    Joseph Salisbury