1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* GENbzero.S: Generic sparc64 memset/clear_user.
4 * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
10 .section __ex_table,"a";\
12 .word 98b, __retl_o1_asi;\
20 .type GENmemset, #function
21 GENmemset: /* %o0=buf, %o1=pat, %o2=len */
33 .type GENbzero, #function
36 1: brz,pn %o1, GENbzero_return
39 /* %o5: saved %asi, restored at GENbzero_done
40 * %o4: store %asi to use
46 GENbzero_from_clear_user:
48 bl,pn %icc, GENbzero_tiny
54 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
59 bl,pn %icc, GENbzero_medium
60 andcc %o0, (64 - 1), %g1
61 be,pt %xcc, GENbzero_pre_loop
65 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
71 andn %o1, (64 - 1), %g1
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)
83 bne,pt %xcc, GENbzero_loop
88 brz,pn %o1, GENbzero_done
93 1: EX_ST(stxa %o2, [%o0 + 0x00] %asi)
97 2: brz,pt %o1, GENbzero_done
101 1: EX_ST(stba %o2, [%o0 + 0x00] %asi)
114 .size GENbzero, .-GENbzero
115 .size GENmemset, .-GENmemset
118 .type GENclear_user, #function
119 GENclear_user: /* %o0=buf, %o1=len */
121 brz,pn %o1, GENbzero_done
124 bne,pn %icc, GENbzero
126 ba,pt %xcc, GENbzero_from_clear_user
128 .size GENclear_user, .-GENclear_user
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; \
138 sethi %hi(BRANCH_ALWAYS), %g3; \
140 srl %g1, 11 + 2, %g1; \
141 or %g3, %lo(BRANCH_ALWAYS), %g3; \
144 sethi %hi(NOP), %g3; \
145 or %g3, %lo(NOP), %g3; \
146 stw %g3, [%g2 + 0x4]; \
149 .globl generic_patch_bzero
150 .type generic_patch_bzero,#function
152 GEN_DO_PATCH(memset, GENmemset)
153 GEN_DO_PATCH(__bzero, GENbzero)
154 GEN_DO_PATCH(__clear_user, GENclear_user)
157 .size generic_patch_bzero,.-generic_patch_bzero