base: add create_vcpu to Vm_session interface

`Vm_session_component::create_vcpu()` is present across all supported
kernels, yet until now it was not part of the `Vm_session` interface.

Add the method to the `Vm_session` interface. This unifies calls in the
base library and is the basis to remove the need for a common base class
for separate `Vm_session` implementations for SVM and VMX on x86_64.

Issue #5221
This commit is contained in:
Benjamin Lamowski 2024-11-15 13:19:17 +01:00 committed by Christian Helmuth
parent f94f461f8f
commit 5e3a898109
12 changed files with 22 additions and 15 deletions

View File

@ -125,7 +125,7 @@ class Core::Vm_session_component
** Vm session interface **
**************************/
Capability<Native_vcpu> create_vcpu(Thread_capability);
Capability<Native_vcpu> create_vcpu(Thread_capability) override;
void attach_pic(addr_t) override { /* unused on Fiasco.OC */ }
void attach(Dataspace_capability, addr_t, Attach_attr) override; /* vm_session_common.cc */

View File

@ -72,8 +72,7 @@ struct Foc_native_vcpu_rpc : Rpc_client<Vm_session::Native_vcpu>, Noncopyable
Capability<Vm_session::Native_vcpu> _create_vcpu(Vm_connection &vm,
Thread_capability &cap)
{
return vm.with_upgrade([&] {
return vm.call<Vm_session::Rpc_create_vcpu>(cap); });
return vm.create_vcpu(cap);
}
public:

View File

@ -136,7 +136,7 @@ class Core::Vm_session_component
void attach_pic(addr_t) override;
void detach(addr_t, size_t) override;
Capability<Native_vcpu> create_vcpu(Thread_capability);
Capability<Native_vcpu> create_vcpu(Thread_capability) override;
};
#endif /* _CORE__VM_SESSION_COMPONENT_H_ */

View File

@ -90,8 +90,7 @@ Capability<Vm_session::Native_vcpu> Hw_vcpu::_create_vcpu(Vm_connection &vm,
{
Thread &tep { *reinterpret_cast<Thread *>(&handler.rpc_ep()) };
return vm.with_upgrade([&] {
return vm.call<Vm_session::Rpc_create_vcpu>(tep.cap()); });
return vm.create_vcpu(tep.cap());
}

View File

@ -102,8 +102,7 @@ Capability<Vm_session::Native_vcpu> Hw_vcpu::_create_vcpu(Vm_connection &vm,
{
Thread &tep { *reinterpret_cast<Thread *>(&handler.rpc_ep()) };
return vm.with_upgrade([&] {
return vm.call<Vm_session::Rpc_create_vcpu>(tep.cap()); });
return vm.create_vcpu(tep.cap());
}

View File

@ -173,7 +173,7 @@ class Core::Vm_session_component
** Vm session interface **
**************************/
Capability<Native_vcpu> create_vcpu(Thread_capability);
Capability<Native_vcpu> create_vcpu(Thread_capability) override;
void attach_pic(addr_t) override { /* unused on NOVA */ }
void attach(Dataspace_capability, addr_t, Attach_attr) override;

View File

@ -719,8 +719,7 @@ Capability<Vm_session::Native_vcpu> Nova_vcpu::_create_vcpu(Vm_connection &v
{
Thread &tep { *reinterpret_cast<Thread *>(&handler.rpc_ep()) };
return vm.with_upgrade([&] {
return vm.call<Vm_session::Rpc_create_vcpu>(tep.cap()); });
return vm.create_vcpu(tep.cap());
}

View File

@ -117,7 +117,7 @@ class Core::Vm_session_component
** Vm session interface **
**************************/
Capability<Native_vcpu> create_vcpu(Thread_capability);
Capability<Native_vcpu> create_vcpu(Thread_capability) override;
void attach_pic(addr_t) override { /* unused on seL4 */ }
void attach(Dataspace_capability, addr_t, Attach_attr) override;

View File

@ -49,8 +49,7 @@ struct Sel4_native_rpc : Rpc_client<Vm_session::Native_vcpu>, Noncopyable
Capability<Vm_session::Native_vcpu> _create_vcpu(Vm_connection &vm,
Thread_capability &cap)
{
return vm.with_upgrade([&] {
return vm.call<Vm_session::Rpc_create_vcpu>(cap); });
return vm.create_vcpu(cap);
}
public:

View File

@ -133,6 +133,11 @@ struct Genode::Vm_connection : Connection<Vm_session>, Rpc_client<Vm_session>
void attach_pic(addr_t vm_addr) override {
call<Rpc_attach_pic>(vm_addr); }
Capability<Vm_session::Native_vcpu> create_vcpu(Thread_capability tcap) override {
return with_upgrade([&] {
return call<Rpc_create_vcpu>(tcap); });
}
};
#endif /* _INCLUDE__VM_SESSION__CONNECTION_H_ */

View File

@ -69,6 +69,7 @@ struct Genode::Vm_session : Session
*/
virtual void attach_pic(addr_t vm_addr) = 0;
/*****************************************
** Access to kernel-specific interface **
*****************************************/
@ -78,6 +79,12 @@ struct Genode::Vm_session : Session
*/
struct Native_vcpu;
/**
* Create a virtual CPU.
*/
virtual Capability<Vm_session::Native_vcpu> create_vcpu(Thread_capability) = 0;
/*********************
** RPC declaration **
*********************/

View File

@ -48,7 +48,7 @@ struct Monitor::Monitored_vm_session : Monitored_rpc_object<Vm_session, Monitore
_real.call<Rpc_attach_pic>(vm_addr);
}
Capability<Native_vcpu> create_vcpu(Thread_capability thread_cap)
Capability<Native_vcpu> create_vcpu(Thread_capability thread_cap) override
{
Capability<Native_vcpu> result { };