Patchwork [v3] hw/arm_gic.c: Fix save/load of irq_target array

login
register
mail settings
Submitter Dmitry Koshelev
Date Oct. 20, 2011, 10:48 a.m.
Message ID <1319107715.4387.11.camel@dierdre>
Download mbox | patch
Permalink /patch/120785/
State New
Headers show

Comments

Dmitry Koshelev - Oct. 20, 2011, 10:48 a.m.
irq_target array saving/loading is in the wrong loop.
Version bump.

Signed-off-by: Dmitry Koshelev <karaghiozis@gmail.com>
---
 hw/arm_gic.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
Andreas Färber - Oct. 21, 2011, 11:42 a.m.
Am 20.10.2011 12:48, schrieb Dmitry Koshelev:
> irq_target array saving/loading is in the wrong loop.
> Version bump.
> 
> Signed-off-by: Dmitry Koshelev <karaghiozis@gmail.com>

Acked-by: Andreas Färber <andreas.faerber@web.de>

Applies cleanly now.

Is there a particular use case that was broken before and works now, or
did this turn up during code review only?

Andreas

> ---
>  hw/arm_gic.c |   16 ++++++++--------
>  1 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/arm_gic.c b/hw/arm_gic.c
> index 83213dd..8dd8742 100644
> --- a/hw/arm_gic.c
> +++ b/hw/arm_gic.c
> @@ -658,9 +658,6 @@ static void gic_save(QEMUFile *f, void *opaque)
>      qemu_put_be32(f, s->enabled);
>      for (i = 0; i < NUM_CPU(s); i++) {
>          qemu_put_be32(f, s->cpu_enabled[i]);
> -#ifndef NVIC
> -        qemu_put_be32(f, s->irq_target[i]);
> -#endif
>          for (j = 0; j < 32; j++)
>              qemu_put_be32(f, s->priority1[j][i]);
>          for (j = 0; j < GIC_NIRQ; j++)
> @@ -674,6 +671,9 @@ static void gic_save(QEMUFile *f, void *opaque)
>          qemu_put_be32(f, s->priority2[i]);
>      }
>      for (i = 0; i < GIC_NIRQ; i++) {
> +#ifndef NVIC
> +        qemu_put_be32(f, s->irq_target[i]);
> +#endif
>          qemu_put_byte(f, s->irq_state[i].enabled);
>          qemu_put_byte(f, s->irq_state[i].pending);
>          qemu_put_byte(f, s->irq_state[i].active);
> @@ -689,15 +689,12 @@ static int gic_load(QEMUFile *f, void *opaque, int version_id)
>      int i;
>      int j;
>  
> -    if (version_id != 1)
> +    if (version_id != 2)
>          return -EINVAL;
>  
>      s->enabled = qemu_get_be32(f);
>      for (i = 0; i < NUM_CPU(s); i++) {
>          s->cpu_enabled[i] = qemu_get_be32(f);
> -#ifndef NVIC
> -        s->irq_target[i] = qemu_get_be32(f);
> -#endif
>          for (j = 0; j < 32; j++)
>              s->priority1[j][i] = qemu_get_be32(f);
>          for (j = 0; j < GIC_NIRQ; j++)
> @@ -711,6 +708,9 @@ static int gic_load(QEMUFile *f, void *opaque, int version_id)
>          s->priority2[i] = qemu_get_be32(f);
>      }
>      for (i = 0; i < GIC_NIRQ; i++) {
> +#ifndef NVIC
> +        s->irq_target[i] = qemu_get_be32(f);
> +#endif
>          s->irq_state[i].enabled = qemu_get_byte(f);
>          s->irq_state[i].pending = qemu_get_byte(f);
>          s->irq_state[i].active = qemu_get_byte(f);
> @@ -739,5 +739,5 @@ static void gic_init(gic_state *s)
>      }
>      memory_region_init_io(&s->iomem, &gic_dist_ops, s, "gic_dist", 0x1000);
>      gic_reset(s);
> -    register_savevm(NULL, "arm_gic", -1, 1, gic_save, gic_load, s);
> +    register_savevm(NULL, "arm_gic", -1, 2, gic_save, gic_load, s);
>  }
Dmitry Koshelev - Oct. 21, 2011, 1:58 p.m.
On Fri, Oct 21, 2011 at 3:42 PM, Andreas Färber <afaerber@suse.de> wrote:
> Am 20.10.2011 12:48, schrieb Dmitry Koshelev:
>> irq_target array saving/loading is in the wrong loop.
>> Version bump.
>>
>> Signed-off-by: Dmitry Koshelev <karaghiozis@gmail.com>
>
> Acked-by: Andreas Färber <andreas.faerber@web.de>
>
> Applies cleanly now.
>
> Is there a particular use case that was broken before and works now, or
> did this turn up during code review only?

