mirror of
https://github.com/drasko/codezero.git
synced 2026-11-24 18:04:00 +01:00
UTCBs are mmap'ed only when needed.
In case of cloned threads, UTCBs may or may not need to be mmapped. This is now checked before the do_mmap call via find_vma().
This commit is contained in:
+12
-7
@@ -9,6 +9,7 @@
|
|||||||
#include <mmap.h>
|
#include <mmap.h>
|
||||||
#include <utcb.h>
|
#include <utcb.h>
|
||||||
#include <lib/malloc.h>
|
#include <lib/malloc.h>
|
||||||
|
#include <vm_area.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UTCB management in Codezero
|
* UTCB management in Codezero
|
||||||
@@ -108,13 +109,17 @@ int task_setup_utcb(struct tcb *task)
|
|||||||
slot = task_new_utcb_desc(task);
|
slot = task_new_utcb_desc(task);
|
||||||
out:
|
out:
|
||||||
|
|
||||||
/* Map this region as private to current task */
|
/* Check if utcb is already mapped (in case of multiple threads) */
|
||||||
if (IS_ERR(err = do_mmap(0, 0, task, slot,
|
if (!find_vma(slot, &task->vm_area_head->list)) {
|
||||||
VMA_ANONYMOUS | VMA_PRIVATE | VMA_FIXED |
|
/* Map this region as private to current task */
|
||||||
VM_READ | VM_WRITE, 1))) {
|
if (IS_ERR(err = do_mmap(0, 0, task, slot,
|
||||||
printf("UTCB: mmapping failed with %d\n", err);
|
VMA_ANONYMOUS | VMA_PRIVATE |
|
||||||
return (int)err;
|
VMA_FIXED | VM_READ | VM_WRITE, 1))) {
|
||||||
}
|
printf("UTCB: mmapping failed with %d\n", err);
|
||||||
|
return (int)err;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
printf("UTCB at 0x%x already mapped.\n", slot);
|
||||||
|
|
||||||
/* Assign task's utcb address */
|
/* Assign task's utcb address */
|
||||||
task->utcb_address = slot;
|
task->utcb_address = slot;
|
||||||
|
|||||||
Reference in New Issue
Block a user