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:
@@ -22,6 +22,7 @@ int container_init(struct container *c)
|
||||
init_address_space_list(&c->space_list);
|
||||
init_ktcb_list(&c->ktcb_list);
|
||||
init_mutex_queue_head(&c->mutex_queue_head);
|
||||
cap_list_init(&c->cap_list);
|
||||
|
||||
/* Init pager structs */
|
||||
for (int i = 0; i < CONFIG_MAX_PAGERS_USED; i++)
|
||||
@@ -73,15 +74,14 @@ int init_pager(struct pager *pager,
|
||||
struct ktcb *task;
|
||||
struct address_space *space;
|
||||
int first = !!current_pgd;
|
||||
struct capability *cap;
|
||||
|
||||
/*
|
||||
* Initialize dummy current capability list pointer
|
||||
* so that capability accounting can be done as normal
|
||||
*
|
||||
* FYI: We're still on bootstack instead of current's
|
||||
* real stack. Hence this is a dummy.
|
||||
* Set up dummy current cap_list so that cap accounting
|
||||
* can be done to this pager. Note, that we're still on
|
||||
* bootstack.
|
||||
*/
|
||||
current->cap_list_ptr = &pager->cap_list;
|
||||
cap_list_move(¤t->cap_list, &pager->cap_list);
|
||||
|
||||
/* New ktcb allocation is needed */
|
||||
task = tcb_alloc_init();
|
||||
@@ -112,7 +112,25 @@ int init_pager(struct pager *pager,
|
||||
task->pager = pager;
|
||||
task->pagerid = task->tid;
|
||||
task->container = cont;
|
||||
task->cap_list_ptr = &pager->cap_list;
|
||||
|
||||
/* Initialize uninitialized capability fields while on dummy */
|
||||
list_foreach_struct(cap, ¤t->cap_list.caps, list) {
|
||||
/* Initialize owner */
|
||||
cap->owner = task->tid;
|
||||
|
||||
/*
|
||||
* Initialize resource id, if possible.
|
||||
* Currently this is a temporary hack where
|
||||
* we allow only container ids and _assume_
|
||||
* that container is pager's own container.
|
||||
*
|
||||
* See capability resource ids for info
|
||||
*/
|
||||
if (cap_rtype(cap) == CAP_RTYPE_CONTAINER)
|
||||
cap->resid = task->container->cid;
|
||||
else
|
||||
cap->resid = CAP_RESID_NONE;
|
||||
}
|
||||
|
||||
printk("%s: Mapping %lu pages from 0x%lx to 0x%lx for %s\n",
|
||||
__KERNELNAME__,
|
||||
@@ -124,6 +142,9 @@ int init_pager(struct pager *pager,
|
||||
page_align_up(pager->memsize),
|
||||
MAP_USR_DEFAULT_FLAGS, TASK_PGD(task));
|
||||
|
||||
/* Move capability list from dummy to task's cap list */
|
||||
cap_list_move(&task->cap_list, ¤t->cap_list);
|
||||
|
||||
/* Initialize task scheduler parameters */
|
||||
sched_init_task(task, TASK_PRIO_PAGER);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user