Commit Graph

268 Commits

Author SHA1 Message Date
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
66388a0fc3 Updated README 2008-11-10 13:32:48 +02:00
Bahadir Balban
9a9b8d2701 Added a clone() test to test0. 2008-11-10 12:51:01 +02:00
Bahadir Balban
a96a8bb6d9 Modification on allocation of thread group ids in the kernel.
A new or forked thread will have its tgid same as its unique thread id.

A cloned thread (i.e. in the same space) will get its parent's tgid if
the parent tgid is supplied as the suggested tgid in the ids field. Otherwise
the thread will have its tgid same as its unique thread id.

Previously we also allocated a tgid from a separate pool, but this doesn't
make sense. It is cleaner to have the unique thread id get used also as the tgid.
2008-11-10 11:29:09 +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
b874062dd7 LICENSE file fix 2008-11-09 12:24:01 +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
0e3f069713 Removed an overly restrictive BUG_ON assert from scheduler code.
sched_resume_async() used to forbit current tasks to wake up themselves
since it seems tasks can never be runnable to wake themselves up. However
there's a special case in the scheduler where a task that is about to sleep
may notice it has a pending event and wake itself up asynchronously. Since
all sleeping preparation has already been done and scheduler code is a safe
zone, it is safe to undo it all and resume about-to-sleep task in the scheduler.

We may want to put a BKPT in the pager's suspend routine if it waits for the
sleeping task to resume itself, to see if such a wait is successful. It rarely happens.
2008-11-07 21:25:36 +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
Bahadir Balban
a2d2574eac Added VM_DIRTY flag for file-backed objects and their pages.
Now file flushing in both munmap() and fsync() caters for VM_DIRTY.
Also write_cache_pages() and write faults set this bit on pages and their objects.
2008-10-30 11:09:15 +02:00
Bahadir Balban
13b1b405a5 Cleaned up libposix mmap()
Now we have proper setting of errno and using pfn based mmap for both types of mmap calls.
2008-10-29 20:01:31 +02:00
Bahadir Balban
4046ad9e3f Added msync(), added handling of munmap/msync to pager main.c 2008-10-29 19:22:01 +02:00
Bahadir Balban
51af9968c2 Added flushing of file pages to do_munmap() for file-backed mappings. 2008-10-29 19:03:19 +02:00
Bahadir Balban
94a126dcde munmap compiling.
do_munmap currently shrinks, splits, destroys vmas and unmaps the given
virtual address range from the task. Unmapped pages may go completely unused
but page reclamation will be done in another part of the pager rather than
directly on the munmap instance.
2008-10-29 16:59:06 +02:00
Bahadir Balban
3421a29693 Few undecided changes on munmap.c 2008-10-29 14:02:21 +02:00
Bahadir Balban
d5b5560bfa Moved munmap functions to munmap.c yet to be modified. 2008-10-27 15:07:06 +02:00
Bahadir Balban
e8c1f31cee Minor cleanups to vm_area.h 2008-10-25 14:32:34 +03:00