Commit Graph

56 Commits

Author SHA1 Message Date
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
398bc0c914 debug aborts commented out 2008-09-16 11:31:44 +03:00
Bahadir Balban
4d1b649465 Fix to exregs.c functions 2008-09-15 18:16:02 +03:00
Bahadir Balban
9c2c9676e8 Added exregs_set_mr() function
Moved all exregs-related calls to libl4 since these are part of the L4 api.
2008-09-15 17:57:09 +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
0b3ab05a98 Some minor changes
Need to reimplement exchange_registers
2008-09-12 10:47:36 +03:00
Bahadir Balban
af03975dc1 Towards adding sys_clone()
Stopped working on self_spawn() - going to finish clone() syscall first.
Arch-specific clone() library call that does ipc() and cloned child setup.
- Need to finish thread_create() that satisfy clone() necessities. i.e. setting up its stack.
  Question: Does the pager (and thus the microkernel) have to explicitly set SP_USR?
  Once the call is known to be successful, the library could set it.
2008-09-11 16:56:41 +03:00
Bahadir Balban
002fe79a54 Added thread group identification to c0 and libl4
tgid will be used when threads will be created in same address space.
2008-09-09 15:39:56 +03:00
Bahadir Balban
89d774f7fa Mixed changes
- Added automatic utcb map/prefaulting of forked tasks for fs0
  so that it does not need to explicitly request those tasks from mm0.
  Eliminating fs0 requests to mm0 reduce deadlock possibilities.

- Replaced kmalloc with a public malloc implementation because of a bug in kmalloc.
- Fixed a kfree bug. default_release_pages was trying to free page_array pages.
2008-09-09 13:36:42 +03:00
Bahadir Balban
6c1da12fec Mixed changes
- Adding prefaulting of fs0 to avoid page fault deadlocks.
- Fixed a bug that a vmo page_cache equivalence would simply drop a link to
  an original vmo, even if the vmo could have more pages outside the page cache,
  or if the vmo was not a shadow vmo.
- Fixed a bug with page allocator where recursion would corrupt global variables.
- Now going to fix or re-write a simpler page allocator that works.
2008-09-06 11:15:41 +03:00
Bahadir Balban
a5fa48bc2f When copying page tables, added excluding common kernel entries.
Normally common kernel entries in 2nd level page table need not get
copied to new tasks since those entries will be used commonly by all tasks.
On fork, we were copying those unnecessarily.
2008-09-01 17:26:49 +03:00
Bahadir Balban
0a9dede8f7 Fix to fork return value issue.
Mistakenly returned child pid to pager in thread_create. This is fixed.
Its not the pager but the forking task that needs this value.
2008-09-01 16:27:44 +03:00
Bahadir Balban
afc0599d49 Saving all registers in syscall so that return from fork is easier.
Child needs rewound function stack in order to reach registers r9-r12
that have original userspace values. But we jump to return_from_syscall
without rewinding the stack. Therefore to ease context restore, we save
r9-r12 on the stack as well upon syscall entry.
2008-09-01 16:19:03 +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
dad1d2d792 When creating a new thread, forgot to set its syscall_args * pointer. 2008-08-27 14:52:06 +03:00
Bahadir Balban
1ca3fce49b Changes in README. Fix to thread_control() reading wrong syscall argument register. 2008-08-27 13:39:16 +03:00
Bahadir Balban
476bac5142 Cleaned up all compile errors. 2008-08-25 16:59:00 +03:00
Bahadir Balban
1d15821acb Added ipc to notify vfs about a forked child.
TODO: Need to ensure child shmat()s its own utcb
after a fork (possibly in libposix/fork.c)
2008-08-22 00:11:06 +03:00
Bahadir Balban
3ce220f062 Changes to make sure after a fork a child process can safely return.
This copies the parent kernel stack to child only for the part where
the previous context is saved. Then the child registers are modified
so that it would begin execution from returning of the system call.
2008-08-21 16:21:08 +03:00
Bahadir Balban
dada3e0b2c Added copy_vma() function.
Sorting out return_from_fork() and kernel stack setup for the child.
2008-08-21 12:18:38 +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
f436b44e81 Changes in the README, changes to fork template. 2008-08-16 13:01:18 +03:00
Bahadir Balban
d1170211e3 Commented out printfs for pager/vfs interaction 2008-05-30 11:18:16 +03:00
Bahadir Balban
f561d885d5 Flushing pages to vfs will work, but the issue is that while vfs is
serving mm0, if it page faults, system deadlocks because mm0 is waiting to be served by vfs.

