diff options
author | Ivan Kokshaysky <ink@jurassic.park.msu.ru> | 2007-12-17 19:19:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-17 22:28:15 -0500 |
commit | fe4304baf26e9580ada52e4579b1b7273434d8dd (patch) | |
tree | cbfcada932066901806ff45c46510ede52f0e328 /arch/alpha/lib | |
parent | 4dbed85a35ed37d9608f4f32e5d69efa775d6223 (diff) |
alpha: strncpy/strncat fixes
First of all, thanks to Bob Tracy <rct@frus.com> and
Michael Cree <mcree@orcon.net.nz> for testing.
Especially to Bob, as he has done titanic multi-day git-bisect
work that finally helped to reproduce and nail down the bug
(http://bugzilla.kernel.org/show_bug.cgi?id=9457).
[ev6-]stxncpy.S: it's t12, not t2 register that is supposed to contain
the last byte offset upon return. As a result of wrong register use
(which was my fault back in 2003, IIRC), under some circumstances extra
terminating zero bytes were added to destination string. This particularly
led to incorrect DEVPATH strings generated in uevent and therefore to udev
problems.
strncpy.S: unrelated bug I found while testing the above fix - destination
is not properly zero-padded then a byte count exceeds source length.
Actually this is addition to strncpy fix from last year.
Signed-off-by: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Bob Tracy <rct@frus.com>
Cc: Michael Cree <mcree@orcon.net.nz>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/alpha/lib')
-rw-r--r-- | arch/alpha/lib/ev6-stxncpy.S | 14 | ||||
-rw-r--r-- | arch/alpha/lib/strncpy.S | 2 | ||||
-rw-r--r-- | arch/alpha/lib/stxncpy.S | 14 |
3 files changed, 15 insertions, 15 deletions
diff --git a/arch/alpha/lib/ev6-stxncpy.S b/arch/alpha/lib/ev6-stxncpy.S index b581a7af2456..1aa6e97e04b5 100644 --- a/arch/alpha/lib/ev6-stxncpy.S +++ b/arch/alpha/lib/ev6-stxncpy.S | |||
@@ -362,10 +362,10 @@ $unaligned: | |||
362 | 362 | ||
363 | extql t2, a1, t2 # U : | 363 | extql t2, a1, t2 # U : |
364 | cmpbge zero, t1, t8 # E : is there a zero? | 364 | cmpbge zero, t1, t8 # E : is there a zero? |
365 | andnot t2, t6, t12 # E : dest mask for a single word copy | 365 | andnot t2, t6, t2 # E : dest mask for a single word copy |
366 | or t8, t10, t5 # E : test for end-of-count too | 366 | or t8, t10, t5 # E : test for end-of-count too |
367 | 367 | ||
368 | cmpbge zero, t12, t3 # E : | 368 | cmpbge zero, t2, t3 # E : |
369 | cmoveq a2, t5, t8 # E : Latency=2, extra map slot | 369 | cmoveq a2, t5, t8 # E : Latency=2, extra map slot |
370 | nop # E : keep with cmoveq | 370 | nop # E : keep with cmoveq |
371 | andnot t8, t3, t8 # E : (stall) | 371 | andnot t8, t3, t8 # E : (stall) |
@@ -379,13 +379,13 @@ $unaligned: | |||
379 | negq t8, t6 # E : build bitmask of bytes <= zero | 379 | negq t8, t6 # E : build bitmask of bytes <= zero |
380 | mskqh t1, t4, t1 # U : | 380 | mskqh t1, t4, t1 # U : |
381 | 381 | ||
382 | and t6, t8, t2 # E : | 382 | and t6, t8, t12 # E : |
383 | subq t2, 1, t6 # E : (stall) | 383 | subq t12, 1, t6 # E : (stall) |
384 | or t6, t2, t8 # E : (stall) | 384 | or t6, t12, t8 # E : (stall) |
385 | zapnot t12, t8, t12 # U : prepare source word; mirror changes (stall) | 385 | zapnot t2, t8, t2 # U : prepare source word; mirror changes (stall) |
386 | 386 | ||
387 | zapnot t1, t8, t1 # U : to source validity mask | 387 | zapnot t1, t8, t1 # U : to source validity mask |
388 | andnot t0, t12, t0 # E : zero place for source to reside | 388 | andnot t0, t2, t0 # E : zero place for source to reside |
389 | or t0, t1, t0 # E : and put it there (stall both t0, t1) | 389 | or t0, t1, t0 # E : and put it there (stall both t0, t1) |
390 | stq_u t0, 0(a0) # L : (stall) | 390 | stq_u t0, 0(a0) # L : (stall) |
391 | 391 | ||
diff --git a/arch/alpha/lib/strncpy.S b/arch/alpha/lib/strncpy.S index bbdef1be5f95..a46f7f3ad8c7 100644 --- a/arch/alpha/lib/strncpy.S +++ b/arch/alpha/lib/strncpy.S | |||
@@ -35,7 +35,7 @@ strncpy: | |||
35 | 35 | ||
36 | or $3, $24, $3 # clear the bits between the last | 36 | or $3, $24, $3 # clear the bits between the last |
37 | or $4, $27, $4 # written byte and the last byte in COUNT | 37 | or $4, $27, $4 # written byte and the last byte in COUNT |
38 | andnot $4, $3, $4 | 38 | andnot $3, $4, $4 |
39 | zap $1, $4, $1 | 39 | zap $1, $4, $1 |
40 | 40 | ||
41 | stq_u $1, 0($16) | 41 | stq_u $1, 0($16) |
diff --git a/arch/alpha/lib/stxncpy.S b/arch/alpha/lib/stxncpy.S index da1a72740d29..3dece25283a3 100644 --- a/arch/alpha/lib/stxncpy.S +++ b/arch/alpha/lib/stxncpy.S | |||
@@ -315,9 +315,9 @@ $unaligned: | |||
315 | 315 | ||
316 | extql t2, a1, t2 # e0 : | 316 | extql t2, a1, t2 # e0 : |
317 | cmpbge zero, t1, t8 # .. e1 : is there a zero? | 317 | cmpbge zero, t1, t8 # .. e1 : is there a zero? |
318 | andnot t2, t6, t12 # e0 : dest mask for a single word copy | 318 | andnot t2, t6, t2 # e0 : dest mask for a single word copy |
319 | or t8, t10, t5 # .. e1 : test for end-of-count too | 319 | or t8, t10, t5 # .. e1 : test for end-of-count too |
320 | cmpbge zero, t12, t3 # e0 : | 320 | cmpbge zero, t2, t3 # e0 : |
321 | cmoveq a2, t5, t8 # .. e1 : | 321 | cmoveq a2, t5, t8 # .. e1 : |
322 | andnot t8, t3, t8 # e0 : | 322 | andnot t8, t3, t8 # e0 : |
323 | beq t8, $u_head # .. e1 (zdb) | 323 | beq t8, $u_head # .. e1 (zdb) |
@@ -330,14 +330,14 @@ $unaligned: | |||
330 | ldq_u t0, 0(a0) # e0 : | 330 | ldq_u t0, 0(a0) # e0 : |
331 | negq t8, t6 # .. e1 : build bitmask of bytes <= zero | 331 | negq t8, t6 # .. e1 : build bitmask of bytes <= zero |
332 | mskqh t1, t4, t1 # e0 : | 332 | mskqh t1, t4, t1 # e0 : |
333 | and t6, t8, t2 # .. e1 : | 333 | and t6, t8, t12 # .. e1 : |
334 | subq t2, 1, t6 # e0 : | 334 | subq t12, 1, t6 # e0 : |
335 | or t6, t2, t8 # e1 : | 335 | or t6, t12, t8 # e1 : |
336 | 336 | ||
337 | zapnot t12, t8, t12 # e0 : prepare source word; mirror changes | 337 | zapnot t2, t8, t2 # e0 : prepare source word; mirror changes |
338 | zapnot t1, t8, t1 # .. e1 : to source validity mask | 338 | zapnot t1, t8, t1 # .. e1 : to source validity mask |
339 | 339 | ||
340 | andnot t0, t12, t0 # e0 : zero place for source to reside | 340 | andnot t0, t2, t0 # e0 : zero place for source to reside |
341 | or t0, t1, t0 # e1 : and put it there | 341 | or t0, t1, t0 # e1 : and put it there |
342 | stq_u t0, 0(a0) # e0 : | 342 | stq_u t0, 0(a0) # e0 : |
343 | ret (t9) # .. e1 : | 343 | ret (t9) # .. e1 : |