From: Klaus Jensen Date: Fri, 23 Apr 2021 05:21:26 +0000 (+0200) Subject: hw/block/nvme: fix invalid msix exclusive uninit X-Git-Tag: v6.0.0-rc5~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5351fb7cb2caf81bccbfd5ee4228106cadc56e3c;p=thirdparty%2Fqemu.git hw/block/nvme: fix invalid msix exclusive uninit 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. Additionally, a subregion is added but it is not removed on exit which causes a reference to linger and the drive to never be unlocked. Fixes: 1901b4967c3f ("hw/block/nvme: move msix table and pba to BAR 0") Signed-off-by: Klaus Jensen Reviewed-by: Michael S. Tsirkin Signed-off-by: Peter Maydell --- diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 624a1431d07..5fe082ec34c 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -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[] = {