From bd0595f7f3827d2a402819c9b215a9ceba254972 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Sat, 13 May 2023 22:12:23 +1000 Subject: 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 Reviewed-by: Stewart Smith Signed-off-by: Reza Arbab --- core/ipmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); -- cgit v1.1