Skip to contentSkip to conversation

hw/block/nvme: fix msix uninit

PATCH Superseded Klaus Jensen 2 participants 6 messages Apr 22, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hw/block/nvme: fix msix uninit

From: Klaus Jensen <[email protected]>

Hi Peter,

The commit message on the patch describes the issue. This is a QEMU crashing bug in -rc4 that I introduced early in the cycle and never found in time. Lack of testing device hotplugging is the cause for that.

I'm not sure what to say other than I'm terribly sorry for introducing this and if this means an -rc5 needs to be rolled, then I'm even more sorry.

I think an acceptance test could have caught this, and I am already working on an acceptance test suite for the nvme device, so I'll add something that test this as well. But, well, it doesn't help now.

Klaus Jensen (1):
hw/block/nvme: fix invalid msix exclusive uninit

 hw/block/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 hw/block/nvme: fix invalid msix exclusive uninit

From: Klaus Jensen <[email protected]>

Commit 1901b4967c3f changed the nvme device from using a bar exclusive for MSI-x to sharing it on bar0.

Unfortunately, the msix_uninit_exclusive_bar() call remains in nvme_exit() which causes havoc when the device is removed with, say, device_del.

Fix this.

Fixes 1901b4967c3f ("hw/block/nvme: move msix table and pba to BAR 0")
---
 hw/block/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/nvme.c +1 -1
index 624a1431d072..31a1a59d88c9 100644
@@ -6235,7 +6235,7 @@ static void nvme_exit(PCIDevice *pci_dev)
     if (n->pmr.dev) {
         host_memory_backend_set_mapped(n->pmr.dev, false);
     }
-    msix_uninit_exclusive_bar(pci_dev);
+    msix_uninit(pci_dev, &n->bar0, &n->bar0);
 }
 
 static Property nvme_props[] = {
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH for-6.0? 1/1] hw/block/nvme: fix invalid msix exclusive uninit

Quoted 33 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Commit 1901b4967c3f changed the nvme device from using a bar exclusive for MSI-x to sharing it on bar0.

Unfortunately, the msix_uninit_exclusive_bar() call remains in nvme_exit() which causes havoc when the device is removed with, say, device_del.

Fix this.

Fixes 1901b4967c3f ("hw/block/nvme: move msix table and pba to BAR 0")

---
hw/block/nvme.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/nvme.c +1 -1
index 624a1431d072..31a1a59d88c9 100644
@@ -6235,7 +6235,7 @@ static void nvme_exit(PCIDevice *pci_dev)
    if (n->pmr.dev) {
        host_memory_backend_set_mapped(n->pmr.dev, false);
    }
-    msix_uninit_exclusive_bar(pci_dev);
+    msix_uninit(pci_dev, &n->bar0, &n->bar0);
 }
 
 static Property nvme_props[] = {
Signature · 1 line
2.31.1

Having investigated more, the proper fix must also delete the subregion that 1901b4967c3f introduced. Otherwise a reference lingers, causing the attached drive to never be "unlocked".

my_bad_counter++;

I found this screw-up while investigating Bug 1925496, so credit to Oguz Bektas for reporting this!

hw/block/nvme.c +2 -1
index 624a1431d072..5fe082ec34c5 100644
@@ -6235,7 +6235,8 @@ static void nvme_exit(PCIDevice *pci_dev)
     if (n->pmr.dev) {
         host_memory_backend_set_mapped(n->pmr.dev, false);
     }
-    msix_uninit_exclusive_bar(pci_dev);
+    msix_uninit(pci_dev, &n->bar0, &n->bar0);
+    memory_region_del_subregion(&n->bar0, &n->iomem);
 }
 
 static Property nvme_props[] = {
#3 lore raw
In reply to Klaus Jensen
Quoted 16 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Hi Peter,

The commit message on the patch describes the issue. This is a QEMU crashing bug in -rc4 that I introduced early in the cycle and never found in time. Lack of testing device hotplugging is the cause for that.

I'm not sure what to say other than I'm terribly sorry for introducing this and if this means an -rc5 needs to be rolled, then I'm even more sorry.

I think an acceptance test could have caught this, and I am already working on an acceptance test suite for the nvme device, so I'll add something that test this as well. But, well, it doesn't help now.

Quoted 10 lines

Klaus Jensen (1):
hw/block/nvme: fix invalid msix exclusive uninit

hw/block/nvme.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.31.1

As far as I can tell, to cause this crash, monitor access is required, so I am not sure if we can get away with a note on this in the release notes and fix this in a potential stable release or next.

#4 lore raw
Quoted 14 lines · Klaus Jensen
Quoted 12 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Hi Peter,

The commit message on the patch describes the issue. This is a QEMU crashing bug in -rc4 that I introduced early in the cycle and never found in time. Lack of testing device hotplugging is the cause for that.

I'm not sure what to say other than I'm terribly sorry for introducing this and if this means an -rc5 needs to be rolled, then I'm even more sorry.

Quoted 7 lines
Quoted 3 lines

I think an acceptance test could have caught this, and I am already working on an acceptance test suite for the nvme device, so I'll add something that test this as well. But, well, it doesn't help now.

As far as I can tell, to cause this crash, monitor access is required, so I am not sure if we can get away with a note on this in the release notes and fix this in a potential stable release or next.

Is this a regression since 5.2 ?

thanks
-- PMM

#5 lore raw
Quoted 19 lines · Peter Maydell
Quoted 17 lines · Klaus Jensen
Quoted 15 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Hi Peter,

The commit message on the patch describes the issue. This is a QEMU crashing bug in -rc4 that I introduced early in the cycle and never found in time. Lack of testing device hotplugging is the cause for that.

I'm not sure what to say other than I'm terribly sorry for introducing this and if this means an -rc5 needs to be rolled, then I'm even more sorry.

I think an acceptance test could have caught this, and I am already working on an acceptance test suite for the nvme device, so I'll add something that test this as well. But, well, it doesn't help now.

Quoted 6 lines
Quoted 3 lines

As far as I can tell, to cause this crash, monitor access is required, so I am not sure if we can get away with a note on this in the release notes and fix this in a potential stable release or next.

Is this a regression since 5.2 ?

Yes.