Commit Graph

54 Commits

Author SHA1 Message Date
Bahadir Balban
2ba4736a8b Cleaned up various bits with capability syscalls.
Made grant interace same as other calls.
Corrected counting and reading of task capabilities by applying it
to all cap lists that a task has right.
2009-11-10 16:15:14 +02:00
Bahadir Balban
f912f28731 Clarified a few confusing definitions in ipc.c 2009-11-09 22:59:24 +02:00
Bahadir Balban
8b12db741f Moved generic ipc flags to api/ipc.h 2009-11-09 22:01:44 +02:00
Bahadir Balban
78917835c7 Substantially fixed cap_split() behaviour.
Need to fix ipc flags capability checking yet.
2009-11-09 19:15:52 +02:00
Bahadir Balban
b24c8eb89d Capability replicate/split/destroy/grant working for test0 ipc.
Implemented a protocol between a client and its pager to
request and get a capability to ipc to another client of the pager.

Pager first ensures the request is valid from its client.
It then tries to use a greater capability that it possesses, to
produce a new capability that the client requested. Once the kernel
validates the correct one and replicates/reduces it to client's
need, it grants it to the client.
2009-11-09 00:40:07 +02:00
Bahadir Balban
dc03c7b130 Implemented a protocol between client and pager for requesting caps.
In posix, test0 makes inter-space ipc for testing extended ipc. This
correctly fails when only the cap to ipc to pager is given to all tasks
in the container.

In order to overcome this problem, the tasks who fork for doing ipc to
each other make a request to the pager to get capabilities to do so.

Pager finds its own widened ipc capability over the container, replicates
it, validates and reduces it to desired boundaries (i.e. just ipc betw.
two spaces) and grants it as IMMUTABLE to requesting tasks.

This protocol may be useful in implementing a client/server capability
request relationship. Code builds but untested.
2009-11-08 14:15:33 +02:00
Bahadir Balban
3728e7ef1e Capability manipulation syscalls
Support for capability replicate, share, grant, deduce, and split.
The code builds, but hasn't been tested.
2009-11-07 15:29:52 +02:00
Bahadir Balban
f7565118f1 Revert "Merge branch 'libl4thread' of git://www.b-labs.co.uk/bora/git/codezero into bora"
This reverts commit 3f870b540f.
2009-11-05 19:17:36 +02:00
Bahadir Balban
3f870b540f Merge branch 'libl4thread' of git://www.b-labs.co.uk/bora/git/codezero into bora 2009-11-05 14:59:59 +02:00
Bora Sahin
8585482bd0 THREAD_RESUME is an alias to THREAD_RUN. 2009-11-05 13:48:58 +02:00
Bahadir Balban
425193efa9 Added a flag to read registers back for sys_exregs call 2009-11-05 11:27:29 +02:00
Bahadir Balban
aeef546544 Changed l4id_t type to unsigned integer. Expanded task_ids to have cid
Task ids are now unsigned as the container ids will need to be encoded
in the id fields as well.

For requests who require even more comprehensive id input, (such as
thread creation) also added is the container id so that threads
_could_ potentially be created in other containers as well.
2009-11-04 16:39:04 +02:00
Bahadir Balban
0f537ea1f5 Wait on working.
Multi-threaded apps can now wait on children to destroy.
WAIT_ON is useful when a child exists with an exit code and the pager
of the child does not want to take the hassle of destorying it via an
ipc. It provides an alternative method of synchronous thread destruction,
where the child destroys itself directly rather than the parent issuing
a destroy on it explicitly.
2009-10-31 23:28:54 +02:00
Bahadir Balban
850c645d77 Exiting tasks use EXITING signal and change states to TASK_DEAD 2009-10-31 23:13:19 +02:00
Bahadir Balban
09197d1fb1 Removed THREAD_WAIT call completely.
Simply reverse this patch to add THREAD_WAIT
2009-10-31 17:12:03 +02:00
Bahadir Balban
18ffa0b4d1 Added a TASK_CAP_LIST macro that abstracts away the primary cap list
We moved initial list of a pager's caps from ktcb to task's space
since the task is expected to trust its space.

Most references to task->cap_list had to change. Although a single
cap list only tells part of the story about the task's caps, the
TASK_CAP_LIST macro works for us to get the first private set of
caps that a task has.
2009-10-30 13:46:47 +02:00
Bahadir Balban
5840d6d696 Capability-enabled kernel running 2_posix test OK. 2009-10-27 15:59:07 +02:00
Bahadir Balban
88e3706474 Capability checking added as compiling code.
Capability checking for thread_control, exregs, mutex, cap_control,
ipc, and map system calls.

The visualised model is implemented in code that compiles, but
actual functionality hasn't been tested.

Need to add:
- Dynamic assignment of initial resources matching with what's
defined in the configuration.
- A paged-thread-group, since that would be a logical group of
seperation from a capability point-of-view.
- Resource ids for various tasks. E.g.
  - Memory capabilities don't have target resources.
  - Thread capability assumes current container for THREAD_CREATE.
  - Mutex syscall assumes current thread (this one may not need
    any changing)
  - cap_control syscall assumes current thread. It may happen to
    be that another thread's capability list is manipulated.

Last but not least:
- A simple and easy-to-use userspace library for dynamic expansion
  of resource domains as new resources are created such as threads.
