mirror of
https://github.com/drasko/codezero.git
synced 2026-01-16 04:43:16 +01:00
Progress on capabilities
Capabilities will be shared among collection of threads. A pager will have a right to share its own capabilities with its space, its thread group and its container. Currently sharing is possible with only all of the caps. Next, it will be support for cap splitting, granting, and partial sharing and granting.
This commit is contained in:
@@ -8,6 +8,16 @@
|
||||
|
||||
#include <l4/lib/list.h>
|
||||
|
||||
/*
|
||||
* Some resources that capabilities possess don't
|
||||
* have unique ids or need ids at all.
|
||||
*
|
||||
* E.g. a threadpool does not need a resource id.
|
||||
* A virtual memory capability does not require
|
||||
* a resource id, its capid is sufficient.
|
||||
*/
|
||||
#define CAP_RESID_NONE -1
|
||||
|
||||
/*
|
||||
* A capability is a unique representation of security
|
||||
* qualifiers on a particular resource.
|
||||
@@ -65,6 +75,7 @@ struct capability {
|
||||
};
|
||||
|
||||
struct cap_list {
|
||||
int ktcb_refs;
|
||||
int ncaps;
|
||||
struct link caps;
|
||||
};
|
||||
@@ -87,12 +98,43 @@ static inline void cap_list_insert(struct capability *cap,
|
||||
clist->ncaps++;
|
||||
}
|
||||
|
||||
/* Detach a whole list of capabilities from list head */
|
||||
static inline struct capability *
|
||||
cap_list_detach(struct cap_list *clist)
|
||||
{
|
||||
struct link *list = list_detach(&clist->caps);
|
||||
clist->ncaps = 0;
|
||||
return link_to_struct(list, struct capability, list);
|
||||
}
|
||||
|
||||
/* Attach a whole list of capabilities to list head */
|
||||
static inline void cap_list_attach(struct capability *cap,
|
||||
struct cap_list *clist)
|
||||
{
|
||||
/* Attach as if cap is the list and clist is the element */
|
||||
list_insert(&clist->caps, &cap->list);
|
||||
|
||||
/* Count the number of caps attached */
|
||||
list_foreach_struct(cap, &clist->caps, list)
|
||||
clist->ncaps++;
|
||||
}
|
||||
|
||||
static inline void cap_list_move(struct cap_list *to,
|
||||
struct cap_list *from)
|
||||
{
|
||||
struct capability *cap_head = cap_list_detach(from);
|
||||
cap_list_attach(cap_head, to);
|
||||
}
|
||||
|
||||
struct ktcb;
|
||||
/* Capability checking for quantitative capabilities */
|
||||
int capability_consume(struct capability *cap, int quantity);
|
||||
int capability_free(struct capability *cap, int quantity);
|
||||
struct capability *capability_find_by_rtype(struct cap_list *clist,
|
||||
struct capability *capability_find_by_rtype(struct ktcb *task,
|
||||
unsigned int rtype);
|
||||
|
||||
struct capability *cap_list_find_by_rtype(struct cap_list *clist,
|
||||
unsigned int rtype);
|
||||
#if 0
|
||||
/* Virtual memory space allocated to container */
|
||||
struct capability cap_virtmap = {
|
||||
|
||||
@@ -48,6 +48,7 @@ struct container {
|
||||
struct id_pool *space_id_pool;
|
||||
|
||||
struct mutex_queue_head mutex_queue_head; /* Userspace mutex list */
|
||||
struct cap_list cap_list; /* Capabilities shared by whole container */
|
||||
|
||||
/*
|
||||
* Capabilities that apply to this container
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <l4/lib/list.h>
|
||||
#include <l4/lib/mutex.h>
|
||||
#include <l4/lib/idpool.h>
|
||||
#include <l4/generic/capability.h>
|
||||
#include INC_SUBARCH(mm.h)
|
||||
|
||||
/* A simple page table with a reference count */
|
||||
@@ -32,6 +33,9 @@ struct address_space {
|
||||
struct link list;
|
||||
struct mutex lock;
|
||||
pgd_table_t *pgd;
|
||||
|
||||
/* Capabilities shared by threads in same space */
|
||||
struct cap_list cap_list;
|
||||
int ktcb_refs;
|
||||
};
|
||||
|
||||
|
||||
@@ -102,9 +102,9 @@ struct ktcb {
|
||||
struct container *container;
|
||||
struct pager *pager;
|
||||
|
||||
/* Capability list */
|
||||
struct cap_list *cap_list_ptr;
|
||||
/* Capability lists */
|
||||
struct cap_list cap_list;
|
||||
struct cap_list tgr_cap_list;
|
||||
|
||||
/* Fields for ipc rendezvous */
|
||||
struct waitqueue_head wqh_recv;
|
||||
|
||||
Reference in New Issue
Block a user