user memory access problem

Andre Schwarz andre.schwarz at matrix-vision.de
Tue Jun 17 22:41:55 EST 2008


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



More information about the Linuxppc-dev mailing list