From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpauth05.mail.atl.earthlink.net (smtpauth05.mail.atl.earthlink.net [209.86.89.65]) by ozlabs.org (Postfix) with ESMTP id AA9E667EB7 for ; Fri, 12 Aug 2005 00:39:06 +1000 (EST) From: "T Michael Turney" To: , Date: Thu, 11 Aug 2005 07:29:21 -0700 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0017_01C59E46.64070C50" In-Reply-To: <0IL100L2IEO6NG@ms13.samsung.com> Subject: RE: copy_from_user problem List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , This is a multi-part message in MIME format. ------=_NextPart_000_0017_01C59E46.64070C50 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit Samsung Enterprise Portal mySingleMurahari, I always start simple and work up to the harder things. Try to access a single long word in the ioctl, e.g., int chr1_ioctl(struct inode *ino, struct file *filp, unsigned int cmd, unsigned long arg) { int ret = 0; unsigned int userdata; switch(cmd) { case IOCTL_WIN_DEBUG_READ_CODE: { ret = get_user(userdata, (unsigned int *)arg); ...... } } } The two O'Reilly books, Linux Device Drivers and Understanding the Linux Kernel are also good references for how to use the get_user and copy_from_user macros. Hope this helps. Cheers, T.mike -----Original Message----- From: linuxppc-dev-bounces@ozlabs.org [mailto:linuxppc-dev-bounces@ozlabs.org]On Behalf Of V MURAHARI Sent: Wednesday, August 10, 2005 7:53 PM To: linuxppc-dev@ozlabs.org Subject: copy_from_user problem Hello, I am working on a character driver for reading and writing the registers to FPGA in our system. I am using driver ioctl to read/write to these registers of FPGA. As the function call to the ioctl is being made, the printk trace shows that the call goes to switch->copy_from_user. As soon as the call is made to copy_from_user, the kernel crashes Can someone help me with this problem? **************************************************************************** *********************** Unhandled kernel unaligned access in unaligned.c::emulate_load_store_insn, line 483 : $0 : 00000000 10001f00 8fbf0034 02a01021 801157a0 8fe8e000 10001f00 ffff00ff $8 : 8fe8ffe0 00001f00 00000000 00000003 74652053 8fe9fed8 0000000a 50434942 $16: 10001f01 00000001 801157a0 0000000f 8fe8fee8 00000104 00000000 0000000f $24: 00000000 2ac0fdb0 8fe8e000 8fe8fe38 00000001 8012010c Hi : 00000000 Lo : 00000000 epc : 8011f774 Tainted: GF Status: 10001f02 Cause : 00800014 Process rsgbm (pid: 317, stackpage=8fe8e000) Stack: 802d920a 0000000a 10001f01 0000003c 10001f01 0000003c 8012010c 80120104 caa8f356 8fe82008 8fe82000 0000000f 00000000 7fff7d00 7fff7d00 0000c001 00000003 10012808 ffffffff caa8e548 00004000 8fe9e272 00000150 7fff7d00 ffffffea 00000000 00000240 8fe82000 00000000 00000001 00000001 7ebff310 00000000 0000000f 8fef24e0 00000004 7ebff3e8 00000000 0000002e 80159c6c ... Call Trace: [<8012010c>] [<80120104>] [] [] [<80159c6c>] [<8010a5c4>] [<80271dc4>] Code: 8c820004 24110001 ac430000 ac800000 ac800004 ac800000 ac800004 8f820004 Unit Fault Handler !!! (INDEX=10) **************************************************************************** ********************** int chr1_ioctl(struct inode *ino, struct file *filp, unsigned int cmd, unsigned long arg) { int ret = 0; n2_debug_rw_reg *dw; switch(cmd) { case IOCTL_WIN_DEBUG_READ_CODE: { n2_debug_rw_reg test; printk("%s %d\n", current->comm, current->pid); printk("%lx\n", arg); copy_from_user(&test, (n2_debug_rw_reg*)arg, sizeof(n2_debug_rw_reg)); printk("%lx %lx\n", ((n2_debug_rw_reg*)arg)->data, ((n2_debug_rw_reg*)arg)-> addr); } } } Thanks & Regards, --Murahari ------=_NextPart_000_0017_01C59E46.64070C50 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Samsung Enterprise Portal mySingle
Murahari,
I=20 always start simple and work up to the harder things.  Try to = access a=20 single
long=20 word in the ioctl, e.g.,
 

