Skip to contentSkip to conversation

xen/arm: gic-v3: Fix redistributor wakeup polling

PATCH In review Luca Fancellu 4 participants 5 messages May 18 – May 22

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: gic-v3: Fix redistributor wakeup polling

gicv3_enable_redist() clears GICR_WAKER.ProcessorSleep and then waits for GICR_WAKER.ChildrenAsleep to clear, as required after waking a redistributor.

However, the polling loop currently uses "while ( timeout )". Since timeout is initially false, the loop runs only once unless the timeout path has already been reached. As a result, Xen can continue before the redistributor has completed wakeup.

Use an unconditional loop, matching the surrounding timeout/break pattern, so the code polls until either ChildrenAsleep is clear or the deadline is reached.

While there, also fix the timeout message. This path polls GICR_WAKER.ChildrenAsleep, not an RWP bit, so "RWP timeout" is misleading.

Fixes bc183a0235e0 ("xen/arm: Add support for GIC v3")
---
 xen/arch/arm/gic-v3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/gic-v3.c +2 -2
index 7f365cdbe9df..bb946dc11375 100644
@@ -828,11 +828,11 @@ static int gicv3_enable_redist(void)
         }
         cpu_relax();
         udelay(1);
-    } while ( timeout );
+    } while ( 1 );
 
     if ( timeout )
     {
-        dprintk(XENLOG_ERR, "GICv3: Redist enable RWP timeout\n");
+        dprintk(XENLOG_ERR, "GICv3: Redist wakeup timeout\n");
         return 1;
     }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 42 lines · Luca Fancellu

gicv3_enable_redist() clears GICR_WAKER.ProcessorSleep and then waits for GICR_WAKER.ChildrenAsleep to clear, as required after waking a redistributor.

However, the polling loop currently uses "while ( timeout )". Since timeout is initially false, the loop runs only once unless the timeout path has already been reached. As a result, Xen can continue before the redistributor has completed wakeup.

Use an unconditional loop, matching the surrounding timeout/break pattern, so the code polls until either ChildrenAsleep is clear or the deadline is reached.

While there, also fix the timeout message. This path polls GICR_WAKER.ChildrenAsleep, not an RWP bit, so "RWP timeout" is misleading.

Fixes bc183a0235e0 ("xen/arm: Add support for GIC v3")
---
 xen/arch/arm/gic-v3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/gic-v3.c +2 -3
index 7f365cdbe9df..bb946dc11375 100644
@@ -828,11 +828,11 @@ static int gicv3_enable_redist(void)
         }
         cpu_relax();
         udelay(1);
-    } while ( timeout );
+    } while ( 1 );
 
     if ( timeout )
     {
-        dprintk(XENLOG_ERR, "GICv3: Redist enable RWP timeout\n");
+        dprintk(XENLOG_ERR, "GICv3: Redist wakeup timeout\n");
         return 1;
     }
 
--
Quoted 3 lines

2.34.1

Best regards,
Mykola

Reviewed-by on v1 1/1
#2 lore raw
In reply to Luca Fancellu
Quoted 13 lines · Luca Fancellu

gicv3_enable_redist() clears GICR_WAKER.ProcessorSleep and then waits for GICR_WAKER.ChildrenAsleep to clear, as required after waking a redistributor.

However, the polling loop currently uses "while ( timeout )". Since timeout is initially false, the loop runs only once unless the timeout path has already been reached. As a result, Xen can continue before the redistributor has completed wakeup.

Use an unconditional loop, matching the surrounding timeout/break pattern, so the code polls until either ChildrenAsleep is clear or the deadline is reached.

Quoted 5 lines

While there, also fix the timeout message. This path polls GICR_WAKER.ChildrenAsleep, not an RWP bit, so "RWP timeout" is misleading.

Fixes bc183a0235e0 ("xen/arm: Add support for GIC v3")

~Michal

#3 lore raw

Oleksii, can we ask for a release ack for this fix?

~Michal

Quoted 26 lines · Michal
Quoted 13 lines · Luca Fancellu

gicv3_enable_redist() clears GICR_WAKER.ProcessorSleep and then waits for GICR_WAKER.ChildrenAsleep to clear, as required after waking a redistributor.

However, the polling loop currently uses "while ( timeout )". Since timeout is initially false, the loop runs only once unless the timeout path has already been reached. As a result, Xen can continue before the redistributor has completed wakeup.

Use an unconditional loop, matching the surrounding timeout/break pattern, so the code polls until either ChildrenAsleep is clear or the deadline is reached.

Quoted 5 lines

While there, also fix the timeout message. This path polls GICR_WAKER.ChildrenAsleep, not an RWP bit, so "RWP timeout" is misleading.

Fixes bc183a0235e0 ("xen/arm: Add support for GIC v3")

~Michal

#4 lore raw
Quoted 27 lines · Michal

Oleksii, can we ask for a release ack for this fix?

~Michal

Quoted 22 lines · Michal
Quoted 13 lines · Luca Fancellu

gicv3_enable_redist() clears GICR_WAKER.ProcessorSleep and then waits for GICR_WAKER.ChildrenAsleep to clear, as required after waking a redistributor.

However, the polling loop currently uses "while ( timeout )". Since timeout is initially false, the loop runs only once unless the timeout path has already been reached. As a result, Xen can continue before the redistributor has completed wakeup.

Use an unconditional loop, matching the surrounding timeout/break pattern, so the code polls until either ChildrenAsleep is clear or the deadline is reached.

Quoted 5 lines

While there, also fix the timeout message. This path polls GICR_WAKER.ChildrenAsleep, not an RWP bit, so "RWP timeout" is misleading.

Fixes bc183a0235e0 ("xen/arm: Add support for GIC v3")

Thanks.

~ Oleksii