Changes in README. Fixes to fault handling.

Yet to investigate why adding a printf format attribute to
stdio.h does not generate warnings for invalid arguments to printf.
This commit is contained in:
Bahadir Balban
2008-03-16 14:58:47 +00:00
parent 1cc6a87547
commit 0f4a4ae5b4
8 changed files with 83 additions and 46 deletions

View File

@@ -13,6 +13,7 @@
#include <l4lib/types.h>
#include <l4lib/utcb.h>
#include <lib/addr.h>
#include <l4/api/kip.h>
#define __TASKNAME__ __PAGERNAME__

View File

@@ -2,6 +2,7 @@
* Copyright (C) 2007 Bahadir Balban
*/
#include <arch/mm.h>
#include <task.h>
/* Extracts generic protection flags from architecture-specific pte */
unsigned int vm_prot_flags(pte_t pte)
@@ -51,11 +52,9 @@ void set_generic_fault_params(struct fault_data *fault)
else
BUG();
}
/*
printf("%s: Handling %s fault (%s abort) from %d. fault @ 0x%x\n",
__TASKNAME__, (fault->reason & VM_READ) ? "read" : "write",
is_prefetch_abort(fault->kdata->fsr) ? "prefetch" : "data",
fault->task->tid, fault->address);
*/
}

View File

@@ -271,10 +271,10 @@ int copy_on_write(struct fault_data *fault)
* when there are shadows one is created because a fork had just
* happened, in which case all shadows are rendered read-only.
*/
if (!(vmo->flags & VM_WRITE)) {
if (!(vmo_link->obj->flags & VM_WRITE)) {
if (!(shadow_link = vma_create_shadow()))
return -ENOMEM;
printf("%s: Created a shadow.\n", __TASKNAME__);
/* Initialise the shadow */
shadow = shadow_link->obj;
shadow->refcnt = 1;
@@ -328,7 +328,7 @@ int copy_on_write(struct fault_data *fault)
/* Update page details */
spin_lock(&new_page->lock);
new_page->refcnt = 1;
new_page->refcnt = 0;
new_page->owner = copier_link->obj;
new_page->offset = file_offset;
new_page->virtual = 0;
@@ -343,6 +343,8 @@ int copy_on_write(struct fault_data *fault)
(void *)page_align(fault->address), 1,
(reason & VM_READ) ? MAP_USR_RO_FLAGS : MAP_USR_RW_FLAGS,
fault->task->tid);
printf("%s: Mapped 0x%x as writable to tid %d.\n", __TASKNAME__,
page_align(fault->address), fault->task->tid);
/*
* Finished handling the actual fault, now check for possible
@@ -403,11 +405,14 @@ int __do_page_fault(struct fault_data *fault)
__TASKNAME__);
BUG();
}
/* Map it to faulty task */
l4_map((void *)page_to_phys(page),
(void *)page_align(fault->address), 1,
(reason & VM_READ) ? MAP_USR_RO_FLAGS : MAP_USR_RW_FLAGS,
fault->task->tid);
printf("%s: Mapped 0x%x as readable to tid %d.\n", __TASKNAME__,
page_align(fault->address), fault->task->tid);
}
/* Handle write */
@@ -435,6 +440,8 @@ int __do_page_fault(struct fault_data *fault)
(void *)page_align(fault->address), 1,
(reason & VM_READ) ? MAP_USR_RO_FLAGS : MAP_USR_RW_FLAGS,
fault->task->tid);
printf("%s: Mapped 0x%x as writable to tid %d.\n", __TASKNAME__,
page_align(fault->address), fault->task->tid);
}
/* FIXME: Just do fs files for now, anon shm objects later. */
BUG_ON((vma_flags & VMA_SHARED) && (vma_flags & VMA_ANONYMOUS));

View File

@@ -546,6 +546,7 @@ int do_mmap(struct vm_file *mapfile, unsigned long file_offset,
return -ENOMEM;
}
vmo_link->obj = &mapfile->vm_obj;
mapfile->vm_obj.refcnt++;
list_add_tail(&vmo_link->list, &new->vm_obj_list);
/* Finished initialising the vma, add it to task */

View File

@@ -181,21 +181,33 @@ struct page *bootfile_page_in(struct vm_object *vm_obj,
{
struct vm_file *boot_file = vm_object_to_file(vm_obj);
struct svc_image *img = boot_file->priv_data;
struct page *page = phys_to_page(img->phys_start +
__pfn_to_addr(offset));
struct page *page;
/* TODO: Check file length against page offset! */
/* Check first if the file has such a page at all */
if (__pfn(page_align_up(boot_file->length) <= offset)) {
printf("%s: %s: Trying to look up page %d, but file length "
"is %d bytes.\n", __TASKNAME__, __FUNCTION__,
offset, boot_file->length);
BUG();
}
/* Update page */
page_init(page);
page->refcnt++;
/* The page is not resident in page cache. */
if (!(page = find_page(vm_obj, offset))) {
page = phys_to_page(img->phys_start + __pfn_to_addr(offset));
/* Update object */
vm_obj->npages++;
/* Update page */
page_init(page);
page->refcnt++;
page->owner = vm_obj;
page->offset = offset;
/* Add the page to owner's list of in-memory pages */
BUG_ON(!list_empty(&page->list));
insert_page_olist(page, vm_obj);
/* Update object */
vm_obj->npages++;
/* Add the page to owner's list of in-memory pages */
BUG_ON(!list_empty(&page->list));
insert_page_olist(page, vm_obj);
}
return page;
}