locking user space memory in kernel

From: Eli Cohen
Date: Sun Mar 21 2004 - 06:18:30 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/