mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-04 00:20:55 +00:00
parent
2407968242
commit
d1c4bc5115
@ -42,7 +42,6 @@ namespace Foc {
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
using Exit_config = Vm_connection::Exit_config;
|
using Exit_config = Vm_connection::Exit_config;
|
||||||
using Call_with_state = Vm_connection::Call_with_state;
|
|
||||||
|
|
||||||
|
|
||||||
enum Virt { VMX, SVM, UNKNOWN };
|
enum Virt { VMX, SVM, UNKNOWN };
|
||||||
@ -1341,7 +1340,7 @@ struct Foc_vcpu : Thread, Noncopyable
|
|||||||
_wake_up.up();
|
_wake_up.up();
|
||||||
}
|
}
|
||||||
|
|
||||||
void with_state(Call_with_state &cw)
|
void with_state(auto const &fn)
|
||||||
{
|
{
|
||||||
if (!_dispatching) {
|
if (!_dispatching) {
|
||||||
if (Thread::myself() != _ep_handler) {
|
if (Thread::myself() != _ep_handler) {
|
||||||
@ -1374,7 +1373,7 @@ struct Foc_vcpu : Thread, Noncopyable
|
|||||||
_state_ready.down();
|
_state_ready.down();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cw.call_with_state(_vcpu_state)
|
if (fn(_vcpu_state)
|
||||||
|| _extra_dispatch_up)
|
|| _extra_dispatch_up)
|
||||||
resume();
|
resume();
|
||||||
|
|
||||||
@ -1416,7 +1415,10 @@ static enum Virt virt_type(Env &env)
|
|||||||
** vCPU API **
|
** vCPU API **
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
void Vm_connection::Vcpu::_with_state(Call_with_state &cw) { static_cast<Foc_native_vcpu_rpc &>(_native_vcpu).vcpu.with_state(cw); }
|
void Vm_connection::Vcpu::_with_state(With_state::Ft const &fn)
|
||||||
|
{
|
||||||
|
static_cast<Foc_native_vcpu_rpc &>(_native_vcpu).vcpu.with_state(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
using Exit_config = Vm_connection::Exit_config;
|
using Exit_config = Vm_connection::Exit_config;
|
||||||
using Call_with_state = Vm_connection::Call_with_state;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
@ -56,8 +55,7 @@ struct Hw_vcpu : Rpc_client<Vm_session::Native_vcpu>, Noncopyable
|
|||||||
|
|
||||||
Hw_vcpu(Env &, Vm_connection &, Vcpu_handler_base &);
|
Hw_vcpu(Env &, Vm_connection &, Vcpu_handler_base &);
|
||||||
|
|
||||||
|
void with_state(auto const &);
|
||||||
void with_state(Call_with_state &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +70,7 @@ Hw_vcpu::Hw_vcpu(Env &env, Vm_connection &vm, Vcpu_handler_base &handler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Hw_vcpu::with_state(Call_with_state &cw)
|
void Hw_vcpu::with_state(auto const &fn)
|
||||||
{
|
{
|
||||||
if (Thread::myself() != _ep_handler) {
|
if (Thread::myself() != _ep_handler) {
|
||||||
error("vCPU state requested outside of vcpu_handler EP");
|
error("vCPU state requested outside of vcpu_handler EP");
|
||||||
@ -80,7 +78,7 @@ void Hw_vcpu::with_state(Call_with_state &cw)
|
|||||||
}
|
}
|
||||||
Kernel::pause_vm(Capability_space::capid(_kernel_vcpu));
|
Kernel::pause_vm(Capability_space::capid(_kernel_vcpu));
|
||||||
|
|
||||||
if (cw.call_with_state(_local_state()))
|
if (fn(_local_state()))
|
||||||
Kernel::run_vm(Capability_space::capid(_kernel_vcpu));
|
Kernel::run_vm(Capability_space::capid(_kernel_vcpu));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +96,10 @@ Capability<Vm_session::Native_vcpu> Hw_vcpu::_create_vcpu(Vm_connection &vm,
|
|||||||
** vCPU API **
|
** vCPU API **
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
void Vm_connection::Vcpu::_with_state(Call_with_state &cw) { static_cast<Hw_vcpu &>(_native_vcpu).with_state(cw); }
|
void Vm_connection::Vcpu::_with_state(With_state::Ft const &fn)
|
||||||
|
{
|
||||||
|
static_cast<Hw_vcpu &>(_native_vcpu).with_state(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
using Exit_config = Vm_connection::Exit_config;
|
using Exit_config = Vm_connection::Exit_config;
|
||||||
using Call_with_state = Vm_connection::Call_with_state;
|
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
@ -58,7 +57,7 @@ struct Hw_vcpu : Rpc_client<Vm_session::Native_vcpu>, Noncopyable
|
|||||||
|
|
||||||
Hw_vcpu(Env &, Vm_connection &, Vcpu_handler_base &);
|
Hw_vcpu(Env &, Vm_connection &, Vcpu_handler_base &);
|
||||||
|
|
||||||
void with_state(Call_with_state &);
|
void with_state(auto const &fn);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ void Hw_vcpu::_run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Hw_vcpu::with_state(Call_with_state &cw)
|
void Hw_vcpu::with_state(auto const &fn)
|
||||||
{
|
{
|
||||||
if (Thread::myself() != _ep_handler) {
|
if (Thread::myself() != _ep_handler) {
|
||||||
error("vCPU state requested outside of vcpu_handler EP");
|
error("vCPU state requested outside of vcpu_handler EP");
|
||||||
@ -92,7 +91,7 @@ void Hw_vcpu::with_state(Call_with_state &cw)
|
|||||||
}
|
}
|
||||||
Kernel::pause_vm(Capability_space::capid(_kernel_vcpu));
|
Kernel::pause_vm(Capability_space::capid(_kernel_vcpu));
|
||||||
|
|
||||||
if(cw.call_with_state(_local_state()))
|
if (fn(_local_state()))
|
||||||
_run();
|
_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +109,10 @@ Capability<Vm_session::Native_vcpu> Hw_vcpu::_create_vcpu(Vm_connection &vm,
|
|||||||
** vCPU API **
|
** vCPU API **
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
void Vm_connection::Vcpu::_with_state(Call_with_state &cw) { static_cast<Hw_vcpu &>(_native_vcpu).with_state(cw); }
|
void Vm_connection::Vcpu::_with_state(With_state::Ft const &fn)
|
||||||
|
{
|
||||||
|
static_cast<Hw_vcpu &>(_native_vcpu).with_state(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
using Exit_config = Vm_connection::Exit_config;
|
using Exit_config = Vm_connection::Exit_config;
|
||||||
using Call_with_state = Vm_connection::Call_with_state;
|
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
@ -163,7 +162,7 @@ struct Nova_vcpu : Rpc_client<Vm_session::Native_vcpu>, Noncopyable
|
|||||||
call<Rpc_startup>();
|
call<Rpc_startup>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void with_state(Call_with_state &cw);
|
void with_state(auto const &fn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -601,7 +600,7 @@ void Nova_vcpu::_handle_exit(Nova::Utcb &utcb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Nova_vcpu::with_state(Call_with_state &cw)
|
void Nova_vcpu::with_state(auto const &fn)
|
||||||
{
|
{
|
||||||
Thread *myself = Thread::myself();
|
Thread *myself = Thread::myself();
|
||||||
bool remote = (_dispatching != myself);
|
bool remote = (_dispatching != myself);
|
||||||
@ -626,7 +625,7 @@ void Nova_vcpu::with_state(Call_with_state &cw)
|
|||||||
_read_nova_state(utcb);
|
_read_nova_state(utcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
_resume = cw.call_with_state(_vcpu_state);
|
_resume = fn(_vcpu_state);
|
||||||
|
|
||||||
if (remote) {
|
if (remote) {
|
||||||
_write_nova_state(utcb);
|
_write_nova_state(utcb);
|
||||||
@ -762,7 +761,10 @@ Nova_vcpu::Nova_vcpu(Env &env, Vm_connection &vm, Allocator &alloc,
|
|||||||
** vCPU API **
|
** vCPU API **
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
void Vm_connection::Vcpu::_with_state(Call_with_state &cw) { static_cast<Nova_vcpu &>(_native_vcpu).with_state(cw); }
|
void Vm_connection::Vcpu::_with_state(With_state::Ft const &fn)
|
||||||
|
{
|
||||||
|
static_cast<Nova_vcpu &>(_native_vcpu).with_state(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
using Exit_config = Vm_connection::Exit_config;
|
using Exit_config = Vm_connection::Exit_config;
|
||||||
using Call_with_state = Vm_connection::Call_with_state;
|
|
||||||
|
|
||||||
struct Sel4_vcpu;
|
struct Sel4_vcpu;
|
||||||
|
|
||||||
@ -810,7 +809,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
|||||||
_wake_up.up();
|
_wake_up.up();
|
||||||
}
|
}
|
||||||
|
|
||||||
void with_state(Call_with_state &cw)
|
void with_state(auto const &fn)
|
||||||
{
|
{
|
||||||
if (!_dispatching) {
|
if (!_dispatching) {
|
||||||
if (Thread::myself() != _ep_handler) {
|
if (Thread::myself() != _ep_handler) {
|
||||||
@ -839,7 +838,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
|||||||
_state_ready.down();
|
_state_ready.down();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cw.call_with_state(_state)
|
if (fn(_state)
|
||||||
|| _extra_dispatch_up)
|
|| _extra_dispatch_up)
|
||||||
resume();
|
resume();
|
||||||
|
|
||||||
@ -859,11 +858,15 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable
|
|||||||
Sel4_native_rpc * rpc() { return &*_rpc; }
|
Sel4_native_rpc * rpc() { return &*_rpc; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
** vCPU API **
|
** vCPU API **
|
||||||
**************/
|
**************/
|
||||||
|
|
||||||
void Vm_connection::Vcpu::_with_state(Call_with_state &cw) { static_cast<Sel4_native_rpc &>(_native_vcpu).vcpu.with_state(cw); }
|
void Vm_connection::Vcpu::_with_state(With_state::Ft const &fn)
|
||||||
|
{
|
||||||
|
static_cast<Sel4_native_rpc &>(_native_vcpu).vcpu.with_state(fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
Vm_connection::Vcpu::Vcpu(Vm_connection &vm, Allocator &alloc,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef _INCLUDE__VM_SESSION__CONNECTION_H_
|
#ifndef _INCLUDE__VM_SESSION__CONNECTION_H_
|
||||||
#define _INCLUDE__VM_SESSION__CONNECTION_H_
|
#define _INCLUDE__VM_SESSION__CONNECTION_H_
|
||||||
|
|
||||||
|
#include <util/callable.h>
|
||||||
#include <base/connection.h>
|
#include <base/connection.h>
|
||||||
#include <base/rpc_client.h>
|
#include <base/rpc_client.h>
|
||||||
#include <vm_session/vm_session.h>
|
#include <vm_session/vm_session.h>
|
||||||
@ -49,11 +50,7 @@ struct Genode::Vm_connection : Connection<Vm_session>, Rpc_client<Vm_session>
|
|||||||
/* for example OMIT_FPU_ON_IRQ */
|
/* for example OMIT_FPU_ON_IRQ */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using With_state = Callable<bool, Vcpu_state &>;
|
||||||
struct Call_with_state : Genode::Interface
|
|
||||||
{
|
|
||||||
virtual bool call_with_state(Vcpu_state &) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual CPU
|
* Virtual CPU
|
||||||
@ -63,28 +60,13 @@ struct Genode::Vm_connection : Connection<Vm_session>, Rpc_client<Vm_session>
|
|||||||
*/
|
*/
|
||||||
struct Vcpu : Genode::Noncopyable
|
struct Vcpu : Genode::Noncopyable
|
||||||
{
|
{
|
||||||
void _with_state(Call_with_state &);
|
void _with_state(With_state::Ft const &);
|
||||||
|
|
||||||
|
void with_state(auto const &fn) { _with_state(With_state::Fn { fn }); }
|
||||||
|
|
||||||
Native_vcpu &_native_vcpu;
|
Native_vcpu &_native_vcpu;
|
||||||
|
|
||||||
Vcpu(Vm_connection &, Allocator &, Vcpu_handler_base &, Exit_config const &);
|
Vcpu(Vm_connection &, Allocator &, Vcpu_handler_base &, Exit_config const &);
|
||||||
|
|
||||||
template <typename FN>
|
|
||||||
void with_state(FN const &fn)
|
|
||||||
{
|
|
||||||
struct Untyped_fn : Call_with_state
|
|
||||||
{
|
|
||||||
FN const &_fn;
|
|
||||||
Untyped_fn(FN const &fn) : _fn(fn) {}
|
|
||||||
|
|
||||||
bool call_with_state(Vcpu_state &state) override
|
|
||||||
{
|
|
||||||
return _fn(state);
|
|
||||||
}
|
|
||||||
} untyped_fn(fn);
|
|
||||||
|
|
||||||
_with_state(untyped_fn);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
friend class Vcpu;
|
friend class Vcpu;
|
||||||
|
@ -92,7 +92,7 @@ _ZN6Genode13Shared_objectC1ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
|
|||||||
_ZN6Genode13Shared_objectC2ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
|
_ZN6Genode13Shared_objectC2ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
|
||||||
_ZN6Genode13Shared_objectD1Ev T
|
_ZN6Genode13Shared_objectD1Ev T
|
||||||
_ZN6Genode13Shared_objectD2Ev T
|
_ZN6Genode13Shared_objectD2Ev T
|
||||||
_ZN6Genode13Vm_connection4Vcpu11_with_stateERNS0_15Call_with_stateE T
|
_ZN6Genode13Vm_connection4Vcpu11_with_stateERKNS_8CallableIbJRNS_10Vcpu_stateEEE2FtE T
|
||||||
_ZN6Genode13Vm_connection4VcpuC1ERS0_RNS_9AllocatorERNS_17Vcpu_handler_baseERKNS0_11Exit_configE T
|
_ZN6Genode13Vm_connection4VcpuC1ERS0_RNS_9AllocatorERNS_17Vcpu_handler_baseERKNS0_11Exit_configE T
|
||||||
_ZN6Genode13Vm_connection4VcpuC2ERS0_RNS_9AllocatorERNS_17Vcpu_handler_baseERKNS0_11Exit_configE T
|
_ZN6Genode13Vm_connection4VcpuC2ERS0_RNS_9AllocatorERNS_17Vcpu_handler_baseERKNS0_11Exit_configE T
|
||||||
_ZN6Genode13Xml_generator4NodeC1ERS0_PKcRKNS1_3_FnE T
|
_ZN6Genode13Xml_generator4NodeC1ERS0_PKcRKNS1_3_FnE T
|
||||||
|
@ -24,11 +24,10 @@ static Vm_session::Native_vcpu dummy;
|
|||||||
|
|
||||||
struct Genode::Vcpu_state { };
|
struct Genode::Vcpu_state { };
|
||||||
|
|
||||||
void Vm_connection::Vcpu::_with_state(Call_with_state &) {};
|
void Vm_connection::Vcpu::_with_state(With_state::Ft const &) { };
|
||||||
|
|
||||||
Vm_connection::Vcpu::Vcpu(Vm_connection &, Allocator &,
|
Vm_connection::Vcpu::Vcpu(Vm_connection &, Allocator &,
|
||||||
Vcpu_handler_base &, Exit_config const &)
|
Vcpu_handler_base &, Exit_config const &)
|
||||||
:
|
:
|
||||||
_native_vcpu(dummy)
|
_native_vcpu(dummy)
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user