Commit Graph

106 Commits

Author SHA1 Message Date
Bahadir Balban
32c0bb3a76 Converted all wait/wakeup runqueue lock/unlock paths to irq versions.
Irqs can now touch runqueues and do async wakeups. This necessitated
that we implement all wake up wait and runqueue locking work with irqs.

All this, assumes that in an SMP setup we may have cross-cpu wake ups,
runqueue manipulation. If we later decide that we only wake up threads
in the current container, (and lock containers to cpus) we won't really
need spinlocks, or irq disabling anymore. The current set up might be
trivially less responsive, but is more flexible.
2009-12-12 01:20:14 +02:00
Bahadir Balban
b1614191b3 Reverted all changes - userspace devices mapped at initialization.
This is much simpler, no device map/unmap maintenance at run-time,
no lazy device mapping etc.
2009-12-11 19:27:46 +02:00
Bahadir Balban
59af5d3794 Made changes to map devices dynamically upon irq registration.
All will be reverted since mapping devices statically is much simpler.
2009-12-11 19:02:10 +02:00
Amit Mahajan
b53cc73747 Testing Inter container IPC for UART service 2009-11-29 11:45:47 +05:30
Bahadir Balban
6e40a2b601 Preliminary irq registration call + irq capability checking
Need to add irqctrl capabilities and irq bits to device memory
caps.

Also need to initialize irq field of devmem caps.
2009-11-28 19:13:23 +02:00
Bahadir Balban
b994083e27 Added a new uattr word to capabilities.
The new word is for irq numbers.
2009-11-23 14:37:37 +02:00
Bahadir Balban
1f32e0ce0e Removed comments for fixed issues 2009-11-23 13:32:07 +02:00
Bahadir Balban
877b2cedc7 Integrated libl4thread with libl4. Added device number to device caps.
A 16-bit device number or id further distinguishes a device on the
system in addition to the device type. This is meant to be used for
the very first identification of the device for further probing. Any
further info is available by userspace mapping and probing.
2009-11-22 21:34:18 +02:00
Bahadir Balban
19b4c6c4c1 Moved capability struct to api/capability.h for userspace coherence
Userspace often breaks as we change the capability structure. Now
structure is under api/ so userspace can also update with changes.
2009-11-22 15:08:29 +02:00
Bahadir Balban
a3cfa2ac9b Added a device attribute to capabilities - In progress
Followed the kernel physical memory reservation convention
with devices. Devices that are possessable by userspace
are created as boot-time capabilities and placed under the kernel
resources devmem_free capability list. Any userspace container
that is defined with the possession of the device would delete the
device capability making it unavailable to further requests.
2009-11-21 23:45:58 +02:00
Bahadir Balban
d826de2eea Initial work to introduce device types and device capabilities 2009-11-21 15:00:42 +02:00
Bahadir Balban
caa7ac0764 Put cinfo array into initdata section. Added more precision in bootmem
cinfo array is now freed along with other init memory.
bootmem allocator memory is reduced to be completely used up.
free boot memory now prints the used free memory as well.
2009-11-21 13:35:53 +02:00
Bahadir Balban
5bff5b5fbf Reduced maximum number of pagers to 1, and boot-time capabilities to 16
Each container was taking up more than 3KB of space at boot-time structures
This was due to having 4 pagers and 32 boot-time capabilities for each. This
caused the boot-time kernel size to vary a lot with capabilities. The new
numbers are optimum.