There is a use case but it's complicated and involves proprietary software.

>
> Andreas
>
>> ---
>>  hw/arm_gic.c |   16 ++++++++--------
>>  1 files changed, 8 insertions(+), 8 deletions(-)
>>
>> diff --git a/hw/arm_gic.c b/hw/arm_gic.c
>> index 83213dd..8dd8742 100644
>> --- a/hw/arm_gic.c
>> +++ b/hw/arm_gic.c
>> @@ -658,9 +658,6 @@ static void gic_save(QEMUFile *f, void *opaque)
>>      qemu_put_be32(f, s->enabled);
>>      for (i = 0; i < NUM_CPU(s); i++) {
>>          qemu_put_be32(f, s->cpu_enabled[i]);
>> -#ifndef NVIC
>> -        qemu_put_be32(f, s->irq_target[i]);
>> -#endif
>>          for (j = 0; j < 32; j++)
>>              qemu_put_be32(f, s->priority1[j][i]);
>>          for (j = 0; j < GIC_NIRQ; j++)
>> @@ -674,6 +671,9 @@ static void gic_save(QEMUFile *f, void *opaque)
>>          qemu_put_be32(f, s->priority2[i]);
>>      }
>>      for (i = 0; i < GIC_NIRQ; i++) {
>> +#ifndef NVIC
>> +        qemu_put_be32(f, s->irq_target[i]);
>> +#endif
>>          qemu_put_byte(f, s->irq_state[i].enabled);
>>          qemu_put_byte(f, s->irq_state[i].pending);
>>          qemu_put_byte(f, s->irq_state[i].active);
>> @@ -689,15 +689,12 @@ static int gic_load(QEMUFile *f, void *opaque, int version_id)
>>      int i;
>>      int j;
>>
>> -    if (version_id != 1)
>> +    if (version_id != 2)
>>          return -EINVAL;
>>
>>      s->enabled = qemu_get_be32(f);
>>      for (i = 0; i < NUM_CPU(s); i++) {
>>          s->cpu_enabled[i] = qemu_get_be32(f);
>> -#ifndef NVIC
>> -        s->irq_target[i] = qemu_get_be32(f);
>> -#endif
>>          for (j = 0; j < 32; j++)
>>              s->priority1[j][i] = qemu_get_be32(f);
>>          for (j = 0; j < GIC_NIRQ; j++)
>> @@ -711,6 +708,9 @@ static int gic_load(QEMUFile *f, void *opaque, int version_id)
>>          s->priority2[i] = qemu_get_be32(f);
>>      }
>>      for (i = 0; i < GIC_NIRQ; i++) {
>> +#ifndef NVIC
>> +        s->irq_target[i] = qemu_get_be32(f);
>> +#endif
>>          s->irq_state[i].enabled = qemu_get_byte(f);
>>          s->irq_state[i].pending = qemu_get_byte(f);
>>          s->irq_state[i].active = qemu_get_byte(f);
>> @@ -739,5 +739,5 @@ static void gic_init(gic_state *s)
>>      }
>>      memory_region_init_io(&s->iomem, &gic_dist_ops, s, "gic_dist", 0x1000);
>>      gic_reset(s);
>> -    register_savevm(NULL, "arm_gic", -1, 1, gic_save, gic_load, s);
>> +    register_savevm(NULL, "arm_gic", -1, 2, gic_save, gic_load, s);
>>  }
>
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746, AG Nürnberg
>
Andreas Färber - Oct. 21, 2011, 2:22 p.m.
Am 21.10.2011 15:58, schrieb Dmitry Koshelev:
> On Fri, Oct 21, 2011 at 3:42 PM, Andreas Färber <afaerber@suse.de> wrote:
>> Am 20.10.2011 12:48, schrieb Dmitry Koshelev:
>>> irq_target array saving/loading is in the wrong loop.
>>> Version bump.
>>>
>>> Signed-off-by: Dmitry Koshelev <karaghiozis@gmail.com>
>>
>> Acked-by: Andreas Färber <andreas.faerber@web.de>

