Inter-container ipc tests working.

This commit is contained in:
Bahadir Balban
2009-11-17 23:34:37 +02:00
parent 5ebc0bb9ac
commit 89093b8ace
4 changed files with 101 additions and 6 deletions

View File

@@ -517,7 +517,7 @@ int cap_find_replicate_reduce_grant(struct capability *cap)
if ((err =
l4_capability_control(CAP_CONTROL_DESTROY,
0, 0, 0, &new_cap)) < 0) {
printf("l4_capability_control() replication of "
printf("l4_capability_control() destruction of "
"capability failed.\n Could not "
"complete CAP_CONTROL_DESTROY request "
" on cap (%d), err = %d.\n",

View File

@@ -108,7 +108,7 @@ int task_delete_utcb_desc(struct tcb *task, struct utcb_desc *d)
}
/*
* Upon fork, the utcb descriptor list is origaced by a new one, since it is a new
* Upon fork, the utcb descriptor list is replaced by a new one, since it is a new
* address space. A new utcb is allocated and mmap'ed for the child task
* running in the newly created address space.
*

View File

@@ -94,7 +94,6 @@ int init_pager(struct pager *pager,
struct ktcb *task;
struct address_space *space;
int first = !!current_pgd;
struct capability *cap;
/*
* Set up dummy current cap_list so that cap accounting
@@ -140,6 +139,7 @@ int init_pager(struct pager *pager,
/* Add the address space to container space list */
address_space_add(task->space);
#if 0
/* Initialize uninitialized capability fields while on dummy */
list_foreach_struct(cap, &current->cap_list.caps, list) {
/* Initialize owner */
@@ -158,8 +158,9 @@ int init_pager(struct pager *pager,
else
cap->resid = CAP_RESID_NONE;
}
#endif
printk("%s: Mapping 0x%lx bytes (0x%lx pages) from 0x%lx to 0x%lx for %s\n",
printk("%s: Mapping 0x%lx bytes (%lu pages) from 0x%lx to 0x%lx for %s\n",
__KERNELNAME__, pager->memsize,
__pfn(page_align_up(pager->memsize)),
pager->start_lma, pager->start_vma, cont->name);
@@ -184,6 +185,93 @@ int init_pager(struct pager *pager,
return 0;
}
/*
* All first-level dynamically allocated resources
* are initialized, which includes the pager thread ids
* and pager space ids.
*
* Update all capability target ids that target such
* run-time allocated resources.
*/
int update_dynamic_capids(struct kernel_resources *kres)
{
struct ktcb *pager, *tpager;
struct container *cont, *tcont;
struct capability *cap;
/* Containers */
list_foreach_struct(cont, &kres->containers.list, list) {
/* Pagers */
list_foreach_struct(pager, &cont->ktcb_list.list, task_list) {
/* Capabilities */
list_foreach_struct(cap,
&pager->space->cap_list.caps,
list) {
/* They all shall be owned by their pager */
cap->owner = pager->tid;
/*
* Pager Space/Thread targets need updating
* from the given static container id to their
* run-time allocated ids.
*/
/* Quantity caps don't have target ids */
if (cap_type(cap) == CAP_TYPE_QUANTITY)
cap->resid = CAP_RESID_NONE;
/*
* Space _always_ denotes current pager's
* space. Other containers are not addressable
* by space ids.
*/
if (cap_rtype(cap) == CAP_RTYPE_SPACE)
cap->resid = pager->space->spid;
/*
* Thread _always_denotes another container's
* pager. There is simply no other reasonable
* thread target in the system.
*/
if (cap_rtype(cap) == CAP_RTYPE_THREAD) {
/* Find target container */
if (!(tcont =
container_find(kres,
cap->resid))) {
printk("FATAL: Capability "
"configured to target "
"non-existent "
"container.\n");
BUG();
}
/* Find its pager */
if (list_empty(&tcont->ktcb_list.list)) {
printk("FATAL: Pager"
"does not exist in "
"container %d.\n",
tcont->cid);
BUG();
}
tpager =
link_to_struct(
tcont->ktcb_list.list.next,
struct ktcb, task_list);
/* Assign pager's thread id to cap */
cap->resid = tpager->tid;
}
}
}
}
return 0;
}
/*
* Initialize all containers with their initial set of tasks,
* spaces, scheduler parameters such that they can be started.
@@ -209,6 +297,12 @@ int container_init_pagers(struct kernel_resources *kres,
}
}
/* Update any capability fields that were dynamically allocated */
update_dynamic_capids(kres);
return 0;
}

View File

@@ -430,6 +430,7 @@ int copy_pager_info(struct pager *pager, struct pager_info *pinfo)
cap_info = &pinfo->caps[i];
cap->resid = cap_info->target;
cap->type = cap_info->type;
cap->access = cap_info->access;
cap->start = cap_info->start;
@@ -527,8 +528,8 @@ void setup_kernel_resources(struct boot_resources *bootres,
* See how many containers we have. Assign next
* unused container id for kernel resources
*/
//kres->cid = id_get(&kres->container_ids, bootres->nconts + 1);
kres->cid = id_get(&kres->container_ids, 0);
kres->cid = id_get(&kres->container_ids, bootres->nconts + 1);
// kres->cid = id_get(&kres->container_ids, 0); // Gets id 0
/* First initialize the list of non-memory capabilities */
cap = boot_capability_create();