[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/21] pcie: remove mmconfig memory leak and wrap mmc
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 10/21] pcie: remove mmconfig memory leak and wrap mmconfig update with transaction |
Date: |
Mon, 16 Feb 2015 19:17:51 +0100 |
This memory leak was introduced inadvertently by omitting object_unparent.
A better fix is to use the new memory_region_set_size instead of destroying
and recreating the MMIO region on the fly.
Also, ensure that unmapping and remapping the region is done atomically.
Acked-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/pci/pcie_host.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
index dfb4a2b..d8afba8 100644
--- a/hw/pci/pcie_host.c
+++ b/hw/pci/pcie_host.c
@@ -88,6 +88,8 @@ static void pcie_host_init(Object *obj)
PCIExpressHost *e = PCIE_HOST_BRIDGE(obj);
e->base_addr = PCIE_BASE_ADDR_UNMAPPED;
+ memory_region_init_io(&e->mmio, OBJECT(e), &pcie_mmcfg_ops, e,
"pcie-mmcfg-mmio",
+ PCIE_MMCFG_SIZE_MAX);
}
void pcie_host_mmcfg_unmap(PCIExpressHost *e)
@@ -104,8 +106,7 @@ void pcie_host_mmcfg_init(PCIExpressHost *e, uint32_t size)
assert(size >= PCIE_MMCFG_SIZE_MIN);
assert(size <= PCIE_MMCFG_SIZE_MAX);
e->size = size;
- memory_region_init_io(&e->mmio, OBJECT(e), &pcie_mmcfg_ops, e,
- "pcie-mmcfg", e->size);
+ memory_region_set_size(&e->mmio, e->size);
}
void pcie_host_mmcfg_map(PCIExpressHost *e, hwaddr addr,
@@ -121,10 +122,12 @@ void pcie_host_mmcfg_update(PCIExpressHost *e,
hwaddr addr,
uint32_t size)
{
+ memory_region_transaction_begin();
pcie_host_mmcfg_unmap(e);
if (enable) {
pcie_host_mmcfg_map(e, addr, size);
}
+ memory_region_transaction_commit();
}
static const TypeInfo pcie_host_type_info = {
--
2.3.0
- [Qemu-devel] [PULL 06/21] vhost-scsi: set the bootable value of channel/target/lun, (continued)
- [Qemu-devel] [PULL 06/21] vhost-scsi: set the bootable value of channel/target/lun, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 07/21] rcu: do not let RCU callbacks pile up indefinitely, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 05/21] vhost-scsi: add a property for booting, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 01/21] kvm_stat: Add kvm_exit reasons for aarch64, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 08/21] rcu: run RCU callbacks under the BQL, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 10/21] pcie: remove mmconfig memory leak and wrap mmconfig update with transaction,
Paolo Bonzini <=
[Qemu-devel] [PULL 11/21] pci: split shpc_cleanup and shpc_free, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 12/21] docs: clarify memory region lifecycle, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 14/21] exec: make iotlb RCU-friendly, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 15/21] exec: RCUify AddressSpaceDispatch, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 09/21] memory: keep the owner of the AddressSpace alive until do_address_space_destroy, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 13/21] exec: introduce cpu_reload_memory_map, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 16/21] rcu: introduce RCU-enabled QLIST, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 19/21] cosmetic changes preparing for the following patches, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 20/21] exec: convert ram_list to QLIST, Paolo Bonzini, 2015/02/16
[Qemu-devel] [PULL 21/21] Convert ram_list to RCU, Paolo Bonzini, 2015/02/16