[Skiboot] [PATCH 1/4] ipmi: Fix potential infinite loop in sync_msg polling
Nicholas Piggin
npiggin at gmail.com
Sat May 13 22:12:23 AEST 2023
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 at gmail.com>
---
core/ipmi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/core/ipmi.c b/core/ipmi.c
index bbc1a7b6..59aa95fc 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);
--
2.40.1
More information about the Skiboot
mailing list