~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sparc/lib/GENbzero.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /* GENbzero.S: Generic sparc64 memset/clear_user.
  3  *
  4  * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
  5  */
  6 #include <asm/asi.h>
  7 
  8 #define EX_ST(x,y)              \
  9 98:     x,y;                    \
 10         .section __ex_table,"a";\
 11         .align 4;               \
 12         .word 98b, __retl_o1_asi;\
 13         .text;                  \
 14         .align 4;
 15 
 16         .align  32
 17         .text
 18 
 19         .globl          GENmemset
 20         .type           GENmemset, #function
 21 GENmemset:              /* %o0=buf, %o1=pat, %o2=len */
 22         and             %o1, 0xff, %o3
 23         mov             %o2, %o1
 24         sllx            %o3, 8, %g1
 25         or              %g1, %o3, %o2
 26         sllx            %o2, 16, %g1
 27         or              %g1, %o2, %o2
 28         sllx            %o2, 32, %g1
 29         ba,pt           %xcc, 1f
 30          or             %g1, %o2, %o2
 31 
 32         .globl          GENbzero
 33         .type           GENbzero, #function
 34 GENbzero:
 35         clr             %o2
 36 1:      brz,pn          %o1, GENbzero_return
 37          mov            %o0, %o3
 38 
 39         /* %o5: saved %asi, restored at GENbzero_done
 40          * %o4: store %asi to use
 41          */
 42         rd              %asi, %o5
 43         mov             ASI_P, %o4
 44         wr              %o4, 0x0, %asi
 45 
 46 GENbzero_from_clear_user:
 47         cmp             %o1, 15
 48         bl,pn           %icc, GENbzero_tiny
 49          andcc          %o0, 0x7, %g1
 50         be,pt           %xcc, 2f
 51          mov            8, %g2
 52         sub             %g2, %g1, %g1
 53         sub             %o1, %g1, %o1
 54 1:      EX_ST(stba %o2, [%o0 + 0x00] %asi)
 55         subcc           %g1, 1, %g1
 56         bne,pt          %xcc, 1b
 57          add            %o0, 1, %o0
 58 2:      cmp             %o1, 128
 59         bl,pn           %icc, GENbzero_medium
 60          andcc          %o0, (64 - 1), %g1
 61         be,pt           %xcc, GENbzero_pre_loop
 62          mov            64, %g2
 63         sub             %g2, %g1, %g1
 64         sub             %o1, %g1, %o1
 65 1:      EX_ST(stxa %o2, [%o0 + 0x00] %asi)
 66         subcc           %g1, 8, %g1
 67         bne,pt          %xcc, 1b
 68          add            %o0, 8, %o0
 69 
 70 GENbzero_pre_loop:
 71         andn            %o1, (64 - 1), %g1
 72         sub             %o1, %g1, %o1
 73 GENbzero_loop:
 74         EX_ST(stxa %o2, [%o0 + 0x00] %asi)
 75         EX_ST(stxa %o2, [%o0 + 0x08] %asi)
 76         EX_ST(stxa %o2, [%o0 + 0x10] %asi)
 77         EX_ST(stxa %o2, [%o0 + 0x18] %asi)
 78         EX_ST(stxa %o2, [%o0 + 0x20] %asi)
 79         EX_ST(stxa %o2, [%o0 + 0x28] %asi)
 80         EX_ST(stxa %o2, [%o0 + 0x30] %asi)
 81         EX_ST(stxa %o2, [%o0 + 0x38] %asi)
 82         subcc           %g1, 64, %g1
 83         bne,pt          %xcc, GENbzero_loop
 84          add            %o0, 64, %o0
 85 
 86         membar          #Sync
 87         wr              %o4, 0x0, %asi
 88         brz,pn          %o1, GENbzero_done
 89 GENbzero_medium:
 90          andncc         %o1, 0x7, %g1
 91         be,pn           %xcc, 2f
 92          sub            %o1, %g1, %o1
 93 1:      EX_ST(stxa %o2, [%o0 + 0x00] %asi)
 94         subcc           %g1, 8, %g1
 95         bne,pt          %xcc, 1b
 96          add            %o0, 8, %o0
 97 2:      brz,pt          %o1, GENbzero_done
 98          nop
 99 
100 GENbzero_tiny:
101 1:      EX_ST(stba %o2, [%o0 + 0x00] %asi)
102         subcc           %o1, 1, %o1
103         bne,pt          %icc, 1b
104          add            %o0, 1, %o0
105 
106         /* fallthrough */
107 
108 GENbzero_done:
109         wr              %o5, 0x0, %asi
110 
111 GENbzero_return:
112         retl
113          mov            %o3, %o0
114         .size           GENbzero, .-GENbzero
115         .size           GENmemset, .-GENmemset
116 
117         .globl          GENclear_user
118         .type           GENclear_user, #function
119 GENclear_user:          /* %o0=buf, %o1=len */
120         rd              %asi, %o5
121         brz,pn          %o1, GENbzero_done
122          clr            %o3
123         cmp             %o5, ASI_AIUS
124         bne,pn          %icc, GENbzero
125          clr            %o2
126         ba,pt           %xcc, GENbzero_from_clear_user
127          mov            ASI_AIUS, %o4
128         .size           GENclear_user, .-GENclear_user
129 
130 #define BRANCH_ALWAYS   0x10680000
131 #define NOP             0x01000000
132 #define GEN_DO_PATCH(OLD, NEW)  \
133         sethi   %hi(NEW), %g1; \
134         or      %g1, %lo(NEW), %g1; \
135         sethi   %hi(OLD), %g2; \
136         or      %g2, %lo(OLD), %g2; \
137         sub     %g1, %g2, %g1; \
138         sethi   %hi(BRANCH_ALWAYS), %g3; \
139         sll     %g1, 11, %g1; \
140         srl     %g1, 11 + 2, %g1; \
141         or      %g3, %lo(BRANCH_ALWAYS), %g3; \
142         or      %g3, %g1, %g3; \
143         stw     %g3, [%g2]; \
144         sethi   %hi(NOP), %g3; \
145         or      %g3, %lo(NOP), %g3; \
146         stw     %g3, [%g2 + 0x4]; \
147         flush   %g2;
148 
149         .globl  generic_patch_bzero
150         .type   generic_patch_bzero,#function
151 generic_patch_bzero:
152         GEN_DO_PATCH(memset, GENmemset)
153         GEN_DO_PATCH(__bzero, GENbzero)
154         GEN_DO_PATCH(__clear_user, GENclear_user)
155         retl
156          nop
157         .size   generic_patch_bzero,.-generic_patch_bzero

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php