Commit Graph

246 Commits

Author SHA1 Message Date
Bahadir Balban
97bfd3bb9b Fixed error escalation in thread_create() and its function calls. 2009-05-01 22:39:31 +03:00
Bahadir Balban
952285d756 UTCB create/destroy working.
Execve maps its utcb in mmap_segments. fork/clone does it as part of task_create
2009-05-01 17:48:54 +03:00
Bahadir Balban
260527c0a3 Added utcb create/destroy and better reorganized calls to them. 2009-05-01 17:06:24 +03:00
Bahadir Balban
8ca0ca9cfb 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().
2009-05-01 14:52:06 +03:00
Bahadir Balban
b1b3b59561 Workaround added for duplicate page faults from cloned threads.
It is possible that in a mult-threaded address space write-faults
(or faults in general) on the same address can occur. This is because
threads may become runnable during the handling of the first fault.

This causes duplicate faults on the same private page in the same address space.
On the case of write faulted private page, this causes a spurious page allocation
Currently this case is detected and handled, but in the future we need
a generic way of detecting duplicate faults (of any kind) and cease duplicate
IPC at a very early stage. This is not done yet as it requires knowledge of the
PTEs of physical pages in the pager (like reverse mapping in Linux).
2009-05-01 14:44:41 +03:00
Bahadir Balban
cada0f8f18 New UTCB implementation almost working.
- KIP's pointer to UTCB seems to work with existing l4lib ipc functions.
- Works up to clone()
- In clone we mmap() the same UTCB on each new thread - excessive.
- Generally during page fault handling, cloned threads may fault on the same page
  multiple times even though a single handling would be enough for all of them.
  Need to detect and handle this.
2009-05-01 10:11:47 +03:00
Bahadir Balban
7a81db8782 Ongoing work for adding per-thread UTCB structures.
Added setting of utcb address to l4_thread_control.
This is going to be moved to exchange_registers() since we need to pass
both the utcb physical and virtual address and exregs fits such context
modification better than thread_control.
2009-04-29 16:53:04 +03:00
Bahadir Balban
54a9b2901d Removed allocation of utcb shared pages by mm0 completely.
- Now libl4 has no references to utcb page or shmat etc.
- Pager does not deal with special case utcb page allocation.
  It instead allocates a shared page from shm memory pool.
- All tasks working to original standard.

Next:
- Add per-thread utcb allocation from the kernel
- Add larger register file for standard ipc
- Add long ipc (up to 1Kb)
2009-04-22 14:48:43 +03:00
Bahadir Balban
203f053878 Removed special-case utcb shared page from posix services.
Previously a so-called utcb shared page was used for transfering
data between posix services. This was a special shmat/get/dt case
allocating from its own virtual pool. Now the term utcb is renamed
as a shared page and integrated with the shm* handling routines.

Generic l4 threads will use long-ipc and not this method. Posix
services will continue to communicate on a shared page for now.
	modified:   tasks/libl4/include/l4lib/ipcdefs.h
	modified:   tasks/libl4/src/init.c
	new file:   tasks/libposix/init.c
	modified:   tasks/mm0/include/shm.h
	modified:   tasks/mm0/include/task.h
	deleted:    tasks/mm0/include/utcb.h
	modified:   tasks/mm0/main.c
	modified:   tasks/mm0/src/boot.c
	modified:   tasks/mm0/src/clone.c
	modified:   tasks/mm0/src/execve.c
	modified:   tasks/mm0/src/exit.c
	modified:   tasks/mm0/src/init.c
	modified:   tasks/mm0/src/shm.c
	modified:   tasks/mm0/src/task.c
	deleted:    tasks/mm0/src/utcb.c
	deleted:    tools/l4-qemu
