Commit Graph

298 Commits

Author SHA1 Message Date
Bahadir Balban
da3b293ab4 Fixed a byte/pfn confusion.
- During execve/map_stack when setting up the environment and argument stack,
  the stack map size was in bytes instead of pfns.
- Can now execve 16 forked tasks with success.
2009-05-14 10:57:31 +03:00
Bahadir Balban
ae50823599 Elf file checking - Added the test that data and text are at least a page apart. 2009-05-13 16:37:08 +03:00
Bahadir Balban
2c01463482 In FS0 filesystem image buffer was smaller than the memfs-defined maximum.
- Now fs size is in sync with memfs max size.
2009-05-13 16:09:20 +03:00
Bahadir Balban
680d20ff94 Initial changes to libl4 for full and extended ipc.
- Tag word will be used to specify full and extended ipc, and its size.
2009-05-13 16:08:37 +03:00
Bahadir Balban
44bf1db573 Removed the BUG() check on a legitimate l4_unmap return case
When vmas are unmapped before being touched, l4_unmap may return a negative
value if the unmapped area was already faulted. This is normal behaviour
2009-05-12 18:24:31 +03:00
Bahadir Balban
33fcceb2b6 Added a shared memory test.
- libposix error printing now configurable via macro definition
- shmget/at/dt tested.
2009-05-12 18:16:25 +03:00
Bahadir Balban
324481a334 Some more enhancements to test0
- Only the topmost parent prints pass messages. Any failed child can print fail message.
- Added testing of 16 forked threads doing file create/read/write/close and
  16 forked x 4 cloned = 64 threads spawning/exiting
2009-05-12 12:31:25 +03:00
Bahadir Balban
8528e2e1ba Modified the kernel and all tasks with well-formatted printout messages. 2009-05-12 11:25:14 +03:00
Bahadir Balban
db0d756dfa Removed thread group id pool.
We don't need a separate group id pool for now.
2009-05-11 12:21:08 +03:00
Bahadir Balban
1b04037034 Address space creation/deletion implemented
- Proper releasing of user pmd and pgds when a space is not used.
- Proper releasing of task, space ids.

- At occasions a starting thread gets bogus SPSR, this needs investigating.
- At a very rare occasion arch_setup_new_thread() had a kernel data abort during
  register copying from one task to another. Needs investigating.
2009-05-11 12:10:12 +03:00
Bahadir Balban
7415546410 Reimplemented space handling by introducing an address_space structure.
- Fixed potential concurrency bugs due to preemption being enabled.
- Introduced a new address space structure to better account for
  address spaces and page tables.
- Currently executes fine up to forking. Will investigate.
2009-05-08 23:35:19 +03:00
Bahadir Balban
2df8875a88 Initialisation works OK with new address space structure.
Going to add:
- Address space create/delete add/remove
- KCTB create/delete add/remove
2009-05-07 11:08:35 +03:00
Bahadir Balban
6e1edc0aad Adding address space structure to ktcbs. Still booting until virtual memory is enabled. 2009-05-07 10:26:34 +03:00
Bahadir Balban
3acc66c2e7 Adding support for refcounted page tables. Fixed freeing of kernel pmds on copy_page_tables 2009-05-02 11:21:19 +03:00
Bahadir Balban
8ab892375e Comment title for kmalloc 2009-05-02 10:54:02 +03:00
Bahadir Balban
63e18b176e Fixed returning freed field of struct. 2009-05-02 10:44:23 +03:00
Bahadir Balban
9fbeefadb8 Slight modification in reaching/freeing of pmds. 2009-05-01 23:12:27 +03:00
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
7af45d0fb9 Added building of external libs as well.
modified:   buildall.sh
2009-04-17 14:52:36 +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
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