mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
hw: fix regression of smp kernel initialization
In commit "hw: improve cross-cpu synchronization" the implicit safe initialization of the global kernel lock gets unsafe. It is a static object, which is protected by the cxx library regarding its initialization. But our cxx library uses a Genode::semaphore in the contention case of object construction, which implicitly leads to kernel syscalls for blocking the corresponding thread. This behaviour is unacceptable for the kernel code. Therefore, this fix guards the initialization of the kernel code with a simple static boolean value explicitely. Ref #3042 Ref #3043
This commit is contained in:
parent
1ff36965f4
commit
2cf4e5a6de
@ -43,12 +43,24 @@ extern "C" void kernel_init();
|
||||
*/
|
||||
extern "C" void kernel_init()
|
||||
{
|
||||
static volatile bool lock_ready = false;
|
||||
static volatile bool pool_ready = false;
|
||||
static volatile bool kernel_ready = false;
|
||||
|
||||
/**
|
||||
* It is essential to guard the initialization of the data_lock object
|
||||
* in the SMP case, because otherwise the __cxa_guard_aquire of the cxx
|
||||
* library contention path might get called, which ends up in
|
||||
* calling a Semaphore, which will call Kernel::stop_thread() or
|
||||
* Kernel::yield() system-calls in this code
|
||||
*/
|
||||
while (Cpu::executing_id() != Cpu::primary_id() && !lock_ready) { ; }
|
||||
|
||||
{
|
||||
Lock::Guard guard(data_lock());
|
||||
|
||||
lock_ready = true;
|
||||
|
||||
/* initialize current cpu */
|
||||
pool_ready = cpu_pool().initialize(pic());
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user