[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/23] s390/sclp: temporarily fix unassignment/reass
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PATCH 13/23] s390/sclp: temporarily fix unassignment/reassignment of memory subregions |
Date: |
Mon, 31 Aug 2015 13:13:53 +0200 |
From: David Hildenbrand <address@hidden>
Commit 374f2981d1f1 ("memory: protect current_map by RCU") broke
unassignment of standby memory on s390x. Looks like that the new
parallelism allows races with our (semi broken) memory hotplug code. The
flatview_unref() can now be executed after our unparenting. Therefore
memory_region_unref() tries to unreference the MemoryRegion itself instead
of the parent.
In theory, MemoryRegions are now bound to separate devices that control
their lifetime. We don't have this yet, so we really want to control their
lifetime manually.
This patch fixes it temporarily, until we have a proper rework. The only
drawback is that they won't pop up in "info qom-tree", but that's better
than qemu crashes.
We have to release the reference to a memory region after a
memory_region_find, as it automatically takes a reference. As we're now
able to reassign memory, the MemoryRegion is in fact deleted (otherwise
vmstate_register_ram() would complain).
Reviewed-by: Matthew Rosato <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/s390x/sclp.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index b3a6c5e..ff29e63 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -217,6 +217,7 @@ static void assign_storage(SCCB *sccb)
(assign_addr >= mhd->padded_ram_size)) {
/* Re-use existing memory region if found */
mr = memory_region_find(sysmem, assign_addr, 1).mr;
+ memory_region_unref(mr);
if (!mr) {
MemoryRegion *standby_ram = g_new(MemoryRegion, 1);
@@ -242,6 +243,11 @@ static void assign_storage(SCCB *sccb)
}
memory_region_init_ram(standby_ram, NULL, id, this_subregion_size,
&error_abort);
+ /* This is a hack to make memory hotunplug work again. Once we have
+ * subdevices, we have to unparent them when unassigning memory,
+ * instead of doing it via the ref count of the MemoryRegion. */
+ object_ref(OBJECT(standby_ram));
+ object_unparent(OBJECT(standby_ram));
vmstate_register_ram_global(standby_ram);
memory_region_add_subregion(sysmem, offset, standby_ram);
}
@@ -269,6 +275,7 @@ static void unassign_storage(SCCB *sccb)
/* find the specified memory region and destroy it */
mr = memory_region_find(sysmem, unassign_addr, 1).mr;
+ memory_region_unref(mr);
if (mr) {
int i;
int is_removable = 1;
@@ -287,8 +294,7 @@ static void unassign_storage(SCCB *sccb)
}
if (is_removable) {
memory_region_del_subregion(sysmem, mr);
- object_unparent(OBJECT(mr));
- g_free(mr);
+ object_unref(OBJECT(mr));
}
}
}
--
2.5.1
- [Qemu-devel] [PATCH 00/23] s390x: further patches, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 01/23] s390x/css: handle ccw-0 TIC correctly, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 05/23] s390x/event-facility: fix location of receive mask, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 02/23] s390x/css: ccw-0 enforces count > 0, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 17/23] s390: no need to manually parse for slots and maxmem, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 03/23] s390x/event-facility: fix receive mask check, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 16/23] s390/sclp: move sclp_service_interrupt into the sclp device, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 13/23] s390/sclp: temporarily fix unassignment/reassignment of memory subregions,
Cornelia Huck <=
- [Qemu-devel] [PATCH 11/23] s390/sclp: rework sclp event facility initialization + device realization, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 08/23] s390x/kvm: make setting of in-kernel irq routes more efficient, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 19/23] s390/sclp: ignore memory hotplug operations if it is disabled, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 07/23] pc-bios/s390-ccw: rebuild image, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 18/23] s390: disallow memory hotplug for the s390-virtio machine, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 14/23] s390/sclp: introduce a root sclp device, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 10/23] sclp/s390: rework sclp cpu hotplug device notification, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 21/23] s390: unify allocation of initial memory, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 06/23] pc-bios/s390-ccw: Device detection in higher subchannel sets, Cornelia Huck, 2015/08/31
- [Qemu-devel] [PATCH 15/23] s390/sclp: move sclp_execute related functions into the SCLP class, Cornelia Huck, 2015/08/31