nova: set page fault handler for core threads

Ease debugging if a core thread fail.
This commit is contained in:
Alexander Boettcher 2012-11-30 16:18:55 +01:00 committed by Norman Feske
parent 2426030c5b
commit cef9af1978
3 changed files with 29 additions and 8 deletions

View File

@ -227,13 +227,16 @@ Pager_object::Pager_object(unsigned long badge)
}
}
/* threads in core get default page fault handler assigned, revoke it */
if (_tid.ec_sel != Native_thread::INVALID_INDEX)
revoke(Obj_crd(exc_pt_sel() + PT_SEL_PAGE_FAULT, 0));
/* create portal for page-fault handler */
res = create_pt(exc_pt_sel() + PT_SEL_PAGE_FAULT, pd_sel,
_tid.ec_sel, Mtd(Mtd::QUAL | Mtd::EIP),
(mword_t)_page_fault_handler);
if (res) {
PERR("could not create page-fault portal, error = %u\n",
res);
PERR("could not create page-fault portal, error = %u\n", res);
class Create_page_fault_pt_failed { };
throw Create_page_fault_pt_failed();
}

View File

@ -75,10 +75,21 @@ class Irq_thread : public Thread_base
throw Cpu_session::Thread_creation_failed();
}
/* map startup portal from main thread */
map_local((Utcb *)Thread_base::myself()->utcb(),
Obj_crd(PT_SEL_STARTUP, 0),
Obj_crd(_tid.exc_pt_sel + PT_SEL_STARTUP, 0));
/* remap startup portal from main thread */
if (map_local((Utcb *)Thread_base::myself()->utcb(),
Obj_crd(PT_SEL_STARTUP, 0),
Obj_crd(_tid.exc_pt_sel + PT_SEL_STARTUP, 0))) {
PERR("could not create startup portal");
throw Cpu_session::Thread_creation_failed();
}
/* remap debugging page fault portal for core threads */
if (map_local((Utcb *)Thread_base::myself()->utcb(),
Obj_crd(PT_SEL_PAGE_FAULT, 0),
Obj_crd(_tid.exc_pt_sel + PT_SEL_PAGE_FAULT, 0))) {
PERR("could not create page fault portal");
throw Cpu_session::Thread_creation_failed();
}
/* create SC */
unsigned sc_sel = cap_selector_allocator()->alloc();

View File

@ -72,7 +72,7 @@ void Thread_base::_deinit_platform_thread()
void Thread_base::start()
{
/*
* On NOVA, core almost nerver starts regular threads. This simply creates a
* On NOVA, core almost never starts regular threads. This simply creates a
* local EC
*/
using namespace Nova;
@ -86,7 +86,14 @@ void Thread_base::start()
uint8_t res = create_ec(_tid.ec_sel, pd_sel, CPU_NO,
utcb, sp, _tid.exc_pt_sel, GLOBAL);
if (res != NOVA_OK) {
PERR("%p - create_ec returned %d", this, res);
PERR("create_ec returned %d", res);
throw Cpu_session::Thread_creation_failed();
}
if (map_local(reinterpret_cast<Nova::Utcb *>(Thread_base::myself()->utcb()),
Obj_crd(PT_SEL_PAGE_FAULT, 0),
Obj_crd(_tid.exc_pt_sel + PT_SEL_PAGE_FAULT, 0))) {
PERR("could not create page fault portal");
throw Cpu_session::Thread_creation_failed();
}
}