RE: [Linux-ia64] Re: memcpy failure

Chen, Kenneth W
2002-11-14T20:32:20Z

[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]

Here is the patch that I promised.

Bjorn, would you please apply it to the 2.4 tree? and
David, would you please apply it to the 2.5 tree?

Thanks.

- Ken

-----Original Message-----
From: Chen, Kenneth W
Sent: Thursday, November 14, 2002 7:53 AM
To: Matthew Wilcox; Christian Cotte-Barrot
Cc: linux-ia64@linuxia64.org
Subject: RE: [Linux-ia64] Re: memcpy failure

> >On Thu, Nov 14, 2002 at 10:01:44AM +0100, Christian Cotte-Barrot wrote:
> > But memcpy from memcpy.S is returning a pointer to dest area.
> > That would lead to quasi non-portable code when the return from memcopy
> > is correctly checked depending on which memcopy function is addressed.
> > But BTW, is it meaningful to take into account a return code
> > that is always the same and which value is known in advance ?
> > Does memcpy suppose to failed in some cases ?

> no, memcpy cannot fail (you get a SIGSEGV in userspace or an MCA in
> kernel space). checking the return value is meaningless.

That's what I feel as well that it is kind of silly to return something that the caller already has. BUt then, I'm not here to judge the specification ;-)

Anyhow, the fix is fairly easy and won't affect the code size as well as the copy throughput, I should have a patch ready shortly to make everyone happy!

- Ken

_______________________________________________
Linux-IA64 mailing list
Linux-IA64@linuxia64.org
http://lists.linuxia64.org/lists/listinfo/linux-ia64

[-- Attachment #2: memcpy_mck.fix.patch --]
[-- Type: application/octet-stream, Size: 1177 bytes --]

--- linux/arch/ia64/lib/memcpy_mck.S.orig Fri Nov 8 18:05:05 2002
+++ linux/arch/ia64/lib/memcpy_mck.S Thu Nov 14 11:33:53 2002
@@ -6,7 +6,10 @@
* in1: source address
* in2: number of bytes to copy
* Output:
- * 0 if success, or number of byte NOT copied if error occurred.
+ * for bcopy: return nothing
+ * for memcpy: retrun dest
+ * for copy_user: return 0 if success,
+ * or number of byte NOT copied if error occurred.
*
* Copyright (C) 2002 Intel Corp.
* Copyright (C) 2002 Ken Chen <kenneth.w.chen@intel.com>
@@ -86,6 +89,7 @@
and r28=0x7,in0
and r29=0x7,in1
mov f6=f0
+ mov retval=in0
br.cond.sptk .common_code
;;
END(memcpy)
@@ -97,7 +101,7 @@
mov f6=f1
mov saved_in0=in0 // save dest pointer
mov saved_in1=in1 // save src pointer
- mov saved_in2=in2 // save len
+ mov retval=r0 // initialize return value
;;
.common_code:
cmp.gt p15,p0=8,in2 // check for small size
@@ -105,7 +109,7 @@
cmp.ne p14,p0=0,r29 // check src alignment
add src0=0,in1
sub r30=8,r28 // for .align_dest
- mov retval=r0 // initialize return value
+ mov saved_in2=in2 // save len
;;
add dst0=0,in0
add dst1=1,in0 // dest odd index