Find the answer to your Linux question:
Results 1 to 3 of 3
I have this in kernel module: /*global scope declared*/ static char array[10]={1,2,3,4,5,6,7,8,9,10}; and I have functions for open close read and write works perfectly, i want to share the `array[8]` ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2012
    Posts
    3

    Kernel/Why do i get Unhandled fault: imprecise external abort?


    I have this in kernel module:


    /*global scope declared*/
    static char array[10]={1,2,3,4,5,6,7,8,9,10};


    and I have functions for open close read and write works perfectly, i want to share the `array[8]` with the user space application in the bottom of this page.

    **in the kernel module:**


    static int *my_mmap (struct file *filep, struct vm_area_struct *vma ) {

    if (remap_pfn_range(vma,
    vma->vm_start,
    virt_to_phys(array)>> PAGE_SHIFT,
    10,
    vma->vm_page_prot) < 0) {
    printk("remap_pfn_range failed\n");
    return -EIO;
    }


    return 0;


    **the application in user-space's source code:**


    #define LEN (64*1024)
    /* prototype for thread routine */

    #define FILE_PATH "/dev/my_module"


    int main()
    {
    int i=0;
    int fd = open(FILE_PATH,O_RDWR);
    int* vadr = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

    for (i=0;i<10;++i){

    printf("%d",*(vadr+i));
    }

    return 0;
    }



    I get `imprecise external abort` and no output from vadr, why is that?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,459
    Please post code inside code blocks, like this:
    Code:
    /*global scope declared*/ 
    static char array[10]={1,2,3,4,5,6,7,8,9,10};
    
    static int *my_mmap (struct file *filep, struct vm_area_struct *vma )
    {
         if (remap_pfn_range(vma, vma->vm_start, virt_to_phys(array)>> PAGE_SHIFT, 10, vma->vm_page_prot) < 0)
         {
             printk("remap_pfn_range failed\n");
             return -EIO;
         }
         return 0;
    }
    
    // the application in user-space's source code:**
    
    #define LEN (64*1024)
    /* prototype for thread routine */
    
    #define FILE_PATH "/dev/my_module"
    
    
    int main() 
    {
         int i=0;
         int fd = open(FILE_PATH,O_RDWR);	
         int* vadr = mmap(0, LEN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    
         for (i=0;i<10;++i)
         {
              printf("%d",*(vadr+i));
         }
    
         return 0;
    }
    It make it a lot easier to read. In any case, this is not sufficient to help you. Please post ALL of your kernel module code, and how you access it from your user-space code.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Aug 2012
    Posts
    3
    Thanks,

    My question is, how do I share memory between a kernel module and user space even if the block of data is not aligned to a page size.
    For example how do I share the

    Code:
    /*global scope declared*/ 
    static char array[10]={1,2,3,4,5,6,7,8,9,10};
    declared in a kernel module with a user application?

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •