lkml.org 
[lkml]   [2004]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectProblem with remap_page_range/mmap
Hello,

I have a problem with mmaping memory to userspace.

It´s very simple:

addr = __get_free_pages(GFP_KERNEL,0);
int atoll_fops_mmap(struct file *filp, struct vm_area_struct *vma)
{
vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO;

if(remap_page_range_A(vma,
vma->vm_start, addr, 4096,
vma->vm_page_prot)) {
printk("remapping send space failed\n");
return -ENXIO;
}
*(unsigned long *)addr = 0x23;
printk("mmap finished, first bytes: %lx\n",*(unsigned long *)addr);
return 0;
}
int atoll_fops_release(struct inode *inode,struct file *filp)
{
printk("release, first bytes: %lx\n",*(unsigned long *)addr);
return 0;
}

complete code is here:
http://debian.christian-leber.de/mmap_problem/atollinit.txt
or as tar
http://debian.christian-leber.de/mmap_problem.tar.bz2

The stupid little testprogramm:
ptr=mmap(NULL,4096,PROT_READ|PROT_WRITE,MAP_SHARED,fdopen,0);
if(ptr==-1) printf("ERROR\n");
*(ptr) = 0x42;
printf("%lx\n",*(ptr));


This works as expected with 2.6.3 on IA64
Testprogramm gives out "42"
and in the kernel log:
mmap finished, first bytes: 23
release, first bytes: 42


Now it gets odd:
On a Dual PIII; another one; dual xeon; another one; and a P3 laptop

The testprogramm gives out "ffffffff"
In the kernel log:
mmap finished, first bytes: 23
release, first bytes: 23

So never anything is written to memory.
(it also doesn´t depend on the kernel, i tried several
versions/configurations)


On a Duron (also tried with exact the same kernel from one of the
systems above), the Testprogramm gives correct output, but the kernel
log says:
mmap finished, first bytes: 23
release, first bytes: 23

So also nothing is actually written to the memory.


Is that a bug (can´t imagine) or do I do a really stupid error?



Christian Leber

--
"Omnis enim res, quae dando non deficit, dum habetur et non datur,
nondum habetur, quomodo habenda est." (Aurelius Augustinus)
Translation: <http://gnuhh.org/work/fsf-europe/augustinus.html>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.054 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site