Input paths are now parsed at the beginning and components
put into an ordered linked list headed by struct pathdata.
Lookup functions use these components to look up vnodes.
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.
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.
Dirbuf allocation was broken, fixed it.
Added more comments on reading directories.
Issues: fs0 ought to check buf address for sys_readdir(). Currently
test0 is passing an area on its stack and fs0 is writing the data to its own
address space (i.e. an area on its own stack.)
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.
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.
- 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.
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
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.
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.
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.
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.
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.