FIX: To fix this, mm0 will need to fork itself and keep a separate thread solely for
page fault handling.
2008-05-28 23:37:41 +03:00
Bahadir Balban
80470e2581 Adding reply phase to pager_sys_open()
So that open() errors on pager's side can be noticed by vfs.
2008-04-21 15:30:40 +01:00
Bahadir Balban
cff7a505e8 Changed time representation to posix style struct timeval/ gettimeofday. 2008-04-18 13:58:37 +01:00
Bahadir Balban
5563cc1c6b Minor changes on sys_time
A get/set flag determines whether to read or write time.
2008-04-18 01:03:39 +01: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
Bahadir Balban
4b1abc60a6 Various minor fixes.
Removed some commented out code.
Removed excessive printfs.
Fixed spid not initialising for mm0
Fixed some faults with fs0.

TODO:
- Need to store vfs files in a separate list.
- Need to define vnum as a vfs-file-specific data, i.e. in priv_data field of vm_file.
- Need to then fix vfs_receive_sys_open.
2008-03-24 22:39:21 +00:00
Bahadir Balban
82a7228d89 Prefaulting of utcb pages seem to work.
Next: fs0 should shmat() on others' utcbs.
2008-03-22 15:57:20 +00:00
Bahadir Balban
16617eed36 Various changes to incorporate new utcb setup.
Issues with l4_return value not reaching client side
	modified:   libs/c/include/stdio.h
	modified:   src/arch/arm/exception.c
	modified:   src/glue/arm/init.c
	modified:   tasks/fs0/src/task.c
	modified:   tasks/libl4/include/l4lib/arch-arm/utcb.h
	modified:   tasks/libl4/src/arm/syscalls.S
	modified:   tasks/libl4/src/init.c
	deleted:    tasks/libl4/tagfilelist
	modified:   tasks/libposix/open.c
	modified:   tasks/mm0/include/utcb.h
	modified:   tasks/mm0/include/vm_area.h
	modified:   tasks/mm0/main.c
	modified:   tasks/mm0/src/init.c
	modified:   tasks/mm0/src/task.c
	modified:   tasks/mm0/src/utcb.c
	modified:   tasks/mm0/src/vm_object.c
2008-03-19 02:27:53 +00:00
Bahadir Balban
d2aa9a552b Minor changes in README. Added fault debugging printfs that can be turned on/off.
Tasks boot fine up to doing ipc using their utcbs.

UTCB PLAN:

- Push ipc registers into private environment instead of a shared utcb,
  but map-in a shared utcb to pass on long data to server tasks.
- Shared utcb has unique virtual address for every thread.
- Forked child does inherit parent's utcb, but cannot use it to communicate to
  any server. It must explicitly obtain its own utcb for that.
- Clone could have a flag to explicitly not inherit parent utcb, which is the
  right thing to do.
- MM0 serves a syscall to obtain self utcb.
- By this method, upon forks tasks don't need to map-in a utcb unless they want
  to pass long data.
2008-03-17 17:09:19 +00:00
Bahadir Balban
509e949983 Added a few vm_object debug functions. Fixed few bugs.
Next issues: For every read fault, the fault must traverse the
vma's object stack until the page is found. The problem was that
we were only searching the first object, that object was a writable
shadow, and the shadow didn't have the read-only page, and the 0
return value was interpreted with IS_ERR() and failed, so address
0 was mapped into the location, and QEMU blew off.
2008-03-16 18:57:26 +00:00
Bahadir Balban
0f4a4ae5b4 Changes in README. Fixes to fault handling.
Yet to investigate why adding a printf format attribute to
stdio.h does not generate warnings for invalid arguments to printf.
2008-03-16 14:58:47 +00:00
Bahadir Balban
285e39870f Added #ifdef flags for enable/disabling data abort messages from c0 2008-03-14 15:35:41 +00:00
Bahadir Balban
4f346cea53 Added the first means to pass information between 2 tasks using the
utcb as a shared page instead of the message registers.

Implemented the code that passes task information from mm0 to fs0
using the fs0 utcb. The code seems to work OK but:

There's an issue with anon pages that they end up on the same swapfile
and with same file offsets (e.g. utcb and stack at offset 0). Need to
fix this issue but otherwise this implementation seems to work.

TODO:
- Separate anon regions into separate vmfiles.
- Possibly map the stacks from virtual files so that they can be
  read from userspace in the future for debugging.
- Possibly utcb could be created as a shared memory object using shmget/shmat
  during startup.
2008-02-29 21:56:05 +00:00
Bahadir Balban
55117c600b Back to the same fs0 bug point as before, but environment, disjoint utcb addresses
and passing of utcb address information via the environment are implemented.
2008-02-29 12:33:53 +00:00
Bahadir Balban
617d24b4f0 Modified task initialisation so that stack now comes beneath the environment
Environment is backed by a special per-task file maintained by mm0 for each task.
This file is filled in by the env pager, by simple copying of env data into the
faulty page upon a fault. UTCB and all anon regions (stack) could use the same
scheme.

