h1. UVM Porting Project
The goal of this project is to port UVM from NetBSD. UVM is going to be completely re-implemented in order to remove the BSD license from the code. Currently, however, we are more interested in getting UVM ported than license issues so the rewrite has been postponed until after we have UVM working in the FMI/OS kernel. In this way any functional changes to the IPC system can be finalized as soon as possible. Once UVM is ported we can start cleaning up the functionality we don't need and re-implementing the code we do need.
I've been avoiding this last step for over a year now, and in order to continue to avoid it I'm starting on an alternate vm: DiscussionsRtmkVm.
h1. Status
- Creating libuvm build target - Done (patch-3)
- Updating pre-processor directives - Done (patch-5)
Porting necessary primitives (@lockmgr@, @ltsleep@ and plenty more) - Done * UVM code compiles (patch-6) * UVM code links (patch-7) * FMI/OS still runs (patch-10)
When this step is finished UVM will basically be dead code in a working FMI/OS kernel. This way I can make sure I have everything UVM depends on already in the kernel, and any part of FMI/OS I've changed (for example the semaphores now use @ltsleep@) still works.
New bringup code - Done
Currently the kernel lies in the first 4MB of physical memory, and when the page tables are initially setup the first 4MB of virtual address space is mapped directly to the first 4MB of physical memory. This saves us from writing boot code that runs in a different address space than the rest of the kernel. I would like to maintain this behaviour because it's quite sexy and having kernel space mapped above user space always seemed alien to me. Please comment if you see something bad about this that I do not. In order to do this I am going to have to modify all UVM and pmap code that assumes kernel space is above user space. * Turn UVM upside down (patch-12) * New page table initialization (patch-13)
After the really important page directory slots are setup, we map in everything else just so FMI/OS will still boot. This will be changed soon because UVM is supposed to manage all that. * UVM initialization (patch-14)
In order to get @uvminit()@ working I had to rewrite @malloc()@ to use @uvmkm@ calls. The new page directory (cr3) setup maps the first 4MB (now depending on a define: @NKPTP@) one-to-one, the rest of kernel space gets page table pages, but no mappings in them. The recursive mapping is setup between kernel space and user space. After that all free physical memory is loaded into @uvmpagephysload()@ and @uvminit()@ is finally called. This is as far as the kernel gets before hitting a panic in @hat.c@ that's a placeholder for future work.
Replacing old vm functionality - Done * Page fault handling (patch-15)
I nuked @vasfault@ (@vmfault.c@) and replaced it with a call to @uvm_fault@, but this can't be tested until a user process faults. I suppose the next step should be: * Executing boot servers (patch-16)
This is a real disgusting hack: I added @uvmmapnoquestionsasked@ to try and create a mapping between a fixed virtual address and a fixed physical address where the pages are already loaded (by GRUB). I couldn't figure out how to do this easily with existing UVM functions. The other option I was considering is to create a new type of memory object like an aobj that is fixed to a specific range of physical memory. Regardless, the fault code works and the kernel boots into userland until namer tries to @mmap@. * pager, mmap, munmap (patch-17)
This is a pretty big patch! I've merged the @uvmvnode.c@ and @psetfod.c@ pagers to create @uvmfod.c@ to handle @MAPFILE@ (this pager is actually incomplete and untested) and merged the @uvmdevice.c@ and @psetmem.c@ pagers to create @uvmphys.c@ to handle @MAPPHYS@ (this pager is untested too, but it's so simple what could go wrong?). The @uvmaobj.c@ pager is used for @MAPANON@. Many more combinations of flags to @mmap@ are now valid. I also tracked down a few bugs in the previous patch and a bug in pmap. The kernel now boots until namer tries to @msg_receive@. * IPC (patch-18)
This patch mainly deals with @seg.c@ which contains the routines for dealing with segments of memory associated with IPC messages. Memory segments are mapped into the receiving process's address space using @uvmmapexport@ unless it's a "kernmem" segment in which case it's copied into an anon. I also nuked the hat layer in order to smoke out some bugs I was having that ended up being a locking problem in @munmap@. Now the kernel boots until @dos@ calls @forkthread@. * exec, fork (patch-19)
I had to rethink how segments work, the map entry passing doesn't cut it because it's possible at the time between @makeseg@ and @attachseg@ for memory to dissappear. So now @makeseg@ loans out the pages to an array of anons, @attachseg@ maps them in and uses @pmapenter@ to make them writable, and @detachseg@ unmaps them and in doing so breaks the loan. The @fork@ and @forkthread@ calls were easy, UVM already had the perfect functions for the job. For @exec@ I had to find a way to keep the @MAPNODEST@ mapping which is no longer supported, so I decided to just copy it in to kernel memory and copy it back out after the rest of the address space has been setup. This is a better behaviour because it's possible the exec'd process might need that area of memory for one of it's segments, however unlikely. Fill-on-demand objects now support reading from a port but not writing yet. That should be quite easy to add when we need it. Oh, and we now boot to a login prompt! * DMA (patch-22)
Several patches later DMA finally works. I also cleaned up alot of unused code and removed swapdev, page stealing, and qio. * page stealing/swap - SKIPPED
- Pruning unneeded UVM functionality (patch-34) * @uvm_pdaemon.c@ removed completely * all swap code removed * loan to kernel functionality removed * various left-over instances of @#ifdef@ removed * statistics gathering code removed * unused @uvmmap@ functions removed
Complete re-implementation - Pending
I'm going to try to do this file-by-file to start out with, there will also be some dead-code removal in this step. * @uvmamap.c@ - _Not Started * @uvmanon.c@ - _Not Started * @uvmaobj.c@ - _Not Started * @uvmfault.c@ - _Not Started * @uvm_fod.c@ - New Code * @uvm_init.c@ - New Code * @uvmkm.c@ - _Not Started * @uvmloan.c@ - _Not Started * @uvmmap.c@ - _Not Started * @uvmpage.c@ - _Not Started * @uvm_pager.c@ - DELETED * @uvm_pglist.c@ - DELETED * @uvm_phys.c@ - New Code
h1. Resources
My arch archive http://fmios.ocgnet.org/archives/amatus@gnu.org--vsta
Current revision: kernel--uvm--1.0--patch-41
Last booting revision: kernel--uvm--1.0--patch-41
- Our UVM documentation page