Mac-on-Linux and VM internals
Mac-on-Linux and VM internals
- Subject: Mac-on-Linux and VM internals
- From: Samuel Rydh <email@hidden>
- Date: Sun, 7 Mar 2004 16:34:36 +0100
- Mail-followup-to: email@hidden
Hello,
I'm currently working on porting Mac-on-Linux to Darwin (MOL is virtual machine
capable of running Mac OS 9, Mac OS X and Linux).
In order to maximize speed, MOL works at a very low level. Basically
MOL hooks all exception vectors (in an OS independent manner) and takes
complete control over the MMU. The main benefit is speed (the MMU virtualization
costs almost nothing).
The low-level parts of MOL is currently implemented as a KEXT/IOKIT driver
(I will probably turn it into a pure KEXT since the IOKIT abstractions are of
little use in this case).
Currently, I have MOL working if I wire down all the RAM of the guest OS
(I have successfully booted MacOS 9). However, this is a quite
suboptimal solution. I would like to be able to use pageable memory
with MOL.
Some background about how MOL virtualizes the MMU:
- MOL "allocates" a range of VSIDs used exclusively by MOL.
- MOL maintains a private PTE hash (under Linux it is possible to share
the PTE hash with the kernel since it is only used as a cache).
- MOL is solely responsible for inserting and flushing PTEs
from the private PTE hash.
- MOL cross-references the inserted PTEs in various tables. For instance,
MOL must be able to flush an ea range of a particular VSID quickly.
Under Linux, pageable memory is handled as follows:
- All RAM pages are "owned" by the userspace part of MOL.
- When MOL maps in a userspace page, it looks to the kernel as if it is the
userspace process that accesses it. MOL looks up the physical address
and inserts one (or several) PTEs referencing it.
- When the userspace page is swapped out, the kernel flushes the PTE
of the userspace mapping. MOL hooks the pte_flush_page function and makes
sure all the PTEs inserted by MOL which alias the page are also invalidated.
What would be the best way to implement something similar under OSX?
I'm thinking about hooking mapping_remove() or hw_rem_map(). Another possibility
might be implementing a custom swapper.
Also... the documentation explicitly states that vm_map_xxx can't be used safely
from a KEXT. Why is that? I believe I don't have to use those functions but
it would be interesting to know exactly why there is a difference between
a KEXT and the kernel proper.
/Samuel
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.