Particularly we always have a single pager per container, even though the
array structures allow more. Single pager makes container-wide privileges
and management simpler.
2009-11-21 12:31:03 +02:00
Bahadir Balban
5ebc0bb9ac Removed capinfo target_type field. Same info expressed in rtype field 2009-11-17 13:43:25 +02:00
Bahadir Balban
b933db1e36 Fixed target symbol parsing in pre-typed capabilities
Also renamed CONT to CONTAINER on certain symbols
2009-11-17 12:34:59 +02:00
Bahadir Balban
8856609896 cinfo is compiling with new changes 2009-11-16 21:25:38 +02:00
Bahadir Balban
b50c3f6f2b Half-way through prepare_capability() 2009-11-16 18:51:36 +02:00
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
d43fa1d3ae Simplified cap id finding and destroying it.
It is not very straightforward to reach a capabilities list. We
now use a single function to find out a capability by its id and
its list, since the two are used frequently together (i.e. cap
removal and destruction)
2009-11-09 23:50:03 +02:00
Bahadir Balban
f912f28731 Clarified a few confusing definitions in ipc.c 2009-11-09 22:59:24 +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
b136b79a2d Capability replicate/deduce/share tested with mm0. 2009-11-07 23:45:57 +02:00
Bahadir Balban
e8f002f879 Fixed most of userspace (mm0) for capability manipulation 2009-11-07 19:43:05 +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
d9520adb55 Added means to search for threads in other containers
Thread ids now contain their container ids in the top 2 nibbles.
Threads on other containers can be addressed by changing those
two nibbles. The addressing of inter-container threads are
subject to capabilities.
2009-11-04 20:56:57 +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
db57c598b0 Merged MAP and VIRTMEM/PHYSMEM capabilities into one.
VIRTMEM and PHYSMEM are theoretically separate resources to be
protected than a MAP resource, which is meant to protect the syscall
privileges.

In practice MAP is always used together with a VIRTMEM and a PHYSMEM
resource, therefore reach VIRTMEM/PHYSMEM resource is now merged with
the MAP capability, combining the micro-permission bits.
2009-11-04 15:26:47 +02:00
Bahadir Balban
9248328dd3 Pager struct allocated from boot memory and never referenced after boot.
We still have to have the pager structs because they possess intermediate
data during boot up such as for transferring of capability lists to
boot stack one-by-one, and then to newly generated ktcbs.
2009-11-03 15:09:28 +02:00
Bahadir Balban
6c69f181db First step in detaching pager struct from tasks 2009-11-03 14:50:22 +02:00
Bahadir Balban
83a740f597 A better locking scheme for address spaces.
Same shall be done for the tcb list.
2009-11-01 14:32:55 +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
638df9e238 Simultaneous exit/thread_destroy working
Reiterating again to simplify:

Working:
 - Pager issues destroy, client also issues exit
   they work in sync.

Missing
 - Pager killing itself
 - Pager killing all children while killing itself
 - Pager waiting on children
2009-10-31 18:45:22 +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
Bora Sahin
2571dabc18 Fixes to the scheduler timeslice management.
One is related to the time distribution when a new child is created.
If the parent has one tick left, then both child and parent received
zero tick. When combined with
	current_irq_nest_count = 1
	voluntary_preempt = 0
values, this caused the scheduler from being invoked.

Second is related to the overall time distribution. When a thread
runs out of time, its new time slice is calculated by the below
formula:
	new_timeslice = (thread_prio * SCHED_TICKS) / total_prio
If we consider total_prio is equal to the sum of the priorities of
all the threads in the system, it imposes a problem of getting
zero tick. In the new scenario, total_prio is equal to the priority
types in the system so it is fixed. Every thread gets a timeslice
in proportion of their priorities. Thus, there is no risk of taking
zero tick.
2009-10-31 15:08:53 +02:00
Bahadir Balban
c3c6c10cf7 Reimplemented kill/suspend
It seems to work fine except an undefined instruction is generated
from posix userspace occasionally
2009-10-30 21:34:10 +02:00
Bahadir Balban
f3c0a38fa9 Some not-very-well working progress on grouply exit.
Going to start from scratch.
2009-10-30 19:52:52 +02:00
Bahadir Balban
118fc795d9 Added wakeup call during exit in case pager was trying to suspend us. 2009-10-30 12:45:31 +02:00
Bahadir Balban
26aa62d2ea Added different paths of exiting for pager and its children.
Created a task_dead list on pager for children to move to when
they exit.
2009-10-30 12:00:05 +02:00
Bahadir Balban
a6c61e05b9 l4_exit() works with a reasonable sched_die_sync()
Next: Killing other tasks more cleanly, and waiting on children
2009-10-29 22:44:58 +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
83ce4280b0 Some capability checking progress 2009-10-24 18:44:47 +03: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
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
9c06bea41a Changed name of kernel_container to kernel_resources 2009-10-20 13:14:49 +03:00
Bahadir Balban
62c4249d95 Renamed many thread_* line of calls.
Renamed so that task_* gets a ktcb directly, and thread_* line of
calls make the search for the ktcb.
2009-10-19 19:24:40 +03:00