Ah sorry, habits, should've been:

Acked-by: Andreas Färber <afaerber@suse.de>

>> Is there a particular use case that was broken before and works now, or
>> did this turn up during code review only?
> 
> There is a use case but it's complicated and involves proprietary software.

I see. ;) Was just wondering which -M were affected.

Andreas
andrzej zaborowski - Oct. 21, 2011, 3:08 p.m.
On 20 October 2011 12:48, Dmitry Koshelev <karaghiozis@gmail.com> wrote:
> irq_target array saving/loading is in the wrong loop.
> Version bump.
>
> Signed-off-by: Dmitry Koshelev <karaghiozis@gmail.com>

Thanks, pushed this patch.

Cheers

Patch

diff --git a/hw/arm_gic.c b/hw/arm_gic.c
index 83213dd..8dd8742 100644
--- a/hw/arm_gic.c
+++ b/hw/arm_gic.c
@@ -658,9 +658,6 @@  static void gic_save(QEMUFile *f, void *opaque)
     qemu_put_be32(f, s->enabled);
     for (i = 0; i < NUM_CPU(s); i++) {
         qemu_put_be32(f, s->cpu_enabled[i]);
-#ifndef NVIC
-        qemu_put_be32(f, s->irq_target[i]);
-#endif
         for (j = 0; j < 32; j++)
             qemu_put_be32(f, s->priority1[j][i]);
         for (j = 0; j < GIC_NIRQ; j++)
@@ -674,6 +671,9 @@  static void gic_save(QEMUFile *f, void *opaque)
         qemu_put_be32(f, s->priority2[i]);
     }
     for (i = 0; i < GIC_NIRQ; i++) {
+#ifndef NVIC
+        qemu_put_be32(f, s->irq_target[i]);
+#endif
         qemu_put_byte(f, s->irq_state[i].enabled);
         qemu_put_byte(f, s->irq_state[i].pending);
         qemu_put_byte(f, s->irq_state[i].active);
@@ -689,15 +689,12 @@  static int gic_load(QEMUFile *f, void *opaque, int version_id)
     int i;
     int j;
 
-    if (version_id != 1)
+    if (version_id != 2)
         return -EINVAL;
 
     s->enabled = qemu_get_be32(f);
     for (i = 0; i < NUM_CPU(s); i++) {
         s->cpu_enabled[i] = qemu_get_be32(f);
-#ifndef NVIC
-        s->irq_target[i] = qemu_get_be32(f);
-#endif
         for (j = 0; j < 32; j++)
             s->priority1[j][i] = qemu_get_be32(f);
         for (j = 0; j < GIC_NIRQ; j++)
@@ -711,6 +708,9 @@  static int gic_load(QEMUFile *f, void *opaque, int version_id)
         s->priority2[i] = qemu_get_be32(f);
     }
     for (i = 0; i < GIC_NIRQ; i++) {
+#ifndef NVIC
+        s->irq_target[i] = qemu_get_be32(f);
+#endif
         s->irq_state[i].enabled = qemu_get_byte(f);
         s->irq_state[i].pending = qemu_get_byte(f);
         s->irq_state[i].active = qemu_get_byte(f);
@@ -739,5 +739,5 @@  static void gic_init(gic_state *s)
     }
     memory_region_init_io(&s->iomem, &gic_dist_ops, s, "gic_dist", 0x1000);
     gic_reset(s);
-    register_savevm(NULL, "arm_gic", -1, 1, gic_save, gic_load, s);
+    register_savevm(NULL, "arm_gic", -1, 2, gic_save, gic_load, s);
 }