<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<STYLE>P {
        MARGIN-TOP: 5px; FONT-SIZE: 9pt; MARGIN-BOTTOM: 5px; FONT-FAMILY: Arial, arial
}
TD {
        MARGIN-TOP: 5px; FONT-SIZE: 9pt; MARGIN-BOTTOM: 5px; FONT-FAMILY: Arial, arial
}
LI {
        MARGIN-TOP: 5px; FONT-SIZE: 9pt; MARGIN-BOTTOM: 5px; FONT-FAMILY: Arial, arial
}
</STYLE>
<META content="MSHTML 6.00.2800.1458" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=372591414-11082005>Murahari,</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=372591414-11082005>I
always start simple and work up to the harder things. Try to access a
single</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=372591414-11082005>long
word in the ioctl, e.g.,</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=372591414-11082005></SPAN></FONT> </DIV>
<DIV><FONT size=2><SPAN class=372591414-11082005>
<P><FONT color=#0000ff>int</FONT></P>
<P><FONT color=#0000ff>chr1_ioctl(struct inode *ino, struct file *filp, unsigned
int cmd,<SPAN class=372591414-11082005> </SPAN>unsigned long arg)</FONT></P>
<P><FONT color=#0000ff>{</FONT></P>
<P><FONT color=#0000ff> int ret = 0;</FONT></P>
<P><SPAN class=372591414-11082005><FONT color=#0000ff> unsigned int
userdata;</FONT></SPAN></P>
<P><FONT color=#0000ff size=2></FONT> </P>
<P><FONT color=#0000ff> switch(cmd)</FONT></P>
<P><FONT color=#0000ff> {</FONT></P>
<P><FONT color=#0000ff> case
IOCTL_WIN_DEBUG_READ_CODE:</FONT></P>
<P><FONT color=#0000ff> {</FONT></P>
<P><SPAN class=372591414-11082005><FONT
color=#0000ff> <FONT size=2>ret =
get_user(userdata, (unsigned int *)arg);</FONT></FONT></SPAN></P>
<P><FONT color=#0000ff><SPAN class=372591414-11082005><FONT
size=2> ......</FONT></SPAN> </FONT></P>
<P><FONT
color=#0000ff> }</FONT></P>
<P><FONT color=#0000ff>}</FONT></P>
<P><FONT color=#0000ff>}</FONT></P>
<P><FONT color=#0000ff size=2><SPAN
class=372591414-11082005></SPAN></FONT> </P>
<P><FONT color=#0000ff size=2><SPAN class=372591414-11082005>The two O'Reilly
books, Linux Device Drivers and Understanding the Linux Kernel are also
good</SPAN></FONT></P>
<P><FONT color=#0000ff size=2><SPAN class=372591414-11082005>references for how
to use the get_user and copy_from_user macros.</SPAN></FONT></P>
<P><FONT color=#0000ff size=2><SPAN class=372591414-11082005>Hope this
helps.</SPAN></FONT></P>
<P><FONT color=#0000ff size=2><SPAN
class=372591414-11082005>Cheers,</SPAN></FONT></P>
<P><FONT color=#0000ff size=2><SPAN
class=372591414-11082005>T.mike</SPAN></FONT></P></SPAN></FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
linuxppc-dev-bounces@ozlabs.org [mailto:linuxppc-dev-bounces@ozlabs.org]<B>On
Behalf Of </B>V MURAHARI<BR><B>Sent:</B> Wednesday, August 10, 2005 7:53
PM<BR><B>To:</B> linuxppc-dev@ozlabs.org<BR><B>Subject:</B> copy_from_user
problem<BR><BR></FONT></DIV>
<P>
<P>Hello,
<P>I am working on a character driver for reading and writing the registers to
FPGA in our system.</P>
<P>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</P>
<P>Can someone help me with this problem?</P>
<P> </P>
<P>***************************************************************************************************</P>
<P> Unhandled kernel unaligned access in
unaligned.c::emulate_load_store_insn, line 483</P>
<P>:</P>
<P>$0 : 00000000 10001f00 8fbf0034 02a01021 801157a0 8fe8e000 10001f00
ffff00ff</P>
<P>$8 : 8fe8ffe0 00001f00 00000000 00000003 74652053 8fe9fed8 0000000a
50434942</P>
<P>$16: 10001f01 00000001 801157a0 0000000f 8fe8fee8 00000104 00000000
0000000f</P>
<P>$24: 00000000 2ac0fdb0
8fe8e000
8fe8fe38 00000001 8012010c</P>
<P>Hi : 00000000</P>
<P>Lo : 00000000</P>
<P>epc : 8011f774 Tainted: GF</P>
<P>Status: 10001f02</P>
<P>Cause : 00800014</P>
<P>Process rsgbm (pid: 317, stackpage=8fe8e000)</P>
<P>Stack: 802d920a 0000000a 10001f01 0000003c 10001f01
0000003c 8012010c</P>
<P> 80120104 caa8f356 8fe82008 8fe82000 0000000f 00000000 7fff7d00
7fff7d00</P>
<P> 0000c001 00000003 10012808 ffffffff caa8e548 00004000 8fe9e272
00000150</P>
<P> 7fff7d00 ffffffea 00000000 00000240 8fe82000 00000000 00000001
00000001</P>
<P> 7ebff310 00000000 0000000f 8fef24e0 00000004 7ebff3e8 00000000
0000002e</P>
<P> 80159c6c ...</P>
<P>Call Trace: [<8012010c>] [<80120104>]
[<caa8f356>] [<caa8e548>] [<80159c6c>]</P>
<P> [<8010a5c4>] [<80271dc4>]</P>
<P> </P>
<P>Code: 8c820004 24110001 ac430000 <ac620004> ac800000
ac800004 ac800000 ac800004</P>
<P> 8f820004</P>
<P> </P>
<P>Unit Fault Handler !!! (INDEX=10)</P>
<P>**************************************************************************************************</P>
<P>int</P>
<P>chr1_ioctl(struct inode *ino, struct file *filp, unsigned int cmd,</P>
<P> unsigned long arg)</P>
<P>{</P>
<P> int ret = 0;</P>
<P> n2_debug_rw_reg *dw;</P>
<P> </P>
<P> switch(cmd)</P>
<P> {</P>
<P> case IOCTL_WIN_DEBUG_READ_CODE:</P>
<P> {</P>
<P> n2_debug_rw_reg test;</P>
<P> printk("%s %d\n",
current->comm, current->pid);</P>
<P> printk("%lx\n", arg);</P>
<P> copy_from_user(&test,
(n2_debug_rw_reg*)arg, sizeof(n2_debug_rw_reg));</P>
<P> printk("%lx %lx\n",
((n2_debug_rw_reg*)arg)->data, ((n2_debug_rw_reg*)arg)-></P>
<P>addr);</P>
<P> }</P>
<P>}</P>
<P>}</P>
<P> </P>
<P>Thanks & Regards,</P>
<P>--Murahari</P></BLOCKQUOTE></BODY></HTML>