NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/58335 (Kernel panic when shutting down a virtual machine with Virtio devices)



> Date: Fri, 28 Jun 2024 12:26:43 +0200
> From: Roddy González <roddy.gonzalez.89%gmail.com@localhost>
> 
> I applied the patch and rebuilt. Same results.

Great, thanks!  Unfortunately, I neglected to make it easy to confirm
everything.  Once more, just to be sure it's running the code I
intended to fix -- can you try the attached patch?

No need to test with kern.detachall=1; that's a separate bug.
diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c
index 88afdd5e6d33..95a9fbfdcf47 100644
--- a/sys/dev/pci/virtio_pci.c
+++ b/sys/dev/pci/virtio_pci.c
@@ -178,7 +178,7 @@ static bool	virtio_pci_msix_enabled(struct virtio_pci_softc *);
 
 CFATTACH_DECL3_NEW(virtio_pci, sizeof(struct virtio_pci_softc),
     virtio_pci_match, virtio_pci_attach, virtio_pci_detach, NULL,
-    virtio_pci_rescan, NULL, 0);
+    virtio_pci_rescan, NULL, DVF_DETACH_SHUTDOWN);
 
 static const struct virtio_ops virtio_pci_ops_09 = {
 	.kick = virtio_pci_kick_09,
@@ -374,12 +374,18 @@ virtio_pci_detach(device_t self, int flags)
 		for (i = 0; i < __arraycount(psc->sc_bars_iot); i++) {
 			if (psc->sc_bars_iosize[i] == 0)
 				continue;
+			printf("%s:%d: unmap space %p handle %p size %zu\n",
+			    __func__, __LINE__, psc->sc_bars_iot[i],
+			    psc->sc_bars_ioh[i], psc->sc_bars_iosize[i]);
 			bus_space_unmap(psc->sc_bars_iot[i],
 			    psc->sc_bars_ioh[i], psc->sc_bars_iosize[i]);
 			psc->sc_bars_iosize[i] = 0;
 		}
 	} else {
 		if (psc->sc_iosize) {
+			printf("%s:%d: unmap space %p handle %p size %zu\n",
+			    __func__, __LINE__, psc->sc_iot,
+			    psc->sc_ioh, psc->sc_iosize);
 			bus_space_unmap(psc->sc_iot, psc->sc_ioh,
 			    psc->sc_iosize);
 			psc->sc_iosize = 0;


Home | Main Index | Thread Index | Old Index