locking user space memory in kernel
Hi,
I need to be able to lock memory allocated in user space and passed to my driver, in order to pass it to a dma controller that can maintain a translation table for each process. The obvious thing is to use sys_mlock() (and sys_munlock() for unlocking) but this function is not exported anymore, nore is sys_call_table. I considered marking the relevant vma->vm_flags with VM_LOCKED and calling get_user_pages but that could be overkill if I want to lock just a portion of the VMA. Currently I do some hacking to find the addresses of sys_mlock/sys_munlock. I also need to maintain a reference count on the locking /unlocking such that a region that has been locked twice will really be unlocked after unlocking twice. This needs to support partly overlapping regions. To cope with this I have implemented some code on top of calls to sys_mlock/sys_munlock to provide this functionality.
Are there more standard ways to get this functionality from the kernel? Any help is appreciated.
Thanks
Eli
Quoted 4 lines · Eli Cohen
Hi,
I need to be able to lock memory allocated in user space and passed to my driver, in order to pass it to a dma controller that can maintain a translation table for each process. The obvious thing is to use
the linux way is to do it the other way around, provide a device that userspace then can mmap......