diff mbox

[2/3] arm_gic: SGIs for GICD_ICFGR are WI

Message ID 1407056027-7522-3-git-send-email-adam@os.inf.tu-dresden.de
State New
Headers show

Commit Message

Adam Lackorzynski Aug. 3, 2014, 8:53 a.m. UTC
Writes to SGIs for GICD_ICFGR register must be ignored.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 hw/intc/arm_gic.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Christoffer Dall Aug. 15, 2014, 12:07 p.m. UTC | #1
On Sun, Aug 03, 2014 at 10:53:46AM +0200, Adam Lackorzynski wrote:
> Writes to SGIs for GICD_ICFGR register must be ignored.
> 
> Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
> ---
>  hw/intc/arm_gic.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
> index d2b1aaf..cd6e6ea 100644
> --- a/hw/intc/arm_gic.c
> +++ b/hw/intc/arm_gic.c
> @@ -566,10 +566,13 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
>              } else {
>                  GIC_CLEAR_MODEL(irq + i);
>              }
> -            if (value & (2 << (i * 2))) {
> -                GIC_SET_EDGE_TRIGGER(irq + i);
> -            } else {
> -                GIC_CLEAR_EDGE_TRIGGER(irq + i);
> +            /* SGIs are WI */

They're actually WI/RAO, so we should set them to edge-triggered
somewhere or always return 1 for reads of these values as well as part
of this fix.

> +            if (irq >= 16) {
> +                if (value & (2 << (i * 2))) {
> +                    GIC_SET_EDGE_TRIGGER(irq + i);
> +                } else {
> +                    GIC_CLEAR_EDGE_TRIGGER(irq + i);
> +                }
>              }
>          }
>      } else if (offset < 0xf10) {
> -- 
> 2.0.1
> 
>
Adam Lackorzynski Aug. 15, 2014, 12:10 p.m. UTC | #2
On Fri Aug 15, 2014 at 14:07:14 +0200, Christoffer Dall wrote:
> On Sun, Aug 03, 2014 at 10:53:46AM +0200, Adam Lackorzynski wrote:
> > Writes to SGIs for GICD_ICFGR register must be ignored.
> > 
> > Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
> > ---
> >  hw/intc/arm_gic.c | 11 +++++++----
> >  1 file changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
> > index d2b1aaf..cd6e6ea 100644
> > --- a/hw/intc/arm_gic.c
> > +++ b/hw/intc/arm_gic.c
> > @@ -566,10 +566,13 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
> >              } else {
> >                  GIC_CLEAR_MODEL(irq + i);
> >              }
> > -            if (value & (2 << (i * 2))) {
> > -                GIC_SET_EDGE_TRIGGER(irq + i);
> > -            } else {
> > -                GIC_CLEAR_EDGE_TRIGGER(irq + i);
> > +            /* SGIs are WI */
> 
> They're actually WI/RAO, so we should set them to edge-triggered
> somewhere or always return 1 for reads of these values as well as part
> of this fix.

SGIs are initialized to edge triggered in arm_gic_common_reset(), i.e.
this is already the case.
 
> > +            if (irq >= 16) {
> > +                if (value & (2 << (i * 2))) {
> > +                    GIC_SET_EDGE_TRIGGER(irq + i);
> > +                } else {
> > +                    GIC_CLEAR_EDGE_TRIGGER(irq + i);
> > +                }
> >              }
> >          }
> >      } else if (offset < 0xf10) {
> > -- 
> > 2.0.1
> > 
> > 

Adam
Christoffer Dall Aug. 15, 2014, 12:12 p.m. UTC | #3
On Sun, Aug 03, 2014 at 10:53:46AM +0200, Adam Lackorzynski wrote:
> Writes to SGIs for GICD_ICFGR register must be ignored.
> 
> Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
> ---
>  hw/intc/arm_gic.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
> index d2b1aaf..cd6e6ea 100644
> --- a/hw/intc/arm_gic.c
> +++ b/hw/intc/arm_gic.c
> @@ -566,10 +566,13 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
>              } else {
>                  GIC_CLEAR_MODEL(irq + i);
>              }
> -            if (value & (2 << (i * 2))) {
> -                GIC_SET_EDGE_TRIGGER(irq + i);
> -            } else {
> -                GIC_CLEAR_EDGE_TRIGGER(irq + i);
> +            /* SGIs are WI */
> +            if (irq >= 16) {
> +                if (value & (2 << (i * 2))) {
> +                    GIC_SET_EDGE_TRIGGER(irq + i);
> +                } else {
> +                    GIC_CLEAR_EDGE_TRIGGER(irq + i);
> +                }
>              }
>          }
>      } else if (offset < 0xf10) {

Actually, this looks a bit weird given that you do set the model bit,
which should probably be treated as WI/RAZ for a GICv2 emulation, but
you don't set the edge trigger bit for them.

I think a cleaner fix might be to to just change the existing check from
(irq < GIC_INTERNAL) to (irq < GIT_NR_SGIS), then you also don't need
the next patch.

-Christoffer
Adam Lackorzynski Aug. 16, 2014, 7:50 p.m. UTC | #4
On Fri Aug 15, 2014 at 14:12:17 +0200, Christoffer Dall wrote:
> On Sun, Aug 03, 2014 at 10:53:46AM +0200, Adam Lackorzynski wrote:
> > Writes to SGIs for GICD_ICFGR register must be ignored.
> > 
> > Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
> > ---
> >  hw/intc/arm_gic.c | 11 +++++++----
> >  1 file changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
> > index d2b1aaf..cd6e6ea 100644
> > --- a/hw/intc/arm_gic.c
> > +++ b/hw/intc/arm_gic.c
> > @@ -566,10 +566,13 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
> >              } else {
> >                  GIC_CLEAR_MODEL(irq + i);
> >              }
> > -            if (value & (2 << (i * 2))) {
> > -                GIC_SET_EDGE_TRIGGER(irq + i);
> > -            } else {
> > -                GIC_CLEAR_EDGE_TRIGGER(irq + i);
> > +            /* SGIs are WI */
> > +            if (irq >= 16) {
> > +                if (value & (2 << (i * 2))) {
> > +                    GIC_SET_EDGE_TRIGGER(irq + i);
> > +                } else {
> > +                    GIC_CLEAR_EDGE_TRIGGER(irq + i);
> > +                }
> >              }
> >          }
> >      } else if (offset < 0xf10) {
> 
> Actually, this looks a bit weird given that you do set the model bit,
> which should probably be treated as WI/RAZ for a GICv2 emulation, but
> you don't set the edge trigger bit for them.

I've addressed that in a separate patch now. However, I'm not sure got
the revision check right. Comments appreciated!

> I think a cleaner fix might be to to just change the existing check from
> (irq < GIC_INTERNAL) to (irq < GIT_NR_SGIS), then you also don't need
> the next patch.

Ok, new series sent out.



Adam
diff mbox

Patch

diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index d2b1aaf..cd6e6ea 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -566,10 +566,13 @@  static void gic_dist_writeb(void *opaque, hwaddr offset,
             } else {
                 GIC_CLEAR_MODEL(irq + i);
             }
-            if (value & (2 << (i * 2))) {
-                GIC_SET_EDGE_TRIGGER(irq + i);
-            } else {
-                GIC_CLEAR_EDGE_TRIGGER(irq + i);
+            /* SGIs are WI */
+            if (irq >= 16) {
+                if (value & (2 << (i * 2))) {
+                    GIC_SET_EDGE_TRIGGER(irq + i);
+                } else {
+                    GIC_CLEAR_EDGE_TRIGGER(irq + i);
+                }
             }
         }
     } else if (offset < 0xf10) {