sandbox: add Pd_intrinsics::start_initial_thread

This hook allows for intercepting the creation of initial threads
whenever a new child is started.

Issue #4917
This commit is contained in:
Norman Feske 2023-05-16 17:11:36 +02:00
parent 0d5571a820
commit add6dbac4e
3 changed files with 15 additions and 0 deletions

View File

@ -66,6 +66,11 @@ class Genode::Sandbox : Noncopyable
* Call 'Fn' with the 'Intrinsics' that apply for the specified PD
*/
virtual void with_intrinsics(Capability<Pd_session>, Pd_session &, Fn const &) = 0;
/**
* Start the initial thread of new PD at the given instruction pointer
*/
virtual void start_initial_thread(Capability<Cpu_thread>, addr_t ip) = 0;
};
private:

View File

@ -782,6 +782,11 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
fn.call(intrinsics.address_space); });
}
void start_initial_thread(Capability<Cpu_thread> cap, addr_t ip) override
{
_pd_intrinsics.start_initial_thread(cap, ip);
}
void yield_response() override
{
apply_downgrade();

View File

@ -268,6 +268,11 @@ struct Genode::Sandbox::Library : ::Sandbox::State_reporter::Producer,
fn.call(intrinsics);
}
void start_initial_thread(Capability<Cpu_thread> cap, addr_t ip) override
{
Cpu_thread_client(cap).start(ip, 0);
}
Default_pd_intrinsics(Env &env) : _env(env) { }
} _default_pd_intrinsics { _env };