Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* copy_in_user.S: Copy from userspace to userspace.
0003  *
0004  * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
0005  */
0006 
0007 #include <linux/linkage.h>
0008 #include <asm/asi.h>
0009 #include <asm/export.h>
0010 
0011 #define XCC xcc
0012 
0013 #define EX(x,y,z)       \
0014 98: x,y;            \
0015     .section __ex_table,"a";\
0016     .align 4;       \
0017     .word 98b, z;       \
0018     .text;          \
0019     .align 4;
0020 
0021 #define EX_O4(x,y) EX(x,y,__retl_o4_plus_8)
0022 #define EX_O2_4(x,y) EX(x,y,__retl_o2_plus_4)
0023 #define EX_O2_1(x,y) EX(x,y,__retl_o2_plus_1)
0024 
0025     .register   %g2,#scratch
0026     .register   %g3,#scratch
0027 
0028     .text
0029 __retl_o4_plus_8:
0030     add %o4, %o2, %o4
0031     retl
0032      add    %o4, 8, %o0
0033 __retl_o2_plus_4:
0034     retl
0035      add    %o2, 4, %o0
0036 __retl_o2_plus_1:
0037     retl
0038      add    %o2, 1, %o0
0039 
0040     .align  32
0041 
0042     /* Don't try to get too fancy here, just nice and
0043      * simple.  This is predominantly used for well aligned
0044      * small copies in the compat layer.  It is also used
0045      * to copy register windows around during thread cloning.
0046      */
0047 
0048 ENTRY(raw_copy_in_user) /* %o0=dst, %o1=src, %o2=len */
0049     cmp     %o2, 0
0050     be,pn       %XCC, 85f
0051      or     %o0, %o1, %o3
0052     cmp     %o2, 16
0053     bleu,a,pn   %XCC, 80f
0054      or     %o3, %o2, %o3
0055 
0056     /* 16 < len <= 64 */
0057     andcc       %o3, 0x7, %g0
0058     bne,pn      %XCC, 90f
0059      nop
0060 
0061     andn        %o2, 0x7, %o4
0062     and     %o2, 0x7, %o2
0063 1:  subcc       %o4, 0x8, %o4
0064     EX_O4(ldxa [%o1] %asi, %o5)
0065     EX_O4(stxa %o5, [%o0] %asi)
0066     add     %o1, 0x8, %o1
0067     bgu,pt      %XCC, 1b
0068      add        %o0, 0x8, %o0
0069     andcc       %o2, 0x4, %g0
0070     be,pt       %XCC, 1f
0071      nop
0072     sub     %o2, 0x4, %o2
0073     EX_O2_4(lduwa [%o1] %asi, %o5)
0074     EX_O2_4(stwa %o5, [%o0] %asi)
0075     add     %o1, 0x4, %o1
0076     add     %o0, 0x4, %o0
0077 1:  cmp     %o2, 0
0078     be,pt       %XCC, 85f
0079      nop
0080     ba,pt       %xcc, 90f
0081      nop
0082 
0083 80: /* 0 < len <= 16 */
0084     andcc       %o3, 0x3, %g0
0085     bne,pn      %XCC, 90f
0086      nop
0087 
0088 82:
0089     subcc       %o2, 4, %o2
0090     EX_O2_4(lduwa [%o1] %asi, %g1)
0091     EX_O2_4(stwa %g1, [%o0] %asi)
0092     add     %o1, 4, %o1
0093     bgu,pt      %XCC, 82b
0094      add        %o0, 4, %o0
0095 
0096 85: retl
0097      clr        %o0
0098 
0099     .align  32
0100 90:
0101     subcc       %o2, 1, %o2
0102     EX_O2_1(lduba [%o1] %asi, %g1)
0103     EX_O2_1(stba %g1, [%o0] %asi)
0104     add     %o1, 1, %o1
0105     bgu,pt      %XCC, 90b
0106      add        %o0, 1, %o0
0107     retl
0108      clr        %o0
0109 ENDPROC(raw_copy_in_user)
0110 EXPORT_SYMBOL(raw_copy_in_user)