public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Problem with remap_page_range/mmap
@ 2004-03-25 23:48 Christian Leber
  2004-03-26  7:17 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Leber @ 2004-03-25 23:48 UTC (permalink / raw)
  To: linux-kernel

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-26 10:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-25 23:48 Problem with remap_page_range/mmap Christian Leber
2004-03-26  7:17 ` Christoph Hellwig
2004-03-26  9:36   ` Christian Leber
2004-03-26  9:46     ` Christoph Hellwig
2004-03-26  9:58       ` Hugang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox