Commit Graph

280 Commits

Author SHA1 Message Date
Bahadir Balban
13d469f659 Removed all unecessary prints from the mutex test and the kernel
- removed (%d) Sleeping print from contended kernel mutexes.
- removed (%d) Waiting print from WAIT_EVENT used by the pager for suspending tasks.
- removed prints from the mutex_control syscall and user mutex test.
2009-06-01 16:02:10 +03:00
Bahadir Balban
5a616d1eb5 Simplified l4_mutex test, in that the test now updates a variable by thread
switching instead of updating a whole page.
2009-06-01 15:51:54 +03:00
Bahadir Balban
78a5ec9d6d Enhanced execve test error handling 2009-06-01 15:33:36 +03:00
Bahadir Balban
87eae2c941 Verbose error reporting on execve test. 2009-06-01 15:07:24 +03:00
Bahadir Balban
33200c92df Mutex implementation almost working.
- Fixed a wrong instruction in mutex.S user library
- Added support for blocking lock/unlock
- Divided waiting into wait_on_prepare and wait_on_prepared_wait
  so that mutex_control lock is released after getting in the waitqueue.
- Declaring waitqueue on the stack should be done outside wait_on_prepare

Issues:
- Tests can be simplified for atomic data access instead of producer/consumer.
- kmalloc variable sized memory caches are not freed properly. Currently only the
  last slot can be freed, occupied correctly. it should be done in any slot, i.e.
  1, 2, 3, 4 instead of just 5.
- Need to add a mutex to kmalloc.
2009-06-01 14:11:40 +03:00
Bahadir Balban
2bd26ce684 Added mmap support for MAP_SHARED + MAP_ANONYMOUS
mmap() with MAP_ANON | MAP_SHARED is used for creating shared
memory mappings that can be shared among a process and its descendants
(think fork())

Currently shmget/at creates shared virtual files on the fly and calls
do_mmap to create anonymous shared mappings. Now sys_mmap uses this
interface to create virtual files on the fly and call do_mmap on those
files.

In the future a common shared virtual file creation method should be
added and commonly used by both interfaces.
2009-05-31 15:55:16 +03:00
Bahadir Balban
d0652fcb21 Updated mutextest - it is not yet there, we need semaphores 2009-05-31 14:18:19 +03:00
Bahadir Balban
ce79aa2b73 Mutex test progress
- Mutex test added. Forked tasks demonstrate produce/consumer using a
  shared mmap'ed page.
- Added l4lib assembler syscall
- Added forgotten SWI to mutex control offset in syscall page.
- Added mutex head initialization
- Contended child successfully sleeps in a waitqueue.

Issues:
- Somehow the child's produced page buffer is altered at about [4020] offset.
  Parent fails to validate buffer therefore.
- Need to add syncing to test so that parent does not unlock and lock again
  before child has a chance to lock buffer and produce.
2009-05-30 16:46:30 +03:00
Bahadir Balban
b11d4c4607 Added mutex_control syscall for userspace mutexes.
- Compiles and Codezero runs as normal without touching mutex implementation
- Mutex implementation needs testing.

The mutex control syscall allows userspace programs to declare any virtual
address as a mutex lock and ask for help from the kernel syscall
for resolving locking contentions.
2009-05-29 15:34:04 +03:00
Bahadir Balban
ab9e036cb7 Updated test pass/fail print messages for test0 2009-05-28 13:23:44 +03:00
Bahadir Balban
b977e6597e Added per-task ipc flags checking instead of the active task flags.
Previously during ipc copy, only the currently active task flags were
checked. This means the flags of whoever doing the actual copy was used
in the ipc. Now flags are stored in the ktcb and checked by the copy routine.

Current use of the flags is to determine short/full/extended ipc.
2009-05-28 11:50:39 +03:00
Bahadir Balban
53310aa31b Extended IPC Support added.
Benefits & Facts:
- Messages up to 2 kilobytes may be sent.
- Both parties may use non-disjoint user buffers. E.g. any userspace address.
- Userspace buffers can page fault.
- Page faults punish timeslice of only the faulting thread.
- Any number of extended ipcs can take place at any one time, since
  only ktcbs of ipc parties are engaged. No global buffer is used.
  - This also provides smp-safety benefit.

