[{"id":3677021,"web_url":"http://patchwork.ozlabs.org/comment/3677021/","msgid":"<20260414044302.GA2787213@liuwe-devbox-debian-v2.local>","list_archive_url":null,"date":"2026-04-14T04:43:02","subject":"Re: [PATCH] Drivers: hv: vmbus: Export hv_vmbus_exists() and use it\n in pci-hyperv","submitter":{"id":77234,"url":"http://patchwork.ozlabs.org/api/people/77234/","name":"Wei Liu","email":"wei.liu@kernel.org"},"content":"On Thu, Apr 09, 2026 at 02:52:32PM -0700, Dexuan Cui wrote:\n> With commit f84b21da3624 (\"PCI: hv: Don't load the driver for baremetal root partition\"),\n> the bare metal Linux root partition won't use the pci-hyperv driver, but\n> when a Linux VM runs on the Linux root partition, pci-hyperv's module_init\n> function init_hv_pci_drv() can still run, e.g. in the case of\n> CONFIG_PCI_HYPERV=y, even if the VMBus driver is not used in such a VM\n> (i.e. the hv_vmbus driver's init function returns -ENODEV due to\n> vmbus_root_device being NULL).\n> \n> In such a Linux VM, init_hv_pci_drv() runs with a side effect: the 3\n> hvpci_block_ops callbacks are set to functions that depend on hv_vmbus.\n> \n> Later, when the MLX driver in such a VM invokes the callbacks, e.g. in\n> drivers/net/ethernet/mellanox/mlx5/core/lib/hv.c:\n> mlx5_hv_register_invalidate(), hvpci_block_ops.reg_blk_invalidate() is\n> hv_register_block_invalidate() rather than a NULL function pointer, and\n> hv_register_block_invalidate() assumes that it can find a struct\n> hv_pcibus_device from pdev->bus->sysdata, which is false in such a VM.\n> \n> Consequently, hv_register_block_invalidate() -> get_pcichild_wslot() ->\n> spin_lock_irqsave() may hang since it can be accessing an invalid\n> spinlock pointer.\n> \n> Fix the issue by exporting hv_vmbus_exists() and using it in pci-hyperv:\n> \n>     hv_root_partition() is true and hv_nested is false ==>\n> \thv_vmbus_exists() is false.\n> \n>     hv_root_partition() is true and hv_nested is true ==>\n> \thv_vmbus_exists() is true.\n> \n>     hv_root_partition() is false ==> hv_vmbus_exists() is true.\n> \n> While at it, rename vmbus_exists() to hv_vmbus_exists() to follow the\n> convention that all public functions have the hv_ prefix; also change\n> the return value's type from int to bool to make the code more readable;\n> also move the two pr_info() calls.\n> \n> Reported-by: Mukesh Rathor <mrathor@linux.microsoft.com>\n> Signed-off-by: Dexuan Cui <decui@microsoft.com>\n\nApplied. Thanks.","headers":{"Return-Path":"\n <linux-pci+bounces-52472-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=qYnYqVKg;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52472-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"qYnYqVKg\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvs8s1QYvz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 14:43:09 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 2ABF330401A1\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 04:43:05 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 2DEE92609EE;\n\tTue, 14 Apr 2026 04:43:04 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 07C1923EA94;\n\tTue, 14 Apr 2026 04:43:03 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 7A54AC19425;\n\tTue, 14 Apr 2026 04:43:03 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776141784; cv=none;\n b=JyMzAl2qbj5k4BPS3VOrKph5JyIMSLpMIaYUwtnpmI5f81bxPGyrMrPnlDb83wVH85A20oCu1X3NMeIzvHta/QpD4Umg+mkJCjZUUvjPuegqu+uIuAqAK/qzL1T6md6Q1uQg6JGOK+YWaEA7nrcGVev4jZRsLnyjp3MaMwEsZPY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776141784; c=relaxed/simple;\n\tbh=e/BPH2h+nZPRVrxfRKT1ziyVJ4Lnh+hL6hFNVjHyb8k=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=TN4pHy7RtQTcSA5Hyg0a1zrZXsqakADVirvsjpFPCya/k+oQDT5nsQHznrFJv6mieCFumhBBlFzedCxLloHf0jyBO/q/7MJTzpd3XEClMCJ2wvItoYfURM2oql71dnGq/LyvsSHJOS8g0qzut4dSaA2BLuo5yIvNxS0tfqlXLcA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=qYnYqVKg; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776141783;\n\tbh=e/BPH2h+nZPRVrxfRKT1ziyVJ4Lnh+hL6hFNVjHyb8k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qYnYqVKgzRlGTEeRmTM9EH6dnJi2YNsxoAjpS2mqPMROVogr9MdRvDZhBMCgGjzxv\n\t 5gLFu8fnsUz1AQFWXhrWjySnXxnai2d/ypecJZHQQtcBb4Iyic9SlXozHTv4aEEqJG\n\t x51loIXt7VQNxEciw1h9fWP0RypyyzcSJ+QNb7ViIf2+x5glhkKp0hDfUh0SxTwfNc\n\t 2ZfEhaUXSOFhtg/wW/x6I/CHF29f6dV/tFKcz9z+0i70Y5KpOebnym/wJFPAqJGA20\n\t VO1nGA0PA0Daih/Zv35DD/YgTicmmFklLE9KU7FZDwtJ204sQTSmLYELqLhXF0euT3\n\t xjiTxjGlBuvUA==","Date":"Tue, 14 Apr 2026 04:43:02 +0000","From":"Wei Liu <wei.liu@kernel.org>","To":"Dexuan Cui <decui@microsoft.com>","Cc":"kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,\n\tlongli@microsoft.com, lpieralisi@kernel.org, kwilczynski@kernel.org,\n\tmani@kernel.org, robh@kernel.org, bhelgaas@google.com,\n\tlinux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tMukesh Rathor <mrathor@linux.microsoft.com>","Subject":"Re: [PATCH] Drivers: hv: vmbus: Export hv_vmbus_exists() and use it\n in pci-hyperv","Message-ID":"<20260414044302.GA2787213@liuwe-devbox-debian-v2.local>","References":"<20260409215232.399350-1-decui@microsoft.com>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260409215232.399350-1-decui@microsoft.com>"}}]