Assign threads to PD at its creation time

This patch replaces the former 'Pd_session::bind_thread' function by a
PD-capability argument of the 'Cpu_session::create_thread' function, and
removes the ancient thread-start protocol via 'Rm_session::add_client' and
'Cpu_session::set_pager'. Threads are now bound to PDs at their creation
time and implicitly paged according to the address space of the PD.

Note the API change:

This patch changes the signature of the 'Child' and 'Process' constructors.
There is a new 'address_space' argument, which represents the region map
representing the child's address space. It is supplied separately to the
PD session capability (which principally can be invoked to obtain the
PD's address space) to allow the population of the address space
without relying on an 'Pd_session::address_space' RPC call.
Furthermore, a new (optional) env_pd argument allows the explicit
overriding of the PD capability handed out to the child as part of its
environment. It can be used to intercept the interaction of the child
with its PD session at core. This is used by Noux.

Issue #1938
This commit is contained in:
Norman Feske
2016-04-20 21:12:57 +02:00
committed by Christian Helmuth
parent 2bc8a0f76a
commit b49e588c1c
140 changed files with 1112 additions and 1221 deletions

View File

@@ -72,13 +72,10 @@ class Vmm::Vcpu_dispatcher : public T
Cpu_session * cpu_session,
Genode::Affinity::Location location)
:
T(WEIGHT, "vCPU dispatcher", stack_size), _pd(pd)
T(WEIGHT, "vCPU dispatcher", stack_size, location), _pd(pd)
{
using namespace Genode;
/* place the thread on CPU described by location object */
cpu_session->affinity(T::cap(), location);
/* request creation of a 'local' EC */
T::native_thread().ec_sel = Native_thread::INVALID_INDEX - 1;
T::start();
@@ -90,14 +87,11 @@ class Vmm::Vcpu_dispatcher : public T
Cpu_session * cpu_session,
Genode::Affinity::Location location,
X attr, void *(*start_routine) (void *), void *arg)
: T(attr, start_routine, arg, stack_size, "vCPU dispatcher", nullptr),
: T(attr, start_routine, arg, stack_size, "vCPU dispatcher", nullptr, location),
_pd(pd)
{
using namespace Genode;
/* place the thread on CPU described by location object */
cpu_session->affinity(T::cap(), location);
/* request creation of a 'local' EC */
T::native_thread().ec_sel = Native_thread::INVALID_INDEX - 1;
T::start();

View File

@@ -22,6 +22,7 @@
#include <cpu_session/connection.h>
#include <pd_session/connection.h>
#include <region_map/client.h>
#include <nova_native_cpu/client.h>
/* NOVA includes */
#include <nova/native_thread.h>
@@ -68,16 +69,7 @@ class Vmm::Vcpu_other_pd : public Vmm::Vcpu_thread
enum { WEIGHT = Cpu_session::DEFAULT_WEIGHT };
Thread_capability vcpu_vm =
_cpu_session->create_thread(WEIGHT, "vCPU");
/* assign thread to protection domain */
_pd_session.bind_thread(vcpu_vm);
/* create new pager object and assign it to the new thread */
Genode::Region_map_client address_space(_pd_session.address_space());
Pager_capability pager_cap = address_space.add_client(vcpu_vm);
_cpu_session->set_pager(vcpu_vm, pager_cap);
_cpu_session->create_thread(_pd_session, WEIGHT, "vCPU", _location);
/* tell parent that this will be a vCPU */
Thread_state state;
@@ -86,15 +78,18 @@ class Vmm::Vcpu_other_pd : public Vmm::Vcpu_thread
_cpu_session->state(vcpu_vm, state);
/* obtain interface to NOVA-specific CPU session operations */
Nova_native_cpu_client native_cpu(_cpu_session->native_cpu());
/* create new pager object and assign it to the new thread */
Native_capability pager_cap = native_cpu.pager_cap(vcpu_vm);
/*
* Delegate parent the vCPU exception portals required during PD
* creation.
*/
delegate_vcpu_portals(pager_cap, exc_base());
/* place the thread on CPU described by location object */
_cpu_session->affinity(vcpu_vm, _location);
/* start vCPU in separate PD */
_cpu_session->start(vcpu_vm, 0, 0);
@@ -118,7 +113,7 @@ class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread_base
Vcpu_same_pd(size_t stack_size, Cpu_session * cpu_session,
Genode::Affinity::Location location)
:
Thread_base(WEIGHT, "vCPU", stack_size, Type::NORMAL, cpu_session)
Thread_base(WEIGHT, "vCPU", stack_size, Type::NORMAL, cpu_session, location)
{
/* release pre-allocated selectors of Thread */
Genode::cap_map()->remove(native_thread().exc_pt_sel, Nova::NUM_INITIAL_PT_LOG2);
@@ -128,9 +123,6 @@ class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread_base
/* tell generic thread code that this becomes a vCPU */
this->native_thread().is_vcpu = true;
/* place the thread on CPU described by location object */
cpu_session->affinity(Thread_base::cap(), location);
}
~Vcpu_same_pd()
@@ -150,11 +142,15 @@ class Vmm::Vcpu_same_pd : public Vmm::Vcpu_thread, Genode::Thread_base
{
this->Thread_base::start();
/* obtain interface to NOVA-specific CPU session operations */
Nova_native_cpu_client native_cpu(_cpu_session->native_cpu());
/*
* Request native EC thread cap and put it next to the
* SM cap - see Vcpu_dispatcher->sel_sm_ec description
*/
request_native_ec_cap(_pager_cap, sel_ec);
Native_capability pager_cap = native_cpu.pager_cap(_thread_cap);
request_native_ec_cap(pager_cap, sel_ec);
}
void entry() { }