2009-10-25 23:57:17 +02:00
Bahadir Balban
4a24e02151 Reorganized test container sources 2009-10-23 16:41:30 +03:00
Bahadir Balban
6093214981 Added sharing of pager capabilities with children or siblings
Pagers can now share their own private capabilities with their
paged children, or their siblings with whom they have a common pager
ancestor.

Added flags CAP_SHARE_CHILD and CAP_SHARE_SIBLINGS for that.
2009-10-23 13:50:32 +03:00
Bahadir Balban
89d49ef495 Lots of fixes, notion of pager hierarchy, fixed tgroup capability checking
Notion of pager hierarchy introduced using the existing but unused
pagerid field.

Thread creation now has two more flags TC_AS_PAGER and TC_SHARE_PAGER.
The former sets creator as pager, the latter sets creator's pager as pager.

Thread group capability sharing now correctly carries shared capabilities
to the thread group leader's tgr_cap_list list, and this list is checked
during capability checking.
2009-10-23 02:36:12 +03:00
Bahadir Balban
df776b568f Tests working up to neverending suspend - Will be fixed. 2009-10-22 22:50:50 +03:00
Bahadir Balban
0f9ea9674c Progress on capabilities
Capabilities will be shared among collection of threads. A pager
will have a right to share its own capabilities with its space,
its thread group and its container.

Currently sharing is possible with only all of the caps. Next,
it will be support for cap splitting, granting, and partial sharing
and granting.
2009-10-22 14:04:25 +03:00
Bahadir Balban
cc2d740900 Neater thread creation flags. 2009-10-21 16:58:10 +03:00
Bahadir Balban
7ba7a2e796 Added a simplified ascii_to_int() implementation.
Removed dependency on hard-coded pager id. Pager id is now passed
as an environment string `pagerid' to tasks. Alternatively, this
could take space in the utcb of each task.
2009-10-17 18:48:30 +03:00
Bahadir Balban
d3d072e47d Capability accounting for quantitative capabilities - First part done.
Need to make sure accounting charges correct containers during init.
Therefore kernel resource spending must also be accounted for.
2009-08-22 12:09:51 +03:00
Bahadir Balban
02a3f1ac91 Pager works until end of init_physmem_secondary 2009-08-09 17:22:13 +03:00
Bahadir Balban
961b255257 Replaced kread and kmem_control syscalls with capability_control and container_control respectively. 2009-08-06 16:22:55 +03:00
Bahadir Balban
7e8845abf8 Code that compiles until initialization of containers and pagers. 2009-08-02 23:43:14 +03:00
Bahadir Balban
723cf7bde9 Code that compiles and works up to initializing the first memcache. 2009-07-29 19:08:29 +03:00
Bahadir Balban
0dd8918ae5 Remove all references to ARM registers in system call arguments. 2009-06-10 17:30:02 +03:00
Bahadir Balban
49d47abe97 Evaluated license issues, made some other enhancements. 2009-06-08 17:00:21 +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
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
577cc34db6 Changed full boolean with ipc flags and simplified ipc calls. 2009-05-23 13:52:06 +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
8528e2e1ba Modified the kernel and all tasks with well-formatted printout messages. 2009-05-12 11:25:14 +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
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
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
c54d505709 Changes towards exit. Need to fix thread suspend first. 2008-09-27 22:15:34 +03:00
Bahadir Balban
1ea21d84bd Updated test0 with a forktest. Fixed timeslices. Updated kmem usage calculations.
- test0 now forks 16 tasks that each modify a global variable.
- scheduler now gives 1/10th of a second per task. It also does not increase timeslice
  of a task that has scheduled.
- When a memory is granted to the kernel, the distribution of this memory to memcaches
  was calculated in a complicated way. This is now simplified.
2008-09-17 15:19:37 +03:00
Bahadir Balban
df2317e7aa exchange_registers(), modified thread_control calls seem to work
- Fixed do_mmap() so that it returns mapped address, and various bugs.
- A child seems to fork with new setup, but with incorrect return value.
  Need to use and test exregs() for fork + clone.
- Shmat searches an unmapped area if input arg is invalid, do_mmap()
  should do this.
2008-09-15 15:59:44 +03:00
Bahadir Balban
4fb5277123 Towards finishing exchange_registers()
- Added mutex_trylock()
- Implemented most of exchange_registers()
- thread_control() now needs a lock for operations that can modify thread context.
- thread_start() does not initialise scheduler flags, now done in thread_create.

TODO:
- Fork/clone'ed threads should retain their context in tcb, not syscall stack.
- exchange_registers() calls in userspace need cleaning up.
2008-09-13 18:07:00 +03:00
Bahadir Balban
4ffdb45550 Fixed 2 more fork issues
Added setting of spsr for the new task.
Added newly created task into mm0's global task list.
2008-08-27 22:27:53 +03:00
Bahadir Balban
476bac5142 Cleaned up all compile errors. 2008-08-25 16:59:00 +03:00
Bahadir Balban
69db3a04c0 Towards implementing fork.
Issue is that shadow object references from original objects are into
the links rather than the objects.
2008-08-19 18:03:23 +03:00
Bahadir Balban
a87914910c Added a new system call sys_timer.
sys_timer accumulates timer ticks into seconds, minutes, hours and days.
It's left to the user to calculate from days into a date. It is not yet
known if the calculation is even roughly correct.

Reduced 2 kmem_reclaim/grant calls into one kmem_control call.
2008-04-18 00:46:29 +01:00