Skip to contentSkip to conversation

memcpy.S patch in 64-bit

PATCH Carsten Langgaard 3 participants 5 messages Aug 8, 2002 – Aug 9, 2002 MIPS

lore
Share & tools
lore
#0 lore raw

The __copy_user function (in arch/mips64/lib/memcpy.S) calls __bzero. We can't do that because __bzero might modify len, which we want to return in case of an error.
The following patch take care of the problem.

/Carsten

--

_    _ ____  ___   Carsten Langgaard   Mailto:[email protected]
|\  /|||___)(___   MIPS Denmark        Direct: +45 4486 5527
| \/ |||    ____)  Lautrupvang 4B      Switch: +45 4486 5555
  TECHNOLOGIES     2750 Ballerup       Fax...: +45 4486 5556
                   Denmark             http://www.mips.com

Index: arch/mips64/lib/memcpy.S
===================================================================
RCS file: /cvs/linux/arch/mips64/lib/memcpy.S,v
retrieving revision 1.9.2.1

mips64/lib/memcpy.S +12 -2
diff -u -r1.9.2.1 memcpy.S
@@ -762,8 +762,18 @@
 	dsubu	a2, AT, ta0			# a2 bytes to go
 	daddu	a0, ta0				# compute start address in a1
 	dsubu	a0, a1
-	j	__bzero
-	 move	a1, zero
+	/*
+	 * Clear len bytes starting at dst.  Can't call __bzero because it
+	 * might modify len.  An inefficient loop for these rare times...
+	 */
+	beqz	a2, 2f
+	 dsubu	a1, a2, 1
+1:	sb	zero, 0(a0)
+	daddu	a0, a0, 1
+	bnez	a1, 1b
+	 dsubu	a1, a1, 1
+2:	jr	ra
+	 nop
 
 s_fixup:
 	jr	ra
#1 lore raw
Quoted 4 lines · Carsten Langgaard

The __copy_user function (in arch/mips64/lib/memcpy.S) calls __bzero. We can't do that because __bzero might modify len, which we want to return in case of an error.
The following patch take care of the problem.

Hmm, how about simply cloning arch/mips/lib/memcpy.S? It seems:

1. Designed to work on mips64 as well.

2. More up to date.

And it would ease maintenance.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#2 lore raw
Quoted 5 lines · Maciej W. Rozycki
Quoted 4 lines

The __copy_user function (in arch/mips64/lib/memcpy.S) calls __bzero. We can't do that because __bzero might modify len, which we want to return in case of an error.
The following patch take care of the problem.

Quoted 7 lines

Hmm, how about simply cloning arch/mips/lib/memcpy.S? It seems:

1. Designed to work on mips64 as well.

2. More up to date.

And it would ease maintenance.

Right but Carsten's patch is already ready, so I'm going to use it for now.

Ralf

#3 lore raw
In reply to Maciej W. Rozycki
Quoted 7 lines · Maciej W. Rozycki
Quoted 4 lines · Carsten Langgaard

The __copy_user function (in arch/mips64/lib/memcpy.S) calls __bzero. We can't do that because __bzero might modify len, which we want to return in case of an error.
The following patch take care of the problem.

Quoted 8 lines

Hmm, how about simply cloning arch/mips/lib/memcpy.S? It seems:

1. Designed to work on mips64 as well.

2. More up to date.

And it would ease maintenance.

If it works then it's the right thing to do, so please go a head :-)

Quoted 5 lines

--

(quoted diff) +3 -0
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#4 lore raw
Quoted 1 line · Carsten Langgaard

If it works then it's the right thing to do, so please go a head :-)

I'll do that later, but don't hesitate to do it yourself if you have some
time to spare. The most effort will likely be in testing.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +