mmap implementation for cdev
Filippo Sironi
filippo.sironi at gmail.com
Sat Dec 3 09:06:17 UTC 2011
Dear all,
I've a strange problem I cannot understand...
I implemented a piece of code within the FreeBSD 7.2 kernel that basically allocate a per-thread memory page to store a certain amount of information that must be read and written without crossing user to kernel and kernel to user boundaries.
To read and write the memory page I decided to allocate it in kernel space and then mmap'ing it to user space using a "virtual cdev" as an entry point for user space threads. The implementation of the mmap I came up with is really trivial, I basically do:
*paddr = vtophys(curthread->private_info);
Now for the problem.
I enter the mmap and private_info is the correct kernel space virtual address, each thread as its own address and the physical address - returned by vtophys - is different too. The problem is that when I come back to user space all the threads write in memory page mapped by the first thread that called the mmap leaving their memory pages untouched.
This problem bugs me but I cannot find a solution. I don't really understand the behavior.
Any ideas?
Thanks a lot,
Filippo
More information about the freebsd-hackers
mailing list