qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard
@ 2017-08-18 17:08 Thomas Huth
  2017-08-18 17:14 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2017-08-18 17:08 UTC (permalink / raw)
  To: Beniamino Galvani, Peter Maydell; +Cc: qemu-arm, qemu-devel, Li Guang

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 <thuth@redhat.com>
---
 hw/arm/allwinner-a10.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index f62a9a3..e152566 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -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 = {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard
  2017-08-18 17:08 [Qemu-devel] [PATCH] hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard Thomas Huth
@ 2017-08-18 17:14 ` Peter Maydell
  2017-08-22 10:07   ` Thomas Huth
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2017-08-18 17:14 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Beniamino Galvani, qemu-arm, QEMU Developers, Li Guang

On 18 August 2017 at 18:08, Thomas Huth <thuth@redhat.com> wrote:
> 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 <thuth@redhat.com>
> ---
>  hw/arm/allwinner-a10.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index f62a9a3..e152566 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard
  2017-08-18 17:14 ` Peter Maydell
@ 2017-08-22 10:07   ` Thomas Huth
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2017-08-22 10:07 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Beniamino Galvani, qemu-arm, QEMU Developers, Li Guang

On 18.08.2017 19:14, Peter Maydell wrote:
> On 18 August 2017 at 18:08, Thomas Huth <thuth@redhat.com> wrote:
>> 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 <thuth@redhat.com>
>> ---
>>  hw/arm/allwinner-a10.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
>> index f62a9a3..e152566 100644
>> --- a/hw/arm/allwinner-a10.c
>> +++ b/hw/arm/allwinner-a10.c
>> @@ -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*.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-22 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18 17:08 [Qemu-devel] [PATCH] hw/arm/allwinner: Fix crash with -nodefaults -M cubieboard Thomas Huth
2017-08-18 17:14 ` Peter Maydell
2017-08-22 10:07   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).