From: Wei Liu <wei.liu@kernel.org>
To: Dexuan Cui <decui@microsoft.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
longli@microsoft.com, lpieralisi@kernel.org,
kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org,
bhelgaas@google.com, linux-hyperv@vger.kernel.org,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Mukesh Rathor <mrathor@linux.microsoft.com>
Subject: Re: [PATCH] Drivers: hv: vmbus: Export hv_vmbus_exists() and use it in pci-hyperv
Date: Tue, 14 Apr 2026 04:43:02 +0000 [thread overview]
Message-ID: <20260414044302.GA2787213@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <20260409215232.399350-1-decui@microsoft.com>
On Thu, Apr 09, 2026 at 02:52:32PM -0700, Dexuan Cui wrote:
> With commit f84b21da3624 ("PCI: hv: Don't load the driver for baremetal root partition"),
> the bare metal Linux root partition won't use the pci-hyperv driver, but
> when a Linux VM runs on the Linux root partition, pci-hyperv's module_init
> function init_hv_pci_drv() can still run, e.g. in the case of
> CONFIG_PCI_HYPERV=y, even if the VMBus driver is not used in such a VM
> (i.e. the hv_vmbus driver's init function returns -ENODEV due to
> vmbus_root_device being NULL).
>
> In such a Linux VM, init_hv_pci_drv() runs with a side effect: the 3
> hvpci_block_ops callbacks are set to functions that depend on hv_vmbus.
>
> Later, when the MLX driver in such a VM invokes the callbacks, e.g. in
> drivers/net/ethernet/mellanox/mlx5/core/lib/hv.c:
> mlx5_hv_register_invalidate(), hvpci_block_ops.reg_blk_invalidate() is
> hv_register_block_invalidate() rather than a NULL function pointer, and
> hv_register_block_invalidate() assumes that it can find a struct
> hv_pcibus_device from pdev->bus->sysdata, which is false in such a VM.
>
> Consequently, hv_register_block_invalidate() -> get_pcichild_wslot() ->
> spin_lock_irqsave() may hang since it can be accessing an invalid
> spinlock pointer.
>
> Fix the issue by exporting hv_vmbus_exists() and using it in pci-hyperv:
>
> hv_root_partition() is true and hv_nested is false ==>
> hv_vmbus_exists() is false.
>
> hv_root_partition() is true and hv_nested is true ==>
> hv_vmbus_exists() is true.
>
> hv_root_partition() is false ==> hv_vmbus_exists() is true.
>
> While at it, rename vmbus_exists() to hv_vmbus_exists() to follow the
> convention that all public functions have the hv_ prefix; also change
> the return value's type from int to bool to make the code more readable;
> also move the two pr_info() calls.
>
> Reported-by: Mukesh Rathor <mrathor@linux.microsoft.com>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
Applied. Thanks.
prev parent reply other threads:[~2026-04-14 4:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 21:52 [PATCH] Drivers: hv: vmbus: Export hv_vmbus_exists() and use it in pci-hyperv Dexuan Cui
2026-04-14 4:43 ` Wei Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260414044302.GA2787213@liuwe-devbox-debian-v2.local \
--to=wei.liu@kernel.org \
--cc=bhelgaas@google.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kwilczynski@kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=mrathor@linux.microsoft.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox