0

I am working on Linux Kernel Usrspace and Kernel space communication,

I am using two target boards, 1) Board with PPC -e500 processor 2) Board with intel x-86 processor

Following peace of code working on e500 processor but same code is giving kernel error after IOCTL call execution as

*error: returning IOCTL -1073460967 ERROR as -EFAULT, kernel error: 28*     

 //User space call
 retVal = ioctl( FD, SOME_OPERATION, &myInfo );

//Definition of structures

struct user_space_struct
{
   unsigned long A;
   unsigned long B;  //file descriptor
   unsigned long C;
   unsigned long D;
   unsigned long E;
   unsigned long F;
   unsigned long G;
};



ret = copy_from_user( (void *)&kernel_space_struct,(void *)arg, sizeof(struct    user_space_struct) );

//Kernel space call

    if( ret != 0 ) {
        printk("In Kernel space copy_from_user() failed \n");
        break;
    }

Can anyone please help me to understand why I am getting this error.

Thanks in advance!

  • What is the definition of struct `user_space_struct`? And of myInfo? Could you be running into struct padding differences across the kernel boundary, so that `sizeof(struct user_space_struct)` isn't the correct value? – Peter Sep 03 '14 at 17:36
  • @peter .. Thanks for input. The definition of user_space_struct and myInfo is same. Both borads 1) Board with PPC -e500 processor and 2) Board with intel x-86 processor are having 32 bit operating system. Could you please let me know how check Padding differences accross the kernel boundary and also can you suggest how avoid it....Thanks! :) – Pravin.2087 Sep 06 '14 at 15:45
  • Paste the entire struct definition into your question. – Peter Sep 08 '14 at 13:07
  • @Peter ..Thanks for you help peter. I have pasted entire struct definition in my question (user_space_struct) – Pravin.2087 Sep 09 '14 at 18:11
  • @peter .. Also I printed size of sizeof(struct epc_diskop_ioctl_param) and sizeof(infoD) both are equal to 28 bytes. – Pravin.2087 Sep 12 '14 at 12:24
  • Those all look fine. The problem must lie elsewhere, and you haven't supplied enough code to guess at where. – Peter Sep 12 '14 at 12:47
  • @Peter :: http://stackoverflow.com/questions/8265657/internal-working-of-copy-from-user ...Can this be reason for the copy_from_user failure ...? – Pravin.2087 Sep 24 '14 at 12:40
  • It explains HOW the faults are being generated. But you don't really care about the mechanism. We can assume that copy_from_user is working properly, and that it is reporting an actual error in memory allocation, addressing, length, and/or alignment. Consider testing a simpler case, perhaps transferring just a single integer. – Peter Sep 25 '14 at 13:30

0 Answers0