Hi all


So far I have found my issue of memory corruption in my initialization routine.
So far I can do mapping of pages to a user space program and unmapping them correctly inside UML. So let's me explain what we do in our current box.
1. The driver allocates a big compound page to server as a pools of pages using __get_free_pages with flags __GFP_COMP.
2. The method mmap is defined and some pages are mapped to the user process for egress data using vm_insert_page on one vma of the user process.
3. Some set are allocated to DMA. When data comes, the pages are remap dynamicly to user space process to server as ingress data using vm_insert_page
4. Once the user process uses that page and data is free, we want to unmap that page from the user process page table entry but the driver wants to still have this page available for future use. For example if the egress data goes from app1 to app2 then we unmap the page from app1 and remap to app2. Or if app1 does notneed it any more then we unmap the page and then we remap for DMA.
So I was able to do the unmapping from  the user space process page table inside UML using:

    pgdp = pgd_offset(mm, addr);
    if (pgdp == NULL) return;
    pudp = pud_offset(pgdp, addr);
    if (pudp == NULL) return;
    pmdp = pmd_offset(pudp, addr);
    if (pmdp == NULL) return;
    ptep = pte_offset_map_lock(mm, pmdp, addr, &ptlp);
    if (ptep == NULL) return;
    ptep_get_and_clear(mm,addr,ptep);
    pte_unmap_unlock(ptep, ptlp);

and then decresing on purpose the map_count by 1 (only the kernel and 1 user process maximum sees that page) so that the vm_insert_page method can be called for that same page later on.

My problem is that I did not found a way to flush the tlb for that entry. What option could I have?

thanks

David Rodriguez





On Fri, Jul 11, 2008 at 4:52 PM, Jeff Dike <jdike@addtoit.com> wrote:
On Fri, Jul 11, 2008 at 03:04:34PM -0700, David Francisco Rodriguez Perez wrote:
> Program received signal SIGSEGV, Segmentation fault.
> 0x0805c2bb in copy_chunk_from_user (from=148668472, len=4040, arg=0xdd8de48)

Tell gdb to
    handle SIGSEGV pass noprint nostop

> Other crash!!!
>
> NI15 # loadmodule
> Initializing with Board Type: 0x52012001
> Loading module qdisp with parameter qdisp_board_type=0x52012001 slot=15 ...
> queue_dispatch: Allocated 255 12KB packet buffers
> Qdispatcher loaded
> NI15 # Slab corruption: size-32768 start=0fcb0000, len=32768
> 000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Dunno about this one.  Since you're playing inside the kernel, I'll
assume it's your fault until you provide convincing evidence otherwise
:-)

                               Jeff

--
Work email - jdike at linux dot intel dot com