Skip to content

Commit db0b034

Browse files
huthkraxel
authored andcommitted
hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices
QEMU crashes with certain targets when trying to show the help output of EHCI devices: $ ./qemu-system-aarch64 -device ich9-usb-ehci1,help qemu-system-aarch64: ../../devel/qemu/softmmu/physmem.c:1154: phys_section_add: Assertion `map->sections_nb < TARGET_PAGE_SIZE' failed. Aborted (core dumped) This happens because the device is doing things at "instance_init" time that should be done at "realize" time instead. So move the related code to the realize() function instead. (NB: This now also matches the memory_region_del_subregion() calls which are done in usb_ehci_unrealize(), and not during finalize()). Suggested-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <20210326095155.1994604-1-thuth@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
1 parent adcf33a commit db0b034

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hw/usb/hcd-ehci.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,6 +2514,11 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
25142514
return;
25152515
}
25162516

2517+
memory_region_add_subregion(&s->mem, s->capsbase, &s->mem_caps);
2518+
memory_region_add_subregion(&s->mem, s->opregbase, &s->mem_opreg);
2519+
memory_region_add_subregion(&s->mem, s->opregbase + s->portscbase,
2520+
&s->mem_ports);
2521+
25172522
usb_bus_new(&s->bus, sizeof(s->bus), s->companion_enable ?
25182523
&ehci_bus_ops_companion : &ehci_bus_ops_standalone, dev);
25192524
for (i = 0; i < s->portnr; i++) {
@@ -2581,11 +2586,6 @@ void usb_ehci_init(EHCIState *s, DeviceState *dev)
25812586
"operational", s->portscbase);
25822587
memory_region_init_io(&s->mem_ports, OBJECT(dev), &ehci_mmio_port_ops, s,
25832588
"ports", 4 * s->portnr);
2584-
2585-
memory_region_add_subregion(&s->mem, s->capsbase, &s->mem_caps);
2586-
memory_region_add_subregion(&s->mem, s->opregbase, &s->mem_opreg);
2587-
memory_region_add_subregion(&s->mem, s->opregbase + s->portscbase,
2588-
&s->mem_ports);
25892589
}
25902590

25912591
void usb_ehci_finalize(EHCIState *s)

0 commit comments

Comments
 (0)