foc: keep core internal pager state separately

beforehand the Lock object and more was accessible
via FOC native cpu thread RPC

Fixes #3809
This commit is contained in:
Alexander Boettcher
2020-07-07 13:40:38 +02:00
committed by Norman Feske
parent f3efbe50bb
commit 6fa4307005
5 changed files with 23 additions and 19 deletions

View File

@@ -33,17 +33,11 @@ struct Genode::Foc_thread_state : Thread_state
Fiasco::l4_cap_idx_t kcap; /* thread's gate cap in its pd */ Fiasco::l4_cap_idx_t kcap; /* thread's gate cap in its pd */
int id; /* id of gate capability */ int id; /* id of gate capability */
addr_t utcb; /* thread's utcb in its pd */ addr_t utcb; /* thread's utcb in its pd */
unsigned exceptions; /* counts exceptions raised by the thread */
bool paused; /* indicates whether thread is stopped */
bool in_exception; /* true if thread is in exception */
Lock lock { };
/** /**
* Constructor * Constructor
*/ */
Foc_thread_state() Foc_thread_state() : kcap(Fiasco::L4_INVALID_CAP), id(0), utcb(0) { }
: kcap(Fiasco::L4_INVALID_CAP), id(0), utcb(0), exceptions(0),
paused(false), in_exception(false) { }
}; };
#endif /* _INCLUDE__FOC__THREAD_STATE_H_ */ #endif /* _INCLUDE__FOC__THREAD_STATE_H_ */

View File

@@ -16,6 +16,15 @@
#include <foc/thread_state.h> #include <foc/thread_state.h>
namespace Genode { typedef Foc_thread_state Pager_object_exception_state; } namespace Genode { struct Pager_object_exception_state; }
struct Genode::Pager_object_exception_state
{
Lock lock { };
unsigned exceptions; /* counts exceptions raised by the thread */
bool paused; /* indicates whether thread is stopped */
bool in_exception; /* true if thread is in exception */
Foc_thread_state state; /* accessible via native cpu thread RPC */
};
#endif /* _CORE__INCLUDE__PAGER_OBJECT_EXCEPTION_STATE_H_ */ #endif /* _CORE__INCLUDE__PAGER_OBJECT_EXCEPTION_STATE_H_ */

View File

@@ -16,7 +16,6 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/log.h> #include <base/log.h>
#include <base/lock.h>
/* core includes */ /* core includes */
#include <pager.h> #include <pager.h>
@@ -59,7 +58,7 @@ void Pager_entrypoint::entry()
{ {
if (_pager.exception()) { if (_pager.exception()) {
Lock::Guard guard(obj->state.lock); Lock::Guard guard(obj->state.lock);
_pager.get_regs(obj->state); _pager.get_regs(obj->state.state);
obj->state.exceptions++; obj->state.exceptions++;
obj->state.in_exception = true; obj->state.in_exception = true;
obj->submit_exception_signal(); obj->submit_exception_signal();
@@ -99,7 +98,7 @@ void Pager_entrypoint::entry()
/* revert exception flag */ /* revert exception flag */
obj->state.in_exception = false; obj->state.in_exception = false;
/* set new register contents */ /* set new register contents */
_pager.set_regs(obj->state); _pager.set_regs(obj->state.state);
} }
/* send wake up message to requested thread */ /* send wake up message to requested thread */
@@ -115,7 +114,7 @@ void Pager_entrypoint::entry()
case Ipc_pager::PAUSE: case Ipc_pager::PAUSE:
{ {
Lock::Guard guard(obj->state.lock); Lock::Guard guard(obj->state.lock);
_pager.get_regs(obj->state); _pager.get_regs(obj->state.state);
obj->state.exceptions++; obj->state.exceptions++;
obj->state.in_exception = true; obj->state.in_exception = true;

View File

@@ -41,5 +41,5 @@ void Pager_object::wake_up()
void Pager_object::unresolved_page_fault_occurred() void Pager_object::unresolved_page_fault_occurred()
{ {
state.unresolved_page_fault = true; state.state.unresolved_page_fault = true;
} }

View File

@@ -96,9 +96,11 @@ void Platform_thread::pause()
return; return;
} }
Foc_thread_state &reg_state = _pager_obj->state.state;
unsigned exc = _pager_obj->state.exceptions; unsigned exc = _pager_obj->state.exceptions;
_pager_obj->state.ip = ~0UL; reg_state.ip = ~0UL;
_pager_obj->state.sp = ~0UL; reg_state.sp = ~0UL;
l4_umword_t flags = L4_THREAD_EX_REGS_TRIGGER_EXCEPTION; l4_umword_t flags = L4_THREAD_EX_REGS_TRIGGER_EXCEPTION;
/* Mark thread to be stopped */ /* Mark thread to be stopped */
@@ -109,8 +111,8 @@ void Platform_thread::pause()
* The pager thread, which also acts as exception handler, will * The pager thread, which also acts as exception handler, will
* leave the thread in exception state until, it gets woken again * leave the thread in exception state until, it gets woken again
*/ */
l4_thread_ex_regs_ret(_thread.local.data()->kcap(), &_pager_obj->state.ip, l4_thread_ex_regs_ret(_thread.local.data()->kcap(), &reg_state.ip,
&_pager_obj->state.sp, &flags); &reg_state.sp, &flags);
/* /*
* The thread state ("ready") is encoded in the lowest bit of the flags. * The thread state ("ready") is encoded in the lowest bit of the flags.
@@ -202,14 +204,14 @@ void Platform_thread::pager(Pager_object &pager_obj)
void Platform_thread::state(Thread_state s) void Platform_thread::state(Thread_state s)
{ {
if (_pager_obj) if (_pager_obj)
*static_cast<Thread_state *>(&_pager_obj->state) = s; *static_cast<Thread_state *>(&_pager_obj->state.state) = s;
} }
Foc_thread_state Platform_thread::state() Foc_thread_state Platform_thread::state()
{ {
Foc_thread_state s; Foc_thread_state s;
if (_pager_obj) s = _pager_obj->state; if (_pager_obj) s = _pager_obj->state.state;
s.kcap = _gate.remote; s.kcap = _gate.remote;
s.id = _gate.local.local_name(); s.id = _gate.local.local_name();