Fixed IS_ERR(x) to accept negative values that are above -1000 for errors. This
protects against false positives for pointers such as 0xE0000000.

	modified:   include/l4/generic/scheduler.h
	modified:   include/l4/macros.h
	modified:   src/arch/arm/exception.c
	modified:   tasks/fs0/include/linker.lds
	modified:   tasks/libl4/src/init.c
	modified:   tasks/libposix/shm.c
	new file:   tasks/mm0/include/env.h
	modified:   tasks/mm0/include/file.h
	new file:   tasks/mm0/include/lib/addr.h
	deleted:    tasks/mm0/include/lib/vaddr.h
	modified:   tasks/mm0/include/task.h
	new file:   tasks/mm0/include/utcb.h
	new file:   tasks/mm0/src/env.c
	modified:   tasks/mm0/src/fault.c
	modified:   tasks/mm0/src/file.c
	modified:   tasks/mm0/src/init.c
	new file:   tasks/mm0/src/lib/addr.c
	modified:   tasks/mm0/src/lib/idpool.c
	deleted:    tasks/mm0/src/lib/vaddr.c
	modified:   tasks/mm0/src/mmap.c
	modified:   tasks/mm0/src/shm.c
	modified:   tasks/mm0/src/task.c
	new file:   tasks/mm0/src/utcb.c
	modified:   tasks/test0/include/linker.lds
2008-02-29 01:43:56 +00:00
Bahadir Balban
dce3a9a47c Merged some libl4 utcb headers, moved mr defs to kernel message.h
Headers 3 headers related to message registers and utcbs are now merged under
utcb.h in libl4. Some message register definitions used by the kernel are now
moved into kernel's glue/message.h. This avoids the duplication of same
definitions. Also the total number of mregs are now determined by arch-specific
kernel header, which is good.
2008-02-11 11:45:21 +00:00
Bahadir Balban
e0492d672f Kernel inspects and sets sender id instead of userspace.
Modified ipc handling so that from now on the kernel inspects and sets
the sender id if the receiver is receiving from L4_ANYTHREAD. This posed
a security problem since the receiver could not trust the sender for
sender information.
2008-02-11 11:11:17 +00:00
Bahadir Balban
57420942ba Removed unnecessary printks, fixed few minor issues. 2008-02-09 15:48:10 +00:00
Bahadir Balban
cd170c1b7c Changed unit macro to use section attribute directly.` 2008-02-09 14:33:37 +00:00
Bahadir Balban
cc23568629 Added locking to id pool allocation and free. 2008-02-09 14:30:03 +00:00
Bahadir Balban
ba0e3ada21 Few more fixes.
Boot files and tasks are now initialised together. Theads can ask for particular
space and thread ids, if they're unused. This enables us to get predefined ids for
known tasks such as the VFS task.

Fixes to README
Other minor fixes.
2008-02-09 14:24:49 +00:00
Bahadir Balban
f29c18ec09 Fixed various errors with ipc message passing.
Previously we had changed the method of setting the ipc tag from l4_ipc() call
argument to being passed as a message register.

- This change was not reflected in l4_ipc() signature as it still had a 3rd argument,
  even though ignored.

- l4_set_sender and _set_tag had their arguments wrong way around.
- Previously 5 mrs were passed onto utcb instead of 6, relying on the fact that
  l4_ipc tag argument was being passed in r3 directly, this wasnt true anymore
  with new convention, but wasn't catered for.

TODO:
- MM0 shouldn't really allocate tids itself, but use ones supplied by C0.
- Sender tid shouldn't really passed by the sender task, but rather by C0. Otherwise
  security can be easily breached by user tasks pretending to be other tasks. This
  would also save us a message register.
2008-02-06 12:26:31 +00:00
Bahadir Balban
4f2e1d3e94 Fixed various minor issues.
Tag setting before ipc via l4 libraries don't seem to work, whereas
c0 internally generated ipcs do it correctly.
2008-02-05 18:30:11 +00:00
Bahadir Balban
6b3d936933 Fixed the negligence in usr addr checking that pager has different vaddr range.
Paging-in requests seem to work.

TODO:
- Remove far/fsr information in pager and abstract away these details in c0.
- Add a npages field to page fault ipc so that multiple pages can be paged-in.
2008-02-05 17:05:36 +00:00
Bahadir Balban
fcaeabc568 Added preliminary code for paging-in, but untested yet. 2008-02-05 16:23:14 +00:00
Bahadir Balban
62df138271 mm.c clean-up
Removed some unused functions and ones with duplicate bodies.

	modified:   src/arch/arm/v5/mm.c
2008-02-05 15:43:34 +00:00