Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Dec 2011 09:42:44 +0100
From:      Filippo Sironi <filippo.sironi@gmail.com>
To:        freebsd-hackers@freebsd.org
Cc:        Sironi Filippo <filippo.sironi@gmail.com>
Subject:   mmap implementation for cdev
Message-ID:  <A51F9B30-A71A-49A5-B684-16EC3C127BC9@gmail.com>

next in thread | raw e-mail | index | archive | help
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 =3D 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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A51F9B30-A71A-49A5-B684-16EC3C127BC9>