From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJiUE-0007KH-UZ for qemu-devel@nongnu.org; Mon, 27 Jul 2015 09:30:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJiU9-0005Ay-SF for qemu-devel@nongnu.org; Mon, 27 Jul 2015 09:30:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJiU9-0005Aj-NK for qemu-devel@nongnu.org; Mon, 27 Jul 2015 09:30:29 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 637F73C200 for ; Mon, 27 Jul 2015 13:30:29 +0000 (UTC) References: <1438003477-5769-1-git-send-email-mst@redhat.com> From: Paolo Bonzini Message-ID: <55B63273.5080509@redhat.com> Date: Mon, 27 Jul 2015 15:30:27 +0200 MIME-Version: 1.0 In-Reply-To: <1438003477-5769-1-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-pci: fix memory MR cleanup for modern List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org On 27/07/2015 15:24, Michael S. Tsirkin wrote: > +static void virtio_pci_modern_region_unmap(VirtIOPCIProxy *proxy, > + VirtIOPCIRegion *region) > +{ > + memory_region_del_subregion(&proxy->modern_bar, > + ®ion->mr); > +} > + > /* This is called by virtio-bus just after the device is plugged. */ > static void virtio_pci_device_plugged(DeviceState *d, Error **errp) > { > @@ -1520,8 +1527,16 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) > static void virtio_pci_device_unplugged(DeviceState *d) > { > VirtIOPCIProxy *proxy = VIRTIO_PCI(d); > + bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN); > > virtio_pci_stop_ioeventfd(proxy); > + > + if (modern) { > + virtio_pci_modern_region_unmap(proxy, &proxy->common); > + virtio_pci_modern_region_unmap(proxy, &proxy->isr); > + virtio_pci_modern_region_unmap(proxy, &proxy->device); > + virtio_pci_modern_region_unmap(proxy, &proxy->notify); > + } > } Actually this is not necessary. memory_region_del_subregion is only needed inasmuch as it prevents further guest access to the region, so it's enough that the toplevel region (the modern_bar itself) is unmapped. The PCI core does that automatically. That said, it's polite to unmap everything, so if you want this patch: Reviewed-by: Paolo Bonzini Paolo