hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard
PATCH 1/1 hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard
The allwinner-a10 device uses serial_hds[0] without checking whether it is available or not. So using the cubieboard with -nodefaults currently results in a segmentation fault. Fix it by adding a proper check here.
And while we're at it, mark the device as "user_creatable = false" since this apparently can not directly be used by the users but has to be wired up in code instead.
--- hw/arm/allwinner-a10.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/arm/allwinner-a10.c +6 -2
@@ -109,8 +109,10 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->sata),0 , s->irq[56 ]);/* FIXME use a qdev chardev prop instead of serial_hds[] */ -serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 , s->irq[1 ], -115200 , serial_hds[0 ],DEVICE_NATIVE_ENDIAN ); +if (serial_hds[0 ]) { +serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 , s->irq[1 ], +115200 , serial_hds[0 ],DEVICE_NATIVE_ENDIAN ); + } }static void aw_a10_class_init (ObjectClass *oc,void *data)
@@ -118,6 +120,8 @@ static void aw_a10_class_init(ObjectClass *oc, void *data)DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = aw_a10_realize; +/* Reason: Needs to be wired up in code, see cubieboard_init() */ + dc->user_creatable = false; }static const TypeInfo aw_a10_type_info = {
Signature · 1 line
1.8.3.1
Quoted 18 lines · Thomas Huth
The allwinner-a10 device uses serial_hds[0] without checking whether it is available or not. So using the cubieboard with -nodefaults currently results in a segmentation fault. Fix it by adding a proper check here.
And while we're at it, mark the device as "user_creatable= false" since this apparently can not directly be used by the users but has to be wired up in code instead.Signed-off-by Thomas Huth <[email protected]>--- hw/arm/allwinner-a10.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)hw/arm/allwinner-a10.c +0
-0
hw/arm/allwinner-a10.c static void aw_a10_realize(DeviceState *dev, Error **errp) · line 115
Quoted 9 lines
hw/arm/allwinner-a10.c +4
-2@@ -109,8 +109,10 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->sata),0 , s->irq[56 ]);/* FIXME use a qdev chardev prop instead of serial_hds[] */ -serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 , s->irq[1 ], -115200 , serial_hds[0 ],DEVICE_NATIVE_ENDIAN ); +if (serial_hds[0 ]) { +serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 , s->irq[1 ], +115200 , serial_hds[0 ],DEVICE_NATIVE_ENDIAN ); + }
This doesn't look like the right fix, because it means that there won't be a UART device at that point in system memory at all. What you want is for there to be a UART device there but not connected to anything, ie serial_mm_init() should cope with being passed a NULL Chardev*.
thanks
-- PMM
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Thomas Huth
The allwinner-a10 device uses serial_hds[0] without checking whether it is available or not. So using the cubieboard with -nodefaults currently results in a segmentation fault. Fix it by adding a proper check here.
And while we're at it, mark the device as "user_creatable= false" since this apparently can not directly be used by the users but has to be wired up in code instead.Signed-off-by Thomas Huth <[email protected]>--- hw/arm/allwinner-a10.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)hw/arm/allwinner-a10.c +0
-0@@ -109,8 +109,10 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->sata),0 , s->irq[56 ]);
Quoted 13 lines
hw/arm/allwinner-a10.c static void aw_a10_realize(DeviceState *dev, Error **errp) · line 115
Quoted 7 lines
hw/arm/allwinner-a10.c +4
-2/* FIXME use a qdev chardev prop instead of serial_hds[] */ -serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 , s->irq[1 ], -115200 , serial_hds[0 ],DEVICE_NATIVE_ENDIAN ); +if (serial_hds[0 ]) { +serial_mm_init (get_system_memory (),AW_A10_UART0_REG_BASE ,2 , s->irq[1 ], +115200 , serial_hds[0 ],DEVICE_NATIVE_ENDIAN ); + }This doesn't look like the right fix, because it means that there won't be a UART device at that point in system memory at all. What you want is for there to be a UART device there but not connected to anything, ie
serial_mm_init()should cope with being passed a NULL Chardev*.
OK, makes sense. ... but I guess the patch to fix serial_mm_init() is going to be a bigger patch, since serial_realize_core() currently expects a char device, too, and thus needs to be reworked, too ... I'll try to come up with something when I've got some more spare time...
Thomas