mmapping kernel buffer into user space

mmapping kernel buffer into user space

Post by Shashi Ra » Thu, 02 Dec 1999 04:00:00


i am writing a kernel device driver that has a statically allocated
buffer which it populates with some computed data. a user task is allowed
to access this buffer through the select/poll interface and mmapping.

however, the user task reads a stream of 0xFF's from the buffer, which is
not what the kernel stashes in the buffer. i was wondering what the
problem was - i am quite sure i am missing something, just cant figure
what? thanks for any help on this one!


linux kernel 2.2.12, uniprocessor kernel on a mobile pentium II
i ensure that the buffer is page aligned

the xxxmmap() function looks like the one for /dev/mem except the
vma->vm_offset is replaced by the start address of the kernel buffer. it
doesnt help even if i pass this start address through __pa() before
calling remap_page_range()

i am wondering if this has something to do with PAGE_OFFSET, or my kernel

thanks, shashi

Shashikant K. Rao                               my opinions, not intel's



1. mmap()-problem with kernel space buffer

        in my VMEBus driver for the Universe PCI/VME Bridge i
encountered a strange problem:
I allocated (via __get_free_pages) a buffer in kernel space and
mmap()ed that into user space with the followin code in the mmap()
function of the driver:
     retval = remap_page_range(vma->vm_start,
                                + virt_to_phys(p->DMA_buffer),
                                vma->vm_end - vma->vm_start,
Then i can do DMA transfers (PCI Busmaster DMA) from this buffer to
the VMEBus and in the other direction, from VME to the buffer.
If i transfer from VME to the buffer the data are in the buffer,
as a printk() in the driver shows --- but in the user space the
mmap()ed buffer still contains only zeroes, even if a mmap() after the
DMA transfer.
If i write from userspace into the mmap()ed buffer the data appear in
the kernel buffer and can also be transferred to the VMEBus.  I am at
a loss about the cause, so please give a hint at what is wrong.


$RCSfile: .signature,v $ $Revision: 1.14 $               Phone: +49 228 73 2447
Dr. Juergen Hannappel           Office: W148                FAX +49 228 73 7869   Nussallee 12, D-53115 Bonn, Germany

2. linux box slows when nic card activated

3. Help needed with mmap (Buffer passed from Kernel to User)

4. Can C2 and YP work together ?

5. Mapping kernel space to user without mmap call

6. What does this stuff mean, please.

7. Question: is there a Kernel equiv. of the user space mmap()?

8. Newfs, IPI Drives, and greater than 2-gig filesystems

9. mapping buffers from kernel to user space

10. Allocating buffers in kernel/user space

11. Kernel space to user space

12. exchange data from user space to kernel space

13. kernel space access to user space functions