base: extend vm_session API with native vcpu cap

To enable the interaction of a VMM with the kernel directly,
a hidden RPC gets introduced. It allows a kernel-specific
base-library implementation of the Vm_session::Client to request
a kernel-specific capability to address a VCPU, e.g., to
run/stop it.

Ref #3926
This commit is contained in:
Stefan Kalkowski 2020-10-09 10:32:24 +02:00 committed by Christian Helmuth
parent 11e261ada4
commit 40445d7011
6 changed files with 33 additions and 7 deletions

View File

@ -108,6 +108,8 @@ class Genode::Vm_session_component
void attach_pic(addr_t) override { }
void detach(addr_t, size_t) override;
Vcpu_id _create_vcpu(Thread_capability);
Capability<Native_vcpu> _native_vcpu(Vcpu_id) {
return Capability<Native_vcpu>(); }
};
#endif /* _CORE__VM_SESSION_COMPONENT_H_ */

View File

@ -55,6 +55,13 @@ void Vm_session_component::_pause(Vcpu_id id)
}
Capability<Vm_session::Native_vcpu> Vm_session_component::_native_vcpu(Vcpu_id id)
{
if (!_valid_id(id)) { return Capability<Vm_session::Native_vcpu>(); }
return reinterpret_cap_cast<Vm_session::Native_vcpu>(_vcpus[id.id].kobj.cap());
}
void Vm_session_component::_exception_handler(Signal_context_capability handler,
Vcpu_id id)
{

View File

@ -107,12 +107,13 @@ class Genode::Vm_session_component
void attach_pic(addr_t) override;
void detach(addr_t, size_t) override;
Dataspace_capability _cpu_state(Vcpu_id);
Vcpu_id _create_vcpu(Thread_capability);
void _exception_handler(Signal_context_capability,
Vcpu_id);
void _run(Vcpu_id);
void _pause(Vcpu_id);
Dataspace_capability _cpu_state(Vcpu_id);
Vcpu_id _create_vcpu(Thread_capability);
void _exception_handler(Signal_context_capability,
Vcpu_id);
void _run(Vcpu_id);
void _pause(Vcpu_id);
Capability<Native_vcpu> _native_vcpu(Vcpu_id);
};
#endif /* _CORE__VM_SESSION_COMPONENT_H_ */

View File

@ -179,6 +179,8 @@ class Genode::Vm_session_component
void attach_pic(addr_t) override {}
void detach(addr_t, size_t) override;
Vcpu_id _create_vcpu(Thread_capability);
Capability<Native_vcpu> _native_vcpu(Vcpu_id) {
return Capability<Native_vcpu>(); }
};
#endif /* _CORE__VM_SESSION_COMPONENT_H_ */

View File

@ -121,6 +121,8 @@ class Genode::Vm_session_component
void attach_pic(addr_t) override {}
void detach(addr_t, size_t) override;
Vcpu_id _create_vcpu(Thread_capability);
Capability<Native_vcpu> _native_vcpu(Vcpu_id) {
return Capability<Native_vcpu>(); }
};
#endif /* _CORE__VM_SESSION_COMPONENT_H_ */

View File

@ -78,6 +78,17 @@ struct Genode::Vm_session : Session
*/
virtual void attach_pic(addr_t vm_addr) = 0;
/*****************************************
** Access to kernel-specific interface **
*****************************************/
/**
* Common base class of kernel-specific CPU interfaces
*/
struct Native_vcpu : Interface { };
/*********************
** RPC declaration **
*********************/
@ -87,6 +98,7 @@ struct Genode::Vm_session : Session
Signal_context_capability, Vcpu_id);
GENODE_RPC(Rpc_run, void, _run, Vcpu_id);
GENODE_RPC(Rpc_pause, void, _pause, Vcpu_id);
GENODE_RPC(Rpc_native_vcpu, Capability<Native_vcpu>, _native_vcpu, Vcpu_id);
GENODE_RPC_THROW(Rpc_attach, void, attach,
GENODE_TYPE_LIST(Out_of_ram, Out_of_caps, Region_conflict,
Invalid_dataspace),
@ -99,7 +111,7 @@ struct Genode::Vm_session : Session
GENODE_RPC_INTERFACE(Rpc_cpu_state, Rpc_exception_handler,
Rpc_run, Rpc_pause, Rpc_attach, Rpc_detach,
Rpc_attach_pic, Rpc_create_vcpu);
Rpc_attach_pic, Rpc_create_vcpu, Rpc_native_vcpu);
};
#endif /* _INCLUDE__VM_SESSION__VM_SESSION_H_ */