Take the 2-minute tour ×

I have a customized uio driver that allocates 2 Megs of contingous memory using get_free_pages. The user space program mmaps to the memory allocated by this uio driver. After running the user space program about 3 or 4 times, the system prints out :

BUG: Bad page state in process sh  pfn:12edc3
page:ffffea0004bb70c0 count:0 mapcount:-127 mapping:          (null) index:0x0
page flags: 0x200000000000000()

i am on kernel 3.8.x I looked at uio.c and see that software is handling the fault method, converting virtual address to page, so it would seem that uio driver should be able to handle mapping of memory allocated by get_free_pages. Can anyone explain what may be the issue? Thank you in advance.

driver code:

#define ORDER   10
#define SIZE  (2 << ORDER) * 1024

   uio_info.mem[0].memtype = UIO_MEM_LOGICAL;
   uio_info.mem[0].size = SIZE;

   uio_buffer = uio_info.mem[0].addr =
        (unsigned long)__get_free_pages(GFP_KERNEL, get_order(SIZE));

application code:


    ptr = (char *)mmap(0, SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd,

    for (ptr+=0x10000, i=j; i<(j+100); i++, ptr++) {
        printf("%#x ..", *ptr);
share|improve this question
add comment


Your Answer



Browse other questions tagged or ask your own question.