mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-15 13:48:17 +00:00
base: assign allocator and quota to platform pd
Enable platform specific allocations and ram quota accounting for protection domains. Needed to allocate object identity references in the base-hw kernel when delegating capabilities via IPC. Moreover, it can be used to account translation table entries in the future. Ref #1443
This commit is contained in:
committed by
Christian Helmuth
parent
d9d65aa86b
commit
358380046c
@ -14,6 +14,9 @@
|
|||||||
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
|
#include <base/allocator.h>
|
||||||
|
|
||||||
/* core includes */
|
/* core includes */
|
||||||
#include <platform_thread.h>
|
#include <platform_thread.h>
|
||||||
#include <address_space.h>
|
#include <address_space.h>
|
||||||
@ -42,7 +45,8 @@ namespace Genode {
|
|||||||
* Constructors
|
* Constructors
|
||||||
*/
|
*/
|
||||||
Platform_pd(bool core);
|
Platform_pd(bool core);
|
||||||
Platform_pd(char const *, signed pd_id = -1, bool create = true);
|
Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id = -1, bool create = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -98,7 +98,8 @@ Platform_pd::Platform_pd(bool core)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
|
Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id, bool create)
|
||||||
: _space_id(TASK_ID_INVALID)
|
: _space_id(TASK_ID_INVALID)
|
||||||
{
|
{
|
||||||
_space_id = TASK_ID_INVALID;
|
_space_id = TASK_ID_INVALID;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
|
|
||||||
|
#include <base/allocator.h>
|
||||||
#include <platform_thread.h>
|
#include <platform_thread.h>
|
||||||
#include <address_space.h>
|
#include <address_space.h>
|
||||||
|
|
||||||
@ -142,7 +143,8 @@ namespace Genode {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Platform_pd(char const *, signed pd_id = PD_INVALID,
|
Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id = PD_INVALID,
|
||||||
bool create = true);
|
bool create = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,7 +490,8 @@ Platform::Platform() :
|
|||||||
|
|
||||||
/* setup pd object for core pd */
|
/* setup pd object for core pd */
|
||||||
_core_label[0] = 0;
|
_core_label[0] = 0;
|
||||||
_core_pd = new(core_mem_alloc()) Platform_pd(_core_label, myself.id.task, false);
|
_core_pd = new(core_mem_alloc()) Platform_pd(nullptr, 0, _core_label,
|
||||||
|
myself.id.task, false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We setup the thread object for thread0 in core pd using a special
|
* We setup the thread object for thread0 in core pd using a special
|
||||||
|
@ -236,7 +236,8 @@ void Platform_pd::unbind_thread(Platform_thread *thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
|
Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id, bool create)
|
||||||
{
|
{
|
||||||
/* check correct init */
|
/* check correct init */
|
||||||
if (!_init)
|
if (!_init)
|
||||||
|
@ -34,7 +34,8 @@ namespace Genode {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Pd_session_component(Rpc_entrypoint *thread_ep, const char *args)
|
Pd_session_component(Rpc_entrypoint *thread_ep,
|
||||||
|
Allocator *md_alloc, const char *args)
|
||||||
: _thread_ep(thread_ep) { }
|
: _thread_ep(thread_ep) { }
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ namespace Genode {
|
|||||||
* Constructors
|
* Constructors
|
||||||
*/
|
*/
|
||||||
Platform_pd(bool core);
|
Platform_pd(bool core);
|
||||||
Platform_pd(char const *, signed pd_id = -1, bool create = true);
|
Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id = -1, bool create = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -43,7 +43,8 @@ Platform_pd::Platform_pd(bool core)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
|
Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id, bool create)
|
||||||
{
|
{
|
||||||
PWRN("not yet implemented");
|
PWRN("not yet implemented");
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,9 @@ namespace Genode
|
|||||||
*
|
*
|
||||||
* \param label name of protection domain
|
* \param label name of protection domain
|
||||||
*/
|
*/
|
||||||
Platform_pd(char const *label) : _main_thread(0), _label(label)
|
Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *label)
|
||||||
|
: _main_thread(0), _label(label)
|
||||||
{
|
{
|
||||||
Lock::Guard guard(_lock);
|
Lock::Guard guard(_lock);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define _CORE__INCLUDE__PD_SESSION_COMPONENT_H_
|
#define _CORE__INCLUDE__PD_SESSION_COMPONENT_H_
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
|
#include <base/allocator.h>
|
||||||
#include <base/rpc_server.h>
|
#include <base/rpc_server.h>
|
||||||
#include <linux_pd_session/linux_pd_session.h>
|
#include <linux_pd_session/linux_pd_session.h>
|
||||||
|
|
||||||
@ -43,9 +44,12 @@ namespace Genode {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* \param ds_ep entrypoint where the dataspaces are managed
|
* \param ds_ep entrypoint where the dataspaces are managed
|
||||||
|
* \param md_alloc meta-data allocator
|
||||||
|
* \param args additional session arguments
|
||||||
*/
|
*/
|
||||||
Pd_session_component(Rpc_entrypoint *ds_ep, const char *args);
|
Pd_session_component(Rpc_entrypoint *ds_ep, Allocator * md_alloc,
|
||||||
|
const char *args);
|
||||||
|
|
||||||
~Pd_session_component();
|
~Pd_session_component();
|
||||||
|
|
||||||
|
@ -305,7 +305,9 @@ static const char *get_env(const char *key)
|
|||||||
** PD session interface **
|
** PD session interface **
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
Pd_session_component::Pd_session_component(Rpc_entrypoint *ep, const char *args)
|
Pd_session_component::Pd_session_component(Rpc_entrypoint * ep,
|
||||||
|
Allocator * md_alloc,
|
||||||
|
const char * args)
|
||||||
:
|
:
|
||||||
_pid(0), _uid(0), _gid(0), _ds_ep(ep)
|
_pid(0), _uid(0), _gid(0), _ds_ep(ep)
|
||||||
{
|
{
|
||||||
|
@ -52,8 +52,13 @@ namespace Genode {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Pd_session_component(Rpc_entrypoint *thread_ep, const char *args)
|
Pd_session_component(Rpc_entrypoint *thread_ep,
|
||||||
: _label(args), _pd(_label.string), _thread_ep(thread_ep) { }
|
Allocator * md_alloc, char const *args)
|
||||||
|
: _label(args),
|
||||||
|
_pd(md_alloc,
|
||||||
|
Arg_string::find_arg(args, "ram_quota").long_value(0),
|
||||||
|
_label.string),
|
||||||
|
_thread_ep(thread_ep) { }
|
||||||
|
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
|
|
||||||
|
#include <base/allocator.h>
|
||||||
#include <platform_thread.h>
|
#include <platform_thread.h>
|
||||||
#include <address_space.h>
|
#include <address_space.h>
|
||||||
|
|
||||||
@ -39,7 +40,8 @@ namespace Genode {
|
|||||||
/**
|
/**
|
||||||
* Constructors
|
* Constructors
|
||||||
*/
|
*/
|
||||||
Platform_pd(char const *, signed pd_id = -1, bool create = true);
|
Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id = -1, bool create = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
|
@ -46,7 +46,8 @@ int Platform_pd::assign_parent(Native_capability parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
|
Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id, bool create)
|
||||||
: _thread_cnt(0), _pd_sel(~0UL) { }
|
: _thread_cnt(0), _pd_sel(~0UL) { }
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,8 @@ namespace Genode {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Pd_session_component(Rpc_entrypoint *thread_ep, const char *args)
|
Pd_session_component(Rpc_entrypoint *thread_ep,
|
||||||
|
Allocator *md_alloc, const char *args)
|
||||||
: _thread_ep(thread_ep) { }
|
: _thread_ep(thread_ep) { }
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
||||||
|
|
||||||
|
#include <base/allocator.h>
|
||||||
#include <platform_thread.h>
|
#include <platform_thread.h>
|
||||||
#include <address_space.h>
|
#include <address_space.h>
|
||||||
|
|
||||||
@ -183,7 +184,8 @@ namespace Genode {
|
|||||||
* Constructors
|
* Constructors
|
||||||
*/
|
*/
|
||||||
Platform_pd(bool core);
|
Platform_pd(bool core);
|
||||||
Platform_pd(char const *, signed pd_id = PD_INVALID,
|
Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id = PD_INVALID,
|
||||||
bool create = true);
|
bool create = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -340,7 +340,8 @@ Platform_pd::Platform_pd(bool core) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
|
Platform_pd::Platform_pd(Allocator * md_alloc, size_t ram_quota,
|
||||||
|
char const *, signed pd_id, bool create)
|
||||||
{
|
{
|
||||||
if (!create)
|
if (!create)
|
||||||
panic("create must be true.");
|
panic("create must be true.");
|
||||||
|
@ -21,34 +21,40 @@
|
|||||||
#include <pd_session_component.h>
|
#include <pd_session_component.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
class Pd_root;
|
||||||
class Pd_root : public Root_component<Pd_session_component>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
Rpc_entrypoint *_thread_ep;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
Pd_session_component *_create_session(const char *args) {
|
|
||||||
return new (md_alloc()) Pd_session_component(_thread_ep, args); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* \param session_ep entry point for managing pd session objects
|
|
||||||
* \param thread_ep entry point for managing threads
|
|
||||||
* \param md_alloc meta-data allocator to be used by root component
|
|
||||||
*/
|
|
||||||
Pd_root(Rpc_entrypoint *session_ep,
|
|
||||||
Rpc_entrypoint *thread_ep,
|
|
||||||
Allocator *md_alloc)
|
|
||||||
:
|
|
||||||
Root_component<Pd_session_component>(session_ep, md_alloc),
|
|
||||||
_thread_ep(thread_ep) { }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Genode::Pd_root
|
||||||
|
: public Genode::Root_component<Genode::Pd_session_component>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
Rpc_entrypoint *_thread_ep;
|
||||||
|
Allocator *_md_alloc;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Pd_session_component *_create_session(const char *args)
|
||||||
|
{
|
||||||
|
return new (md_alloc()) Pd_session_component(_thread_ep,
|
||||||
|
_md_alloc, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* \param session_ep entry point for managing pd session objects
|
||||||
|
* \param thread_ep entry point for managing threads
|
||||||
|
* \param md_alloc meta-data allocator to be used by root component
|
||||||
|
*/
|
||||||
|
Pd_root(Rpc_entrypoint *session_ep,
|
||||||
|
Rpc_entrypoint *thread_ep,
|
||||||
|
Allocator *md_alloc)
|
||||||
|
: Root_component<Pd_session_component>(session_ep, md_alloc),
|
||||||
|
_thread_ep(thread_ep), _md_alloc(md_alloc) { }
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _CORE__INCLUDE__PD_ROOT_H_ */
|
#endif /* _CORE__INCLUDE__PD_ROOT_H_ */
|
||||||
|
@ -52,8 +52,13 @@ namespace Genode {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Pd_session_component(Rpc_entrypoint *thread_ep, char const *args)
|
Pd_session_component(Rpc_entrypoint *thread_ep,
|
||||||
: _label(args), _pd(_label.string), _thread_ep(thread_ep) { }
|
Allocator * md_alloc, char const *args)
|
||||||
|
: _label(args),
|
||||||
|
_pd(md_alloc,
|
||||||
|
Arg_string::find_arg(args, "ram_quota").long_value(0),
|
||||||
|
_label.string),
|
||||||
|
_thread_ep(thread_ep) { }
|
||||||
|
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
|
Reference in New Issue
Block a user