Commit Graph

88 Commits

Author SHA1 Message Date
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
fd787479c3 Fixed minor faults during close path.
FIXME:
write/close/open/read sequence does not read the initially written data.
Investigate.
2008-05-23 05:42:26 +00:00
Bahadir Balban
6be310f460 Added sys_close and sys_fsync
Untested.
2008-05-23 03:59:18 +00:00
Bahadir Balban
bd8b182f1b Added syscall to update filestats (size) from pager.
After flushing written/truncated pages, stats are updated
so that vfs is synced with new file info such as its size.
2008-05-21 10:23:11 +00:00
Bahadir Balban
5efece98cd More changes 2008-05-03 15:04:16 +01:00
Bahadir Balban
0557fa8910 Gotta find a way to pass on updated file size before write_file_pages. 2008-04-26 01:03:11 +01:00
Bahadir Balban
f183b3c15e Still towards close/flush. 2008-04-25 23:06:23 +01:00
Bahadir Balban
c9b9f9d111 Towards sys_close()/sys_flush() 2008-04-25 22:14:59 +01:00
Bahadir Balban
488d9e6271 Fixed the issue that page copy offsets were not correct.
When copying file pages back and forth, we need both dst and src
offsets since the cursor offset and read/write buffer page offsets
are different. This is now fixed.

Also done some mods to close().
2008-04-25 17:07:49 +01:00
Bahadir Balban
ba725168a0 Fixed lseek. Updates to sys_read/sys_write
read and write are both called by test0. But they don't yet
work as expected. An error is in one or both. To be investigated.
2008-04-24 00:09:49 +01:00
Bahadir Balban
0629ba3c1a sys_write() "seems to" work. Also added support for sys_lseek(). 2008-04-23 14:14:45 +01:00
Bahadir Balban
59bdaf22ec Towards user buffer checking 2008-04-22 14:18:12 +01:00
Bahadir Balban
1270cfe3b3 open file descriptor references to vm files weren't properly initialised.
This fixes the issue. sys_read/write yet to be inspected.
2008-04-22 01:41:18 +01: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
a674cf2b27 Recompiled with write_cache_pages(). Implementation to be re-evaluated. 2008-04-21 00:31:16 +01:00
Bahadir Balban
e3cc14515c mm0 compiles, still previous issues on. 2008-04-20 23:34:25 +01:00
Bahadir Balban
d8d65a6301 Efforts towards sys_write.
- Added logic to calculate which pages are in the file and which are new
  for writing.
- Nearly finished the template for sys_write.
- Need to implement write_cache_pages().
- Need to distinguish dirty/clean pages and implement flushing dirty
  pages back to vfs.
2008-04-20 17:33:05 +01:00
Bahadir Balban
9992d100d7 Few fixes in libposix error checking.
size_t is a non-negative type and negative error checking didn't work. Now fixed.
Fixed various issues with reading file pages in the sys_read() path.
2008-04-20 02:12:53 +01:00
Bahadir Balban
8b3fedc18d Towards working sys_read/sys_write. 2008-04-19 15:42:13 +01:00
Bahadir Balban
9f4e400fed Minor updates to README 2008-04-19 12:28:49 +01:00
Bahadir Balban
8c4c436925 Reorganised sys_open.
vfs_create and mknod now returns the newly created vnode.
(which might be used by upper layers).
2008-04-19 00:40:48 +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
d6d97876bb Page fault handling fix.
Factored out mapping of the physical page as the final generic code
after all fault-specific handling is done.

Fixed the error that zero page didn't have an owner (devzero).

Fixed the error that struct dirent did not have the record length
field as u16 as expected by userspace.
2008-04-14 00:09:57 +01:00
Bahadir Balban
7f815dd2dd Fixed handling of pages that are SHARED and ANONYMOUS
Normally anon && shared pages need to COW once and any newer
accesses by other sharing processes should simply map the COW'ed
pages to themselves as writeable. We didn't have that but instead
every ANON && SHARED write fault was going into the COW path, causing
the same offset'ed page to be COW'ed twice.

