aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2023-05-13 22:12:23 +1000
committerReza Arbab <arbab@linux.ibm.com>2023-06-06 13:32:12 -0500
commitbd0595f7f3827d2a402819c9b215a9ceba254972 (patch)
tree27e31e9b767a92d25c92ec88b578cadd6b41429c
parent1e7dd419df98a948506c918d66007a05a7aebce0 (diff)
downloadskiboot-bd0595f7f3827d2a402819c9b215a9ceba254972.zip
skiboot-bd0595f7f3827d2a402819c9b215a9ceba254972.tar.gz
skiboot-bd0595f7f3827d2a402819c9b215a9ceba254972.tar.bz2
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>
-rw-r--r--core/ipmi.c3
1 files changed, 2 insertions, 1 deletions
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 @@ void ipmi_queue_msg_sync(struct ipmi_msg *msg)
}
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);