From 6c69f181db7e13d4b8a3b7f111ad875c809235cb Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 3 Nov 2009 14:50:22 +0200 Subject: [PATCH] First step in detaching pager struct from tasks --- include/l4/generic/container.h | 10 +--------- src/api/cap.c | 4 ++-- src/api/exregs.c | 2 +- src/generic/capability.c | 2 +- src/generic/container.c | 4 +--- src/generic/resource.c | 13 +++++++------ src/glue/arm/init.c | 8 ++++---- 7 files changed, 17 insertions(+), 26 deletions(-) diff --git a/include/l4/generic/container.h b/include/l4/generic/container.h index 369119e..ee7b21f 100644 --- a/include/l4/generic/container.h +++ b/include/l4/generic/container.h @@ -48,15 +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 - * - * Threads, address spaces, mutex queues, cpu share ... - * Pagers possess these capabilities. - */ - /* threadpool, spacepool, mutexpool, cpupool, mempool */ + struct cap_list cap_list; /* Capabilities shared by whole container */ struct pager pager[CONFIG_MAX_PAGERS_USED]; }; diff --git a/src/api/cap.c b/src/api/cap.c index 56306a2..c456a07 100644 --- a/src/api/cap.c +++ b/src/api/cap.c @@ -28,7 +28,7 @@ int read_task_capabilities(void *userbuf) * Currently only pagers can * read their own capabilities */ - if (current != current->pager->tcb) + if (current->tid != current->pagerid) return -EPERM; /* Determine size of pager capabilities (FIXME: partial!) */ @@ -126,7 +126,7 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf) switch(req) { /* Return number of capabilities the thread has */ case CAP_CONTROL_NCAPS: - if (current != current->pager->tcb) + if (current->tid != current->pagerid) return -EPERM; if ((err = check_access((unsigned long)userbuf, diff --git a/src/api/exregs.c b/src/api/exregs.c index 6691ba4..8465557 100644 --- a/src/api/exregs.c +++ b/src/api/exregs.c @@ -132,7 +132,7 @@ int sys_exchange_registers(struct exregs_data *exregs, l4id_t tid) * be the pagers making the call on themselves. */ if (task->state != TASK_INACTIVE && exregs->valid_vect && - current != task && task->pager->tcb != current) { + current != task && task->pagerid != current->tid) { err = -EACTIVE; goto out; } diff --git a/src/generic/capability.c b/src/generic/capability.c index 614a4af..6d58fd4 100644 --- a/src/generic/capability.c +++ b/src/generic/capability.c @@ -556,7 +556,7 @@ struct capability *cap_match_mem(struct capability *cap, * * It seems it would be reasonable for a pager to have memory * capabilities with a resid of its own id, and rtype of - * CAP_RTYPE_PGGROUP, effectively allowing it to do map + * CAP_RTYPE_CONTAINER, effectively allowing it to do map * operations on itself and its group of paged children. */ } diff --git a/src/generic/container.c b/src/generic/container.c index 73ee897..1f6d3bb 100644 --- a/src/generic/container.c +++ b/src/generic/container.c @@ -110,8 +110,6 @@ int init_pager(struct pager *pager, task_init_registers(task, pager->start_address); /* Initialize container/pager relationships */ - pager->tcb = task; - task->pager = pager; task->pagerid = task->tid; task->tgid = task->tid; task->container = cont; @@ -142,7 +140,7 @@ int init_pager(struct pager *pager, cap->resid = CAP_RESID_NONE; } - printk("%s: Mapping %lx bytes (%lx pages) from 0x%lx to 0x%lx for %s\n", + printk("%s: Mapping 0x%lx bytes (0x%lx 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); diff --git a/src/generic/resource.c b/src/generic/resource.c index 514619e..cebbc9f 100644 --- a/src/generic/resource.c +++ b/src/generic/resource.c @@ -363,9 +363,6 @@ void init_kernel_resources(struct kernel_resources *kres) /* Initialize container head */ container_head_init(&kres->containers); - /* Get first container id for itself */ - kres->cid = id_new(&kres->container_ids); - /* Initialize kernel capability lists */ cap_list_init(&kres->physmem_used); cap_list_init(&kres->physmem_free); @@ -521,6 +518,10 @@ void setup_containers(struct boot_resources *bootres, /* Initialize pagers */ container_init_pagers(kres, current_pgd); + + /* Assign next unused container id for kernel resources */ + kres->cid = id_new(&kres->container_ids); + } /* @@ -559,8 +560,8 @@ void copy_boot_capabilities(struct cap_list *caplist) * Creates capabilities allocated with a real id, and from the * capability cache, in place of ones allocated at boot-time. */ -void kres_setup_capabilities(struct boot_resources *bootres, - struct kernel_resources *kres) +void kernel_setup_capabilities(struct boot_resources *bootres, + struct kernel_resources *kres) { struct capability *cap; @@ -861,7 +862,7 @@ int init_system_resources(struct kernel_resources *kres) init_resource_allocators(&bootres, kres); - kres_setup_capabilities(&bootres, kres); + kernel_setup_capabilities(&bootres, kres); setup_containers(&bootres, kres); diff --git a/src/glue/arm/init.c b/src/glue/arm/init.c index 56c6302..bf4b7a8 100644 --- a/src/glue/arm/init.c +++ b/src/glue/arm/init.c @@ -257,11 +257,11 @@ void init_finalize(struct kernel_resources *kres) /* Get the first container */ c = link_to_struct(kres->containers.list.next, - struct container, - list); + struct container, list); - /* Get the first pager ktcb */ - first_task = c->pager[0].tcb; + /* Get the first pager in container */ + first_task = link_to_struct(c->ktcb_list.list.next, + struct ktcb, task_list); /* Calculate first stack address */ newstack = align((unsigned long)first_task + PAGE_SIZE - 1,