2009-04-22 11:58:58 +03:00
Bahadir Balban
8d82fa5f5e Removed execve() test. 2009-04-18 09:47:48 +03:00
Bahadir Balban
23b4c9d5db Moved boot-related functions to boot.c 2009-04-17 15:18:42 +03:00
Bahadir Balban
9123eb49a8 execve working from vfs executable file along with clone/fork/exit 2008-12-02 18:29:40 +02:00
Bahadir Balban
32b3dfe91d Fixed various faults with execve().
Added a new ordered task_insert_vma() function
2008-12-02 14:15:40 +02:00
Bahadir Balban
05d8438f34 Task initally exec'ing with success. Some errors need to be investigated.
- Directory creation, file read/write is OK.
- Cannot reuse old task's fds. They are not recycled for some reason.
- Problems with fork/clone/exit. They fail for a reason.
2008-12-01 13:53:50 +02:00
Bahadir Balban
783b1e025f Added env and arg passing to execve 2008-11-25 12:52:28 +02:00
Bahadir Balban
159944b092 Removed copy_user_string 2008-11-25 12:32:13 +02:00
Bahadir Balban
321b5b2b73 Now using a common method for copying variable size strings and pointer array. 2008-11-25 12:28:50 +02:00
Bahadir Balban
a9e6aabcae We can now successfully copy char *argv[] user array.
After a lot of magic pointer arithmetic and mapping.
2008-11-25 11:05:41 +02:00
Bahadir Balban
0ddb8ea799 Fix to do_mmap(): file_offset was byte offset, it is now a pfn.
Uncovered a mmap() bug that came along this far. file_offset
parameter of do_mmap() was assigned to the mapped vma as is, i.e.
as a byte offset. This caused problems since most page fault and
other internal code assumed this was a page frame number. This is now
fixed. This came along unnoticed since all mmaps until now started at
file offset 0.
2008-11-23 23:24:03 +02:00
Bahadir Balban
d0e878b32c Added detailed mapping of bss.
.data and .text now needs to be 4K apart.
removed an early copy of test0 called test1
2008-11-23 21:27:11 +02:00
Bahadir Balban
311d6917c4 Fixed a few errors with pager-mapping of elf file pages.
Added expansion of elf segments during segment marking.
2008-11-22 13:23:39 +02:00
Bahadir Balban
906c8ac679 Added pager_map_file_page() which maps a file offset as a pointer. 2008-11-21 23:27:43 +02:00
Bahadir Balban
7d38243dff Moved all pager page-mapping routines to memory.c
Added a new virtual address pool for contiguous virtual addresses for the pager.
This will help in mapping multi-page user buffers and files.
2008-11-21 21:05:42 +02:00
Bahadir Balban
2d5a08ff32 More progress on parsing elf files. Fixes to memfs file read/write
Increased inode block pointers to 40. The current maximum allowed (and checked).
Updates to file size after every file write ensures subsequent writes can
correctly operate using updated file size information (i.e. not try to add
more pages that are already present). We cannot do this inside write() because
directory writes rely on byte-granularity updates on file buffers, whereas
file updates are by page-granularity (currently).
2008-11-21 19:26:10 +02:00
Bahadir Balban
27d331895b Introduction to elf parsing 2008-11-20 17:34:12 +02:00
Bahadir Balban
1914e58be9 Moved thread id assignment to task_create for new tasks with parents.
Added shared parenting for CLONE_THREAD and CLONE_PARENT
2008-11-19 21:34:57 +02:00
Bahadir Balban
46937eab88 Added preliminary support for execve(). Updates to clone, fork, exit, task handling.
It turned out we used one version of kmalloc for malloc() and another for kfree()!
Now fixed.
Added parent-child relationship to tasks. Need to polish handling CLONE_PARENT and THREAD.
2008-11-19 12:59:52 +02:00
Bahadir Balban
d182b5b35a Initial changes for execve() support 2008-11-13 21:45:30 +02:00
Bahadir Balban
44c34026b2 clone() call working. Tested exit(), clone() and fork() mixture running about 22 threads, processes. 2008-11-10 17:58:33 +02:00
Bahadir Balban
9a9b8d2701 Added a clone() test to test0. 2008-11-10 12:51:01 +02:00
Bahadir Balban
2c15d09797 Towards finishing off clone()
Few minor changes in clone() syscall
2008-11-10 11:22:38 +02:00
Bahadir Balban
b0291fa075 Added the LICENSE file for GPL v3. 2008-11-09 12:22:48 +02:00
Bahadir Balban
513d5aaac8 Added exit.c that seemed to be out of tree. 2008-11-09 11:42:10 +02:00
Bahadir Balban
88ca2033f7 Now shared tcb parts freed correctly. 2008-11-09 11:37:24 +02:00
Bahadir Balban
b387a0526a tcb_destroy() in pager and fs0 now caters for shared structures. 2008-11-09 10:40:18 +02:00
Bahadir Balban
63fb907cd0 Made changes to have shared tcb parts in fs0 in preparation for clone()
fs_data and files structures can now be shared in the vfs task.
Currently no means to free shared structures in tcb destruction. Need to add that.
2008-11-09 10:07:24 +02:00
Bahadir Balban
5468c1833d Utcbs of exiting children are successfully unmapped from vfs via sys_shmdt
The shared memory addresses are returned back to their pools via the
deletion function of such objects. They don't get released via do_munmap().
2008-11-08 13:19:15 +02:00
Bahadir Balban
94daebd0c5 Mapping precision fixes on l4_unmap and do_munmap()
l4_unmap now returns -1 if given range was only partially unmapped.

