* user memory access problem
@ 2008-06-17 12:41 Andre Schwarz
0 siblings, 0 replies; only message in thread
From: Andre Schwarz @ 2008-06-17 12:41 UTC (permalink / raw)
To: linux-ppc list
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-17 12:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-17 12:41 user memory access problem Andre Schwarz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).