int

chr1_ioctl(struct inode *ino, struct file = *filp, unsigned=20 int cmd, unsigned long = arg)

{

   int ret =3D 0;

  = unsigned int=20 userdata;

 

   switch(cmd)

   {

      case=20 IOCTL_WIN_DEBUG_READ_CODE:

      {

        ret =3D=20 get_user(userdata, (unsigned int *)arg);

        ...... 

         }

}

}

 

The = two O'Reilly=20 books, Linux Device Drivers and Understanding the Linux Kernel are also=20 good

references for how=20 to use the get_user and copy_from_user macros.

Hope = this=20 helps.

Cheers,

T.mike

-----Original Message-----
From:=20 linuxppc-dev-bounces@ozlabs.org = [mailto:linuxppc-dev-bounces@ozlabs.org]On=20 Behalf Of V MURAHARI
Sent: Wednesday, August 10, 2005 = 7:53=20 PM
To: linuxppc-dev@ozlabs.org
Subject: = copy_from_user=20 problem

Hello,=20

I am working on a character driver for reading and writing the = registers to=20 FPGA in our system.

I am using driver ioctl to read/write to these registers of FPGA. = As the=20 function call to the ioctl is being made, the printk trace shows that = the call=20 goes to switch->copy_from_user. As soon as the call is made to=20 copy_from_user, the kernel crashes

Can someone help me with this problem?

 

=

**********************************************************************= *****************************

 Unhandled kernel unaligned access in=20 unaligned.c::emulate_load_store_insn, line 483

:

$0 : 00000000 10001f00 8fbf0034 02a01021 801157a0 8fe8e000 10001f00 = ffff00ff

$8 : 8fe8ffe0 00001f00 00000000 00000003 74652053 8fe9fed8 0000000a = 50434942

$16: 10001f01 00000001 801157a0 0000000f 8fe8fee8 00000104 00000000 = 0000000f

$24: 00000000 2ac0fdb0=20 =             &= nbsp;     8fe8e000=20 8fe8fe38 00000001 8012010c

Hi : 00000000

Lo : 00000000

epc  : 8011f774    Tainted: GF

Status: 10001f02

Cause : 00800014

Process rsgbm (pid: 317, stackpage=3D8fe8e000)

Stack:    802d920a 0000000a 10001f01 0000003c = 10001f01=20 0000003c 8012010c

 80120104 caa8f356 8fe82008 8fe82000 0000000f 00000000 = 7fff7d00=20 7fff7d00

 0000c001 00000003 10012808 ffffffff caa8e548 00004000 = 8fe9e272=20 00000150

 7fff7d00 ffffffea 00000000 00000240 8fe82000 00000000 = 00000001=20 00000001

 7ebff310 00000000 0000000f 8fef24e0 00000004 7ebff3e8 = 00000000=20 0000002e

 80159c6c ...

Call Trace:   [<8012010c>] [<80120104>]=20 [<caa8f356>] [<caa8e548>] [<80159c6c>]

 [<8010a5c4>] [<80271dc4>]

 

Code: 8c820004  24110001  ac430000 <ac620004> = ac800000=20  ac800004  ac800000  ac800004

  8f820004

 

Unit Fault Handler !!! (INDEX=3D10)

=

**********************************************************************= ****************************

int

chr1_ioctl(struct inode *ino, struct file *filp, unsigned int = cmd,

      unsigned long arg)

{

   int ret =3D 0;

   n2_debug_rw_reg *dw;

 

   switch(cmd)

   {

      case = IOCTL_WIN_DEBUG_READ_CODE:

      {

   n2_debug_rw_reg test;

        printk("%s %d\n",=20 current->comm, current->pid);

        printk("%lx\n", = arg);

=

        copy_from_user(&te= st,=20 (n2_debug_rw_reg*)arg, sizeof(n2_debug_rw_reg));

        printk("%lx %lx\n", = ((n2_debug_rw_reg*)arg)->data, ((n2_debug_rw_reg*)arg)->

addr);

         }

}

}

 

Thanks & Regards,

--Murahari

------=_NextPart_000_0017_01C59E46.64070C50--