From: Christian Leber <christian@leber.de>
To: linux-kernel@vger.kernel.org
Subject: Problem with remap_page_range/mmap
Date: Fri, 26 Mar 2004 00:48:04 +0100 [thread overview]
Message-ID: <20040325234804.GA29507@core.home> (raw)
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>
next reply other threads:[~2004-03-25 23:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-25 23:48 Christian Leber [this message]
2004-03-26 7:17 ` Problem with remap_page_range/mmap Christoph Hellwig
2004-03-26 9:36 ` Christian Leber
2004-03-26 9:46 ` Christoph Hellwig
2004-03-26 9:58 ` Hugang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040325234804.GA29507@core.home \
--to=christian@leber.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox