Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56318 )
Change subject: lib/thread: Verify threads are initialized before yielding ......................................................................
lib/thread: Verify threads are initialized before yielding
In hardwaremain.c we call console_init before threads_initialize. Part of setting up the uart requires calling udelay which then calls thread_yield_microseconds. Since threads have not been setup, trying to yield will result in bad things happening. This change guards the thread methods by making current_thread return NULL if the structures have not been initialized.
BUG=b:179699789 TEST=Ramstage no longer hangs with serial enabled
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: If9e1eedfaebe584901d2937c8aa24e158706fa43 --- M src/lib/thread.c 1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/18/56318/1
diff --git a/src/lib/thread.c b/src/lib/thread.c index e2280c6..782a63e 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -9,6 +9,8 @@ #include <thread.h> #include <timer.h>
+static bool initialized; + static void idle_thread_init(void);
/* There needs to be at least one thread to run the ramstate state machine. */ @@ -40,6 +42,9 @@
static inline struct thread *current_thread(void) { + if (!initialized) + return NULL; + return cpu_info_to_thread(cpu_info()); }
@@ -265,6 +270,8 @@ free_thread(t); }
+ initialized = 1; + idle_thread_init(); }