do_munmap() now only unmaps address ranges that have correspondence in
the unmapped vmas. Trying to unmap regions with no correspondent vmas
causes problems in corner cases, e.g. mm0 that tries to mmap its own
address space during initialisation would unmap its whole address space
and fail to execute.
2008-11-08 10:18:35 +02:00
Bahadir Balban
99b7cf2274 for sys_mmap(), added unmapping of existing vmas for the area that is soon to be mmap'ed. 2008-11-07 21:22:50 +02:00
Bahadir Balban
daffc1d084 Split vmas had no objects. Now fixed.
When sys_munmap() splits a vma, the new vma had no copy of the objects
in the original vma. Now we fixed that using a vma_copy_links() function
which can also be used as part of fork().
2008-11-07 20:39:11 +02:00
Bahadir Balban
61751a896b vma_intersect() was erroneous, replaced by a nice and simple set_intersection() routine.
Still testing sys_munmap(). It now correctly spots and unmaps the overlapping vma.
The issue now is that if a split occurs, we forgot to add same objects to new vma.
2008-11-07 20:13:28 +02:00
Bahadir Balban
93ca3f88a8 Forgot to increase file open count when forking a task. Now fixed.
Also now a file can only be deleted if both open count and map count is zero.
2008-11-07 17:20:11 +02:00
Bahadir Balban
122214f9b5 Increased memfs fixed maximum file size to 40 blocks (i.e. 40 pages) 2008-11-07 16:29:24 +02:00
Bahadir Balban
1ddd7ac9c2 Removed vm_object printfs that were for testing exit().
File open was failing when using 2 files with same name. TODO: Look at it in the future.
Need to increase writeable file size in fs0. 16 pages don't work.
2008-11-07 16:26:07 +02:00
Bahadir Balban
40ccc642f9 Removed find_vma_byrange completely. It was buggy and useless. 2008-11-07 16:12:44 +02:00
Bahadir Balban
f87f3cd5d2 Fixed libposix munmap call where we used the MMAP tag. 2008-11-07 15:18:43 +02:00
Bahadir Balban
f0348cc356 Fixed an msync() issue.
msync used find_vma_byrange() instead of traversing each vma. Fixed now.
2008-11-07 15:10:19 +02:00
Bahadir Balban
3cb36b632a Fixed various bugs in user buffer validation/mapping and mmap() syscall path. 2008-11-07 12:32:10 +02:00
Bahadir Balban
ca8959eee0 Added new routines that map and check the validity of user buffers.
mmap uses this mechanism to get arguments. It needs to be tested.
2008-11-03 11:27:10 +02:00
Bahadir Balban
87d1b91743 Added setting page owner to VM_DIRTY in write_cache_pages. 2008-10-30 11:11:21 +02:00