ipmi: Fix potential infinite loop in sync_msg polling
Current gcc with -Os happens to generate code that re-loads the variable
in the loop, but that could change without notice, and with -O2 it does
infinite loop if sync_msg is !NULL, because it is not declared volatile
and there is no compiler barrier in the loop.
Add the usual cpu_relax() there to provide the compiler barrier.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Stewart Smith <stewart@flamingspork.com>
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
diff --git a/core/ipmi.c b/core/ipmi.c
index bbc1a7b..59aa95f 100644
--- a/core/ipmi.c
+++ b/core/ipmi.c
@@ -170,7 +170,8 @@
}
lock(&sync_lock);
- while (sync_msg);
+ while (sync_msg)
+ cpu_relax();
sync_msg = msg;
if (msg->backend->disable_retry && !opal_booting())
msg->backend->disable_retry(msg);