Skip to contentSkip to conversation

serial-pci: remove memory regions from BAR before destroying them

PATCH In review Paolo Bonzini 4 participants 9 messages Jun 25, 2014 – Jul 15, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial-pci: remove memory regions from BAR before destroying them

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021: memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed. Aborted (core dumped)

---
 hw/char/serial-pci.c | 1 +
 1 file changed, 1 insertion(+)
hw/char/serial-pci.c +1 -0
index 6c25296..7340c8d 100644
@@ -148,6 +148,7 @@ static void multi_serial_pci_exit(PCIDevice *dev)
     for (i = 0; i < pci->ports; i++) {
         s = pci->state + i;
         serial_exit_core(s);
+        memory_region_del_subregion(&pci->iobar, &s->io);
         memory_region_destroy(&s->io);
         g_free(pci->name[i]);
     }
Signature · 1 line
1.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021: memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed. Aborted (core dumped)

Would it make sense to add a "must not contain subregions" to memory_region_destroy()'s function comment?

#2 lore raw

Il 26/06/2014 09:32, Markus Armbruster ha scritto:

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Would it make sense to add a "must not contain subregions" to memory_region_destroy()'s function comment?

I don't know, in the end the assertion is pretty self-explanatory. If we add hotplug support to libqos, we can test it.

Paolo

Reviewed-by
#3 lore raw
In reply to Markus Armbruster
Quoted 5 lines · Markus Armbruster
Quoted 3 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

Quoted 9 lines
Quoted 6 lines

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021: memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed. Aborted (core dumped)

Quoted 3 lines

Would it make sense to add a "must not contain subregions" to memory_region_destroy()'s function comment?

Any reason to just not patch the memory region finaliser to unparent all contained subregions automatically rather than assert? Destroying a container should imply removing the subregion relationship and simply orphan the subregion.

Regards,
Peter

#4 lore raw

Il 14/07/2014 14:36, Peter Crosthwaite ha scritto:

Quoted 16 lines · Markus Armbruster
Quoted 5 lines
Quoted 3 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

Quoted 9 lines
Quoted 6 lines

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021: memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed. Aborted (core dumped)

Quoted 7 lines
Quoted 3 lines

Would it make sense to add a "must not contain subregions" to memory_region_destroy()'s function comment?

Any reason to just not patch the memory region finaliser to unparent

Note that unparent for memory regions is _not_ memory_region_del_subregion. It is memory_region_destroy.

The parent object of a memory region is a device; the _container_ of a memory region is another memory region.

Quoted 3 lines

all contained subregions automatically rather than assert? Destroying a container should imply removing the subregion relationship and simply orphan the subregion.

This makes sense since we will soon make memory_region_destroy optional (devices will automatically destroy their memory regions). Before QOMification, however, I think the assert was a useful debugging tool, guaranteeing that owners of memory regions were destroyed in the right order. So we could indeed revisit this in 2.2 and make memory_region_del_subregion also optional.

Paolo

#5 lore raw
Quoted 29 lines · Paolo Bonzini

Il 14/07/2014 14:36, Peter Crosthwaite ha scritto:

Quoted 27 lines
Quoted 12 lines · Markus Armbruster
Quoted 9 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021:
memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
Aborted (core dumped)

Quoted 6 lines
Quoted 2 lines
Quoted 3 lines

Would it make sense to add a "must not contain subregions" to memory_region_destroy()'s function comment?

Quoted 6 lines
Quoted 1 line

Any reason to just not patch the memory region finaliser to unparent

Note that unparent for memory regions is _not_ memory_region_del_subregion. It is memory_region_destroy.

Yes, bad choice of words by me. What I was going for was "un-contain" I guess.

Regards,
Peter

Quoted 18 lines

The parent object of a memory region is a device; the _container_ of a memory region is another memory region.

Quoted 3 lines

all contained subregions automatically rather than assert? Destroying a container should imply removing the subregion relationship and simply orphan the subregion.

This makes sense since we will soon make memory_region_destroy optional (devices will automatically destroy their memory regions). Before QOMification, however, I think the assert was a useful debugging tool, guaranteeing that owners of memory regions were destroyed in the right order. So we could indeed revisit this in 2.2 and make memory_region_del_subregion also optional.

Paolo

#6 lore raw
In reply to Peter Crosthwaite
Quoted 12 lines · Peter Crosthwaite
Quoted 11 lines · Markus Armbruster
Quoted 9 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021:
memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
Aborted (core dumped)

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Nominating for 2.1, just to be explicit.

[...]

#7 lore raw
Quoted 17 lines · Markus Armbruster
Quoted 15 lines · Peter Crosthwaite
Quoted 14 lines · Markus Armbruster
Quoted 11 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021:
memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
Aborted (core dumped)

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Nominating for 2.1, just to be explicit.

[...]

Hmm, is trivial out of service? I remember thinking "Ok, trivial patch, qemu-trivial is cc'ed, that'll pick it up, nothing to do for me."

cheers,
Gerd

PS: Saw paolo sticked the patch into one of his pull requests meanwhile.

#8 lore raw

Il 15/07/2014 10:35, Gerd Hoffmann ha scritto:

Quoted 21 lines · Markus Armbruster
Quoted 20 lines
Quoted 18 lines · Peter Crosthwaite
Quoted 16 lines · Markus Armbruster
Quoted 11 lines · Paolo Bonzini

Otherwise, hot-unplug of pci-serial-2x trips the assertion in memory_region_destroy:

(qemu) device_del gg
(qemu) qemu-system-x86_64: /work/armbru/tmp/qemu/memory.c:1021:
memory_region_destroy: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
Aborted (core dumped)

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Nominating for 2.1, just to be explicit.

[...]

Hmm, is trivial out of service? I remember thinking "Ok, trivial patch, qemu-trivial is cc'ed, that'll pick it up, nothing to do for me."

I think it's more likely that Michael went on vacation, from a quick look at his posting history.

Paolo