Extend base-hw specific vm-session (fix #738)

Introduce pause syscall for VM objects, and extend the vm-session interface
to support it.
This commit is contained in:
Stefan Kalkowski 2013-05-08 15:22:28 +02:00 committed by Norman Feske
parent d8f0392c9f
commit ae291b557d
6 changed files with 61 additions and 7 deletions

View File

@ -80,8 +80,9 @@ namespace Kernel
ACK_SIGNAL = 29,
/* vm specific */
NEW_VM = 24,
RUN_VM = 25,
NEW_VM = 24,
RUN_VM = 25,
PAUSE_VM = 31,
};
/*****************************************************************
@ -546,6 +547,17 @@ namespace Kernel
*/
inline void run_vm(unsigned const id) {
syscall(RUN_VM, (Syscall_arg)id); }
/**
* Stop execution of a virtual-machine
*
* \param id ID of the targeted VM
*
* Restricted to core threads.
*/
inline void pause_vm(unsigned const id) {
syscall(PAUSE_VM, (Syscall_arg)id); }
}
#endif /* _INCLUDE__KERNEL__SYSCALLS_H_ */

View File

@ -41,8 +41,8 @@ namespace Genode
void exception_handler(Signal_context_capability handler) {
call<Rpc_exception_handler>(handler); }
void run() {
call<Rpc_run>(); }
void run() { call<Rpc_run>(); }
void pause() { call<Rpc_pause>(); }
};
}

View File

@ -46,6 +46,12 @@ namespace Genode {
*/
virtual void run(void) {}
/**
* Stop execution of the VM
*/
virtual void pause(void) {}
/*********************
** RPC declaration **
*********************/
@ -54,7 +60,9 @@ namespace Genode {
GENODE_RPC(Rpc_exception_handler, void, exception_handler,
Signal_context_capability);
GENODE_RPC(Rpc_run, void, run);
GENODE_RPC_INTERFACE(Rpc_cpu_state, Rpc_exception_handler, Rpc_run);
GENODE_RPC(Rpc_pause, void, pause);
GENODE_RPC_INTERFACE(Rpc_cpu_state, Rpc_exception_handler,
Rpc_run, Rpc_pause);
};
}

View File

@ -67,6 +67,7 @@ namespace Genode {
Dataspace_capability cpu_state(void) { return _ds_cap; }
void exception_handler(Signal_context_capability handler);
void run(void);
void pause(void);
};
}

View File

@ -691,8 +691,13 @@ namespace Kernel
Signal_context * const context)
: _state(state), _context(context) { }
void run() {
cpu_scheduler()->insert(this); }
/**************************
** Vm_session interface **
**************************/
void run() { cpu_scheduler()->insert(this); }
void pause() { cpu_scheduler()->remove(this); }
/**********************
@ -1300,6 +1305,23 @@ namespace Kernel
}
/**
* Do specific syscall for 'user', for details see 'syscall.h'
*/
void do_pause_vm(Thread * const user)
{
/* check permissions */
assert(user->pd_id() == core_id());
/* get targeted vm via its id */
Vm * const vm = Vm::pool()->object(user->user_arg_1());
assert(vm);
/* pause targeted vm */
vm->pause();
}
/**
* Handle a syscall request
*
@ -1344,6 +1366,7 @@ namespace Kernel
/* 28 */ do_resume_faulter,
/* 29 */ do_ack_signal,
/* 30 */ do_kill_signal_context,
/* 31 */ do_pause_vm,
};
enum { MAX_SYSCALL = sizeof(handle_sysc)/sizeof(handle_sysc[0]) - 1 };

View File

@ -44,6 +44,16 @@ void Vm_session_component::run(void)
}
void Vm_session_component::pause(void)
{
if (!_vm_id) {
PWRN("No exception handler registered!");
return;
}
Kernel::pause_vm(_vm_id);
}
Vm_session_component::Vm_session_component(Rpc_entrypoint *ds_ep,
Range_allocator *ram_alloc,
size_t ram_quota)