Currently the Linux character device mmap handling only supports mmap
operations that map a single page that has an associated vm_page_t.
This does not permit mapping larger regions (such as a PCI memory
BAR) and it does not permit mapping addresses beyond the top of RAM
(such as a 64-bit BAR located above the top of RAM).
Instead of using a single OBJT_DEVICE object and passing the physaddr via
the offset as a hack, create a new sglist and OBJT_SG object for each
mmap request. The requested memory attribute is applied to the object
thus affecting all pages mapped by the request.
Longer term I think the Linux files should become a new file type instead
of a normal cdevsw. This would allow them to use fo_mmap() and to then
change io_remap_pfn_range() to actually do the mmap instead (it would
still create an OBJT_SG object for the mapping). This can be implemented
by using a d_fdopen callback in the cdevsw to install a custom fileops
(see the existing pts/ptmux code for an example). This would also allow
the Linux file ops to use f_data directly and simplify what is now done
via cdevpriv.