public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation
@ 2023-08-16 17:59 Dexuan Cui
  2023-08-16 18:04 ` Dexuan Cui
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Dexuan Cui @ 2023-08-16 17:59 UTC (permalink / raw)
  To: tglx, jgg, bhelgaas, haiyangz, kw, kys, linux-hyperv, linux-pci,
	lpieralisi, mikelley, robh, wei.liu, helgaas
  Cc: linux-kernel, Dexuan Cui

When a Linux VM with an assigned PCI device runs on Hyper-V, if the PCI
device driver is not loaded yet (i.e. MSI-X/MSI is not enabled on the
device yet), doing a VM hibernation triggers a panic in
hv_pci_restore_msi_msg() -> msi_lock_descs(&pdev->dev), because
pdev->dev.msi.data is still NULL.

Avoid the panic by checking if MSI-X/MSI is enabled.

Fixes: dc2b453290c4 ("PCI: hv: Rework MSI handling")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---

Changes in v2:
    Replaced the test "if (!pdev->dev.msi.data)" with
		      "if (!pdev->msi_enabled && !pdev->msix_enabled)".
      Thanks Michael!
    Updated the changelog accordingly.

 drivers/pci/controller/pci-hyperv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 2d93d0c4f10d..bed3cefdaf19 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -3983,6 +3983,9 @@ static int hv_pci_restore_msi_msg(struct pci_dev *pdev, void *arg)
 	struct msi_desc *entry;
 	int ret = 0;
 
+	if (!pdev->msi_enabled && !pdev->msix_enabled)
+		return 0;
+
 	msi_lock_descs(&pdev->dev);
 	msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
 		irq_data = irq_get_irq_data(entry->irq);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-22 13:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 17:59 [PATCH v2] PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation Dexuan Cui
2023-08-16 18:04 ` Dexuan Cui
2023-08-16 18:12 ` Kuppuswamy Sathyanarayanan
2023-08-16 19:30   ` Dexuan Cui
2023-08-16 19:37     ` Kuppuswamy Sathyanarayanan
2023-08-16 20:10 ` Michael Kelley (LINUX)
2023-08-22  1:22   ` Wei Liu
2023-08-22 13:06 ` Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox