Skip to content

Commit beb0ad9

Browse files
James Hogangregkh
authored andcommitted
metag/usercopy: Set flags before ADDZ
commit fd40eee1290ad7add7aa665e3ce6b0f9fe9734b4 upstream. The fixup code for the copy_to_user rapf loops reads TXStatus.LSM_STEP to decide how far to rewind the source pointer. There is a special case for the last execution of an MGETL/MGETD, since it leaves LSM_STEP=0 even though the number of MGETLs/MGETDs attempted was 4. This uses ADDZ which is conditional upon the Z condition flag, but the AND instruction which masked the TXStatus.LSM_STEP field didn't set the condition flags based on the result. Fix that now by using ANDS which does set the flags, and also marking the condition codes as clobbered by the inline assembly. Fixes: 373cd78 ("metag: Memory handling") Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: linux-metag@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 29b5eb5 commit beb0ad9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/metag/lib/usercopy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
" .previous\n" \
316316
: "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \
317317
: "0" (to), "1" (from), "2" (ret), "3" (n) \
318-
: "D1Ar1", "D0Ar2", "memory")
318+
: "D1Ar1", "D0Ar2", "cc", "memory")
319319

320320
/* rewind 'to' and 'from' pointers when a fault occurs
321321
*
@@ -341,7 +341,7 @@
341341
#define __asm_copy_to_user_64bit_rapf_loop(to, from, ret, n, id)\
342342
__asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \
343343
"LSR D0Ar2, D0Ar2, #8\n" \
344-
"AND D0Ar2, D0Ar2, #0x7\n" \
344+
"ANDS D0Ar2, D0Ar2, #0x7\n" \
345345
"ADDZ D0Ar2, D0Ar2, #4\n" \
346346
"SUB D0Ar2, D0Ar2, #1\n" \
347347
"MOV D1Ar1, #4\n" \
@@ -486,7 +486,7 @@
486486
" .previous\n" \
487487
: "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \
488488
: "0" (to), "1" (from), "2" (ret), "3" (n) \
489-
: "D1Ar1", "D0Ar2", "memory")
489+
: "D1Ar1", "D0Ar2", "cc", "memory")
490490

491491
/* rewind 'to' and 'from' pointers when a fault occurs
492492
*
@@ -512,7 +512,7 @@
512512
#define __asm_copy_to_user_32bit_rapf_loop(to, from, ret, n, id)\
513513
__asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \
514514
"LSR D0Ar2, D0Ar2, #8\n" \
515-
"AND D0Ar2, D0Ar2, #0x7\n" \
515+
"ANDS D0Ar2, D0Ar2, #0x7\n" \
516516
"ADDZ D0Ar2, D0Ar2, #4\n" \
517517
"SUB D0Ar2, D0Ar2, #1\n" \
518518
"MOV D1Ar1, #4\n" \

0 commit comments

Comments
 (0)