From: Andre Schwarz <andre.schwarz@matrix-vision.de>
To: linux-ppc list <linuxppc-dev@ozlabs.org>
Subject: user memory access problem
Date: Tue, 17 Jun 2008 14:41:55 +0200 [thread overview]
Message-ID: <4857B113.5000300@matrix-vision.de> (raw)
Actually we're running 2.6.26-rc6 with MPC8343 and MPC5200B based boards.
Our kernel driver implements a read functions that initiates a DMA
operation into that user memory - nothing special.
For testing purposes this memory can be touched from the kernel using
memset.
1. User memory is translated to sg by get_user_pages during read syscall.
2. walk sg entries and map each page using kmap
3. memset the kmap'ed mem
4. SetPageDirty and unmap.
Running this code leads to memory corruption and SegFaults on the
Application side.
This code worked fine on 2.6.19.
Can anybody help me out here ?
"um" is a pointer to an internal struct holding the sg_list besides
other information...
for (i=0; i<um->page_cnt; i++) {
data = i & 0xff;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
kva = kmap(um->sl[i].page) + um->sl[i].offset;
#else
kva = kmap(sg_page(&um->sl[i])) + um->sl[i].offset;
#endif
if (kva) {
/* leads to SegFault ... */
memset (kva, data, um->sl[i].length);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
SetPageDirty(um->sl[i].page);
kunmap(sg_page(um->sl[i].page));
#else
SetPageDirty(sg_page(&um->sl[i]));
kunmap(sg_page(&um->sl[i]));
#endif
}
}
regards,
Andre Schwarz
Matrix Vision
MATRIX VISION GmbH, Talstraße 16, DE-71570 Oppenweiler - Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschäftsführer: Gerhard Thullner, Werner Armingeon, Uwe Furtner
reply other threads:[~2008-06-17 12:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4857B113.5000300@matrix-vision.de \
--to=andre.schwarz@matrix-vision.de \
--cc=linuxppc-dev@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.