vmm: parameterize Vcpu_dispatcher

Pre-condition to realize #1129, to be able to let a vCPU handler thread also
be a pthread.
This commit is contained in:
Alexander Boettcher 2014-04-17 14:00:58 +02:00 committed by Norman Feske
parent 512c29c486
commit 4782fd34f6
4 changed files with 31 additions and 13 deletions

View File

@ -18,6 +18,7 @@ namespace Vmm {
using namespace Genode;
template <class T>
class Vcpu_dispatcher;
}
@ -25,7 +26,8 @@ namespace Vmm {
/**
* Thread that handles virtualization events of a 'Vmm::Vcpu_thread'
*/
class Vmm::Vcpu_dispatcher : public Genode::Thread_base
template <class T>
class Vmm::Vcpu_dispatcher : public T
{
private:
@ -57,17 +59,30 @@ class Vmm::Vcpu_dispatcher : public Genode::Thread_base
Vcpu_dispatcher(size_t stack_size, Cap_connection &cap)
:
Thread_base("vCPU dispatcher", stack_size),
T("vCPU dispatcher", stack_size),
_cap(cap)
{
using namespace Genode;
/* request creation of a 'local' EC */
_tid.ec_sel = Native_thread::INVALID_INDEX - 1;
Thread_base::start();
/* request creation of a 'local' EC */
T::_tid.ec_sel = Native_thread::INVALID_INDEX - 1;
T::start();
}
template <typename X>
Vcpu_dispatcher(size_t stack_size, Cap_connection &cap,
X attr, void *(*start_routine) (void *), void *arg)
: T(attr, start_routine, arg, stack_size, "vCPU dispatcher", nullptr),
_cap(cap)
{
using namespace Genode;
/* request creation of a 'local' EC */
T::_tid.ec_sel = Native_thread::INVALID_INDEX - 1;
T::start();
}
/**
* Register virtualization event handler
*/
@ -82,7 +97,7 @@ class Vmm::Vcpu_dispatcher : public Genode::Thread_base
/* Create the portal at the desired selector index */
_cap.rcv_window(exc_base + EV);
Native_capability thread_cap(tid().ec_sel);
Native_capability thread_cap(T::tid().ec_sel);
Native_capability handler =
_cap.alloc(thread_cap, (Nova::mword_t)entry, mtd.value());
@ -111,7 +126,7 @@ class Vmm::Vcpu_dispatcher : public Genode::Thread_base
*/
Nova::mword_t sel_sm_ec()
{
return tid().exc_pt_sel + Nova::SM_SEL_EC;
return T::tid().exc_pt_sel + Nova::SM_SEL_EC;
}
};

View File

@ -24,7 +24,7 @@ using Genode::printf;
using Genode::sleep_forever;
class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher
class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher<Genode::Thread_base>
{
private:
@ -60,7 +60,7 @@ class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher
Vcpu_dispatcher(Cap_connection &cap, Type type)
:
Vmm::Vcpu_dispatcher(STACK_SIZE, cap),
Vmm::Vcpu_dispatcher<Genode::Thread_base>(STACK_SIZE, cap),
_vcpu_thread(STACK_SIZE)
{
using namespace Nova;

View File

@ -246,7 +246,9 @@ class Guest_memory
};
class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher,
typedef Vmm::Vcpu_dispatcher<Genode::Thread_base> Vcpu_handler;
class Vcpu_dispatcher : public Vcpu_handler,
public StaticReceiver<Vcpu_dispatcher>
{
private:
@ -683,7 +685,7 @@ class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher,
bool has_vmx,
Vmm::Vcpu_thread *vcpu_thread)
:
Vmm::Vcpu_dispatcher(STACK_SIZE, cap_connection),
Vcpu_handler(STACK_SIZE, cap_connection),
_vcpu(vcpu_lock, unsynchronized_vcpu),
_vcpu_thread(vcpu_thread),
_guest_memory(guest_memory),

View File

@ -58,7 +58,7 @@ static inline Genode::uint32_t sel_ar_conv_from_nova(Genode::uint16_t v)
extern "C" int MMIO2_MAPPED_SYNC(PVM pVM, RTGCPHYS GCPhys, size_t cbWrite);
class Vcpu_handler : public Vmm::Vcpu_dispatcher
class Vcpu_handler : public Vmm::Vcpu_dispatcher<Genode::Thread_base>
{
private:
@ -507,7 +507,8 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher
Vcpu_handler()
:
Vmm::Vcpu_dispatcher(STACK_SIZE, _cap_connection),
Vmm::Vcpu_dispatcher<Genode::Thread_base>(STACK_SIZE,
_cap_connection),
_ec_sel(Genode::cap_map()->insert()),
_lock_startup(Genode::Lock::LOCKED),
_signal_emt(Genode::Lock::LOCKED),