Since commit c84bf6dd2b83 ("mm: introduce new .mmap_prepare() file callback"), The f_op->mmap hook has been deprecated in favour of f_op->mmap_prepare. This was introduced in order to make it possible for us to eventually eliminate the f_op->mmap hook which is highly problematic as it allows drivers and filesystems raw access to a VMA which is not yet correctly initialised. This hook also introduced complexity for the memory mapping operation, as we must correctly unwind what we do should an error arises. Overall this interface being so open has caused significant problems for us, including security issues, it is important for us to simply eliminate this as a source of problems. Therefore this series continues what was established by extending the functionality further to permit more drivers and filesystems to use mmap_prepare. We start by udpating some existing users who can use the mmap_prepare functionality as-is. We then introduce the concept of an mmap 'action', which a user, on mmap_prepare, can request to be performed upon the VMA: * Nothing - default, we're done * Remap PFN - perform PFN remap with specified parameters * Insert mixed - Insert a linear PFN range as a mixed map * Insert mixed pages - Insert a set of specific pages as a mixed map * Custom action - Should rarely be used, for operations that are truly custom. A hook is invoked. By setting the action in mmap_prepare, this alows us to dynamically decide what to do next, so if a driver/filesystem needs to determine whether to e.g. remap or use a mixed map, it can do so then change which is done. This significantly expands the capabilities of the mmap_prepare hook, while maintaining as much control as possible in the mm logic. In the custom hook case, which unfortunately we have to provide for the obstinate drivers which insist on doing 'interesting' things, we make it possible for them to invoke mmap actions themselves via mmap_action_prepare() (to be called in mmap_prepare as necessary) and mmap_action_complete() (to be called in the custom hook). This way, we keep as much logic in generic code as possible even in the custom case. The point at which the VMA is accessible it is safe for it to be manipulated as it will already be fully established in the maple tree and error handling can be simplified to unmapping the VMA. We split remap_pfn_range*() functions which allow for PFN remap (a typical mapping prepopulation operation) split between a prepare/complete step, as well as io_mremap_pfn_range_prepare, complete for a similar purpose.