Next: Factor out the l4_map code to a common point at the end of all
fault handling paths.
2008-04-13 17:03:11 +01:00
Bahadir Balban
7b2f9f96cf os_readdir() now using utcb as dirent buffer. 2008-04-13 16:32:34 +01:00
Bahadir Balban
81ebffdc87 VFS updates, readme updates.
Separated vfs file as a specific file. vm file is not always a vfs file.
Updated the README
sys_open was not returning back to client, added that.
Added comments for future vfs additions.
2008-04-09 16:55:54 +01:00
Bahadir Balban
dd3f35bbd4 Moved vnum to priv_data of vm_file since its only related to vfs files. 2008-03-25 23:32:51 +00: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
13b9e5407a Removed non-standard allocation of mm0 utcb.
It is now allocated in a generic way using shm_new() which creates a
posix shmat()/shmget()'able utcb.
2008-03-24 00:46:31 +00:00
Bahadir Balban
35d2d275b6 Multiple above-minor updates.
- fixed is_err(x), was evaluating x twice, resulting in calling a
function x twice.

- Divided task initialisation into multiple parts.
- MM0 now creates a tcb for itself and maintains memory regions of its own.
- MM0's tcb is used for mmapping other tasks' regions. MM0 mmaps and prefaults
  those regions, instead of the typical mmap() and fault approach used by
  non-pager tasks.
  For example there's an internal shmget_shmat() path to map in other tasks'
  shm utcbs. Those mappings are then prefaulted into mm0's address space using
  the default fault handling path.

- FS0 now reads task data into its utcb from mm0 via a syscall.
  FS0 shmat()s to utcbs of other tasks, e.g. mm0 and test0.

  FS0 then crashes, that is to be fixed and where this commit is left last.
2008-03-24 00:34:14 +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
d0084b2ee0 Trivial changes in comments for copy_on_write. 2008-03-21 16:06:08 +00:00
Bahadir Balban
0b279081b6 shm file didn't initialise with VM_WRITE. Added that.
Otherwise copy_on_write() tries to create a r/w shadow which is wrong.
Also fixed the fault print functions to print SHM file type as well.
2008-03-21 16:00:20 +00:00
Bahadir Balban
b369ff6efe Added copy-on-write shared memory but untested yet.
For anonymous shm, mmap now adds a shm_file and devzero behind it
as two vm_objects. Faults are handled by copy_on_write(). Just as
shadows copy r/w pages from original files, it should copy r/w
pages from devzero into the shm_file in front.

shmat/shmget uses mmap to set-up their areas.

Untested yet so bugs expected.

	modified:   tasks/libl4/src/init.c
	modified:   tasks/mm0/include/shm.h
	modified:   tasks/mm0/include/vm_area.h
	modified:   tasks/mm0/src/fault.c
	modified:   tasks/mm0/src/mmap.c
	modified:   tasks/mm0/src/shm.c
2008-03-21 15:40:54 +00:00
Bahadir Balban
466138f125 shmat/shmget for utcbs are working for now.
faults on shared memory needs to be implemented.
2008-03-19 22:26:38 +00:00
Bahadir Balban
55d24dbbdf Managed to pass utcb information to tasks via an ipc() call.
Removed setting of tag during ipc_return(). So it does not overwrite
return value anymore.

Next stage is for the tasks to map their utcb via shmget/shmat before
accessing.
2008-03-19 02:55:31 +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
26e6366014 Added a memlayout.txt, revised README, reduced env size to 4kb 2008-03-18 18:21:09 +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
1cc6a87547 Previous commit. 2008-03-14 18:53:53 +00:00
Bahadir Balban
b0900ad6c3 Forgotten to add vma to file reference in do_mmap(). This adds that. 2008-03-14 15:39:25 +00:00
Bahadir Balban
ed68f934aa Fixed few more issues
The svc images must be pushed to boot file list in correct order
otherwise if test0 starts earlier than fs0, it gets fs0's predefined
thread and space id (since that's the first unallocated one) and
fs0 fails to initalise. In the future we can pre-allocate ids from
the kernel but current temporary fix is simple enough to use.
2008-03-14 15:39:00 +00:00
Bahadir Balban
dc3b63d924 Fixed detection of devzero file.
Fixed adding VMA_ANONYMOUS flag explicitly if no file was given
2008-03-14 15:37:10 +00:00
Bahadir Balban
2ecc7612c3 Fixed the error that file length was referenced without checking that
the file pointer was valid.
2008-03-14 15:36:25 +00:00
Bahadir Balban
4f87b6672e Few map_address fixes to mmap() 2008-03-13 00:56:21 +00:00
Bahadir Balban
d27f942702 Very minor fixes. 2008-03-13 00:40:12 +00:00
Bahadir Balban
e304bb26c6 Clarified handling of anon and non-anon shared mappings. 2008-03-12 23:10:50 +00:00
Bahadir Balban
d718b8efd5 Got mm0 to compile. A lot of issues expected. 2008-03-12 22:58:26 +00:00