Disadvantages:
- There is triple copying penalty. This has to be done:
  - Sender buffer to sender ktcb
  - Sender ktcb to receiver ktcb
  - Receiver ktcb to receiver buffer.
  This is due to the fact that buffers can be on non-disjoint userspace addresses.

If you want to avoid disadvantages and lose some of the benefits,
(e.g. address freedom, shorter copy size) use FULL IPC.
2009-05-27 14:36:11 +03:00
Bahadir Balban
3ff519439b Added first part of extended ipc support.
- Extended ipc tests
- Need to copy from ktcb-to-ktcb instead of ktcb-to-user
- Need to check flags of both ipc parties before ipc copy type.
2009-05-27 14:07:17 +03:00
Bahadir Balban
93c7cf1995 Fixed fork() errors where forked thread is a copy of any cloned thread in parent address space.
Upon fork, child was created in a new space but as a copy of any
cloned thread in the parent space. This was due to the search of forker thread
by its space id (which is shared among many cloned threads).

Now fixed.
	modified:   src/api/thread.c
	modified:   tasks/mm0/src/task.c
2009-05-26 17:02:32 +03:00
Bahadir Balban
bece68fbf7 Fixed omission of if curly brackets causing stack corruption.
Initialization a local pointer variable was only done in some conditions
causing the uninitialized pointer to corrupt kernel stack of current.
2009-05-25 12:12:21 +03:00
Bahadir Balban
5ac5889a0f Unstable changes for ipc - Fork fails for some reason 2009-05-23 18:43:55 +03:00
Bahadir Balban
379f7ab2b1 Added the omitted utcb.h to mm0 2009-05-19 16:20:05 +03:00
Bahadir Balban
cc96e2c86c Full IPC working.
- Test0 has a full ipc mr read/write test.
- A full ipc occurs for definite only if both parties use the FULL IPC flag.
  Otherwise the thread that makes the ipc copy rules on whether it was a short
  or a full copy.
2009-05-19 15:39:01 +03:00
Bahadir Balban
b950ec323d Removed object files that were tracked by mistake. 2009-05-17 20:54:26 +03:00
Bahadir Balban
40e088b042 Modifications towards full ipc
- Added a full ipc send/recv test
- Removed non-zero value checking in r2 for ipc that was there
  to catch inadvertent full ipc calls.
- Added correct hanlding for read/write mrs for current status of utcb.

TODO:
- Add mapping of every utcb to every task for privileged access so that
  the kernel can access every utcb without switching spaces.
- Removal of same mappings
- Upon thread creation need to copy page tables accordingly i.e.
  each task will have its own utcb mapped with USER access, but every
  other utcb as kernel access only. Need to handle this case upon page
  table copying.
2009-05-17 20:49:13 +03:00
Bahadir Balban
93368447f9 Added kernel + libl4 changes for full and extended ipc.
- Short ipc working as normal. Full/extended ipc haven't been tested.
- Added automated compilation and inclusion of test executable in test0.
2009-05-15 19:14:40 +03:00
Bahadir Balban
814eba43dd l4lib changes to accomodate extended and full ipc.
- Added ARM register ipc usage explanation to glue/arm/message.h
- In the current design, the unused r2 register is a system register
  that kernel checks for ipc flags such as:
  - IPC type: e.g. full or extended.
  - In extended IPC, MR index containing message buffer ptr.
  - In extended IPC, message size
2009-05-14 20:23:10 +03:00
Bahadir Balban
548617660f Added l4_send/receive full/extended ipc prototype proposals 2009-05-14 18:38:28 +03:00
Bahadir Balban
e6a81b0783 Cleaned some printfs in mm0 2009-05-14 15:15:30 +03:00
Bahadir Balban
f37cadf5c8 File opener count was not decreased in vm_file_put 2009-05-14 13:07:10 +03:00
Bahadir Balban
3b8386fe7d Added error handling to task_mmap_segments() 2009-05-14 13:00:27 +03:00
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
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