mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 11:16:57 +00:00
Fiasco.OC: prevent first exception in ldso apps
In applications that use ldso the main_thread_bootstrap() function is called twice which results in the main thread's gate-capability to be inserted twice in the Capability_map which results in an exception. Unfortunately at least on ARM this exception cannot be handled that early, so this commit prevents the exception by checking, whether the capability is inserted already or not. Fixes #164.
This commit is contained in:
parent
9a9f49b65c
commit
76c106dac0
@ -21,15 +21,24 @@
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/utcb.h>
|
||||
#include <l4/sys/kdebug.h>
|
||||
}
|
||||
|
||||
enum { MAIN_THREAD_CAP_ID = 1 };
|
||||
|
||||
static void main_thread_bootstrap() {
|
||||
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE] = MAIN_THREAD_CAP_ID;
|
||||
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = 0;
|
||||
Genode::cap_map()->insert(MAIN_THREAD_CAP_ID, Fiasco::MAIN_THREAD_CAP);
|
||||
/**
|
||||
* Unfortunately ldso calls this function twice. So the second time when
|
||||
* inserting the main thread's gate-capability an exception would be raised.
|
||||
* At least on ARM we got problems when raising an exception that early,
|
||||
* that's why we first check if the cap is already registered before
|
||||
* inserting it.
|
||||
*/
|
||||
Genode::Cap_index *idx = Genode::cap_map()->find(MAIN_THREAD_CAP_ID);
|
||||
if (!idx) {
|
||||
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE] = MAIN_THREAD_CAP_ID;
|
||||
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = 0;
|
||||
Genode::cap_map()->insert(MAIN_THREAD_CAP_ID, Fiasco::MAIN_THREAD_CAP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user