Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
softmmu/ioport.c: make portio_list MemoryRegions children of MemoryRe…
…gionPortioList Currently when portio_list MemoryRegions are freed using portio_list_destroy() the RCU thread segfaults generating a backtrace similar to that below: #0 0x5555599a34b6 in phys_section_destroy ../softmmu/physmem.c:996 #1 0x5555599a37a3 in phys_sections_free ../softmmu/physmem.c:1011 #2 0x5555599b24aa in address_space_dispatch_free ../softmmu/physmem.c:2430 #3 0x55555996a283 in flatview_destroy ../softmmu/memory.c:292 #4 0x55555a2cb9fb in call_rcu_thread ../util/rcu.c:284 qemu#5 0x55555a29b71d in qemu_thread_start ../util/qemu-thread-posix.c:541 qemu#6 0x7ffff4a0cea6 in start_thread nptl/pthread_create.c:477 qemu#7 0x7ffff492ca2e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xfca2e) The problem here is that portio_list_destroy() unparents the portio_list MemoryRegions causing them to be freed immediately, however the flatview still has a reference to the MemoryRegion and so generates a segfault when the RCU thread updates the flatview. Solve the lifetime issue by making MemoryRegionPortioList a child of the portio_list owner, and attach the portio_list MemoryRegions to the MemoryRegionPortioList instead of to the portio_list owner. This ensures that the MemoryRegionPortioList lifecycle is tied to that of its portio_list MemoryRegions, and allows a finalize() method to be added that can be called by the (delayed) RCU thread to free the MemoryRegions when the flatview is next updated. Since MemoryRegionPortioList is a QOM object with this change the MemoryRegionPortList is now visible in the output of "info qom-tree". As an example the output of "info qom-tree" before and after this commit is shown below: Before: /device[4] (i8257) /dma-chan[0] (memory-region) /dma-cont[0] (memory-region) /dma-page[0] (memory-region) /dma-page[1] (memory-region) /device[5] (i8257) /dma-chan[0] (memory-region) /dma-cont[0] (memory-region) /dma-page[0] (memory-region) /dma-page[1] (memory-region) After: /device[4] (i8257) /dma-chan[0] (memory-region) /dma-cont[0] (memory-region) /portiolist[0] (memory-region-portio-list) /dma-page[0] (memory-region) /portiolist[1] (memory-region-portio-list) /dma-page[0] (memory-region) /device[5] (i8257) /dma-chan[0] (memory-region) /dma-cont[0] (memory-region) /portiolist[0] (memory-region-portio-list) /dma-page[0] (memory-region) /portiolist[1] (memory-region-portio-list) /dma-page[0] (memory-region) Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
- Loading branch information