macoskernelvirtual-machinexnu

What’s the role of UPL (Universal Page List) in XNU?


I’m just beginner of XNU and studying that source code.

While seeing the VM. I have three questions.

 • What is role of UPL? Is it the same to anon_vma and PST node in Linux for reverse mapping? 
 • If first answer is True, How XNU can find virtual address using upl structure?
 • If first answer is False, How XNU edit pmap entries for page in/out?

I’ve tried to find Apple developement documents But couldn’t find the answer.

Thank you.


Solution

  • I'm also interested in exploring the VM realm of xnu, so I did some initial research about your question.

    So the UPL is a wrapper for any set of pages forming memory range and sharing the same properties.

    The UPL struct itself provides a snapshot of various properties of its pages, such as whether the pages are mapped, dirty, encrypted, busy (access-blocked), or correspond to I/O memory.

    The UPL API consist of the following methods... non of them fit your need physical to virtual mapping or vise versa upl_abort upl_abort_range upl_commit upl_commit_range

    However, what I've read, UPL is the BSD equivalent to IOMemoryDescriptor from IOKit framework. and this IOKit class is pretty easy to use and it's well documented, So if your goal is sharing memory between kernel and user modes, it will do.