Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* copy_in_user.S: Copy from userspace to userspace. |
| 2 | * |
| 3 | * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) |
| 4 | */ |
| 5 | |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 6 | #include <linux/linkage.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <asm/asi.h> |
| 8 | |
| 9 | #define XCC xcc |
| 10 | |
| 11 | #define EX(x,y) \ |
| 12 | 98: x,y; \ |
David S. Miller | 4d000d5 | 2006-03-04 23:23:56 -0800 | [diff] [blame] | 13 | .section __ex_table,"a";\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | .align 4; \ |
David S. Miller | 40bdac7 | 2009-02-08 22:00:55 -0800 | [diff] [blame] | 15 | .word 98b, __retl_one; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | .text; \ |
| 17 | .align 4; |
| 18 | |
| 19 | .register %g2,#scratch |
| 20 | .register %g3,#scratch |
| 21 | |
| 22 | .text |
| 23 | .align 32 |
| 24 | |
| 25 | /* Don't try to get too fancy here, just nice and |
| 26 | * simple. This is predominantly used for well aligned |
| 27 | * small copies in the compat layer. It is also used |
| 28 | * to copy register windows around during thread cloning. |
| 29 | */ |
| 30 | |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 31 | ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | cmp %o2, 0 |
| 33 | be,pn %XCC, 85f |
| 34 | or %o0, %o1, %o3 |
| 35 | cmp %o2, 16 |
| 36 | bleu,a,pn %XCC, 80f |
| 37 | or %o3, %o2, %o3 |
| 38 | |
| 39 | /* 16 < len <= 64 */ |
| 40 | andcc %o3, 0x7, %g0 |
| 41 | bne,pn %XCC, 90f |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 42 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | andn %o2, 0x7, %o4 |
| 45 | and %o2, 0x7, %o2 |
| 46 | 1: subcc %o4, 0x8, %o4 |
| 47 | EX(ldxa [%o1] %asi, %o5) |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 48 | EX(stxa %o5, [%o0] %asi) |
| 49 | add %o1, 0x8, %o1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | bgu,pt %XCC, 1b |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 51 | add %o0, 0x8, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | andcc %o2, 0x4, %g0 |
| 53 | be,pt %XCC, 1f |
| 54 | nop |
| 55 | sub %o2, 0x4, %o2 |
| 56 | EX(lduwa [%o1] %asi, %o5) |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 57 | EX(stwa %o5, [%o0] %asi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | add %o1, 0x4, %o1 |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 59 | add %o0, 0x4, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | 1: cmp %o2, 0 |
| 61 | be,pt %XCC, 85f |
| 62 | nop |
| 63 | ba,pt %xcc, 90f |
| 64 | nop |
| 65 | |
| 66 | 80: /* 0 < len <= 16 */ |
| 67 | andcc %o3, 0x3, %g0 |
| 68 | bne,pn %XCC, 90f |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 69 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | 82: |
| 72 | subcc %o2, 4, %o2 |
| 73 | EX(lduwa [%o1] %asi, %g1) |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 74 | EX(stwa %g1, [%o0] %asi) |
| 75 | add %o1, 4, %o1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | bgu,pt %XCC, 82b |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 77 | add %o0, 4, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | 85: retl |
| 80 | clr %o0 |
| 81 | |
| 82 | .align 32 |
| 83 | 90: |
| 84 | subcc %o2, 1, %o2 |
| 85 | EX(lduba [%o1] %asi, %g1) |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 86 | EX(stba %g1, [%o0] %asi) |
| 87 | add %o1, 1, %o1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | bgu,pt %XCC, 90b |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 89 | add %o0, 1, %o0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | retl |
| 91 | clr %o0 |
David S. Miller | aeb3987 | 2009-02-08 22:32:31 -0800 | [diff] [blame] | 92 | ENDPROC(___copy_in_user) |