53
53
SYM_FUNC_START(copy_user_generic_unrolled)
54
54
ASM_STAC
55
55
cmpl $8 ,%edx
56
- jb 20f /* less then 8 bytes, go to byte copy loop */
56
+ jb .Lcopy_user_short_string_bytes
57
57
ALIGN_DESTINATION
58
58
movl %edx ,%ecx
59
59
andl $63 ,%edx
60
60
shrl $6 ,%ecx
61
- jz .L_copy_short_string
61
+ jz copy_user_short_string
62
62
1: movq (%rsi ),%r8
63
63
2: movq 1*8 (%rsi ),%r9
64
64
3: movq 2*8 (%rsi ),%r10
@@ -79,37 +79,11 @@ SYM_FUNC_START(copy_user_generic_unrolled)
79
79
leaq 64 (%rdi ),%rdi
80
80
decl %ecx
81
81
jnz 1b
82
- .L_copy_short_string:
83
- movl %edx ,%ecx
84
- andl $7 ,%edx
85
- shrl $3 ,%ecx
86
- jz 20f
87
- 18: movq (%rsi ),%r8
88
- 19: movq %r8 ,(%rdi )
89
- leaq 8 (%rsi ),%rsi
90
- leaq 8 (%rdi ),%rdi
91
- decl %ecx
92
- jnz 18b
93
- 20: andl %edx ,%edx
94
- jz 23f
95
- movl %edx ,%ecx
96
- 21: movb (%rsi ),%al
97
- 22: movb %al ,(%rdi )
98
- incq %rsi
99
- incq %rdi
100
- decl %ecx
101
- jnz 21b
102
- 23: xor %eax ,%eax
103
- ASM_CLAC
104
- RET
82
+ jmp copy_user_short_string
105
83
106
84
30: shll $6 ,%ecx
107
85
addl %ecx ,%edx
108
- jmp 60f
109
- 40: leal (%rdx ,%rcx ,8 ),%edx
110
- jmp 60f
111
- 50: movl %ecx ,%edx
112
- 60: jmp .Lcopy_user_handle_tail /* ecx is zerorest also */
86
+ jmp .Lcopy_user_handle_tail
113
87
114
88
_ASM_EXTABLE_CPY(1b, 30b)
115
89
_ASM_EXTABLE_CPY(2b, 30b)
@@ -127,10 +101,6 @@ SYM_FUNC_START(copy_user_generic_unrolled)
127
101
_ASM_EXTABLE_CPY(14b, 30b)
128
102
_ASM_EXTABLE_CPY(15b, 30b)
129
103
_ASM_EXTABLE_CPY(16b, 30b)
130
- _ASM_EXTABLE_CPY(18b, 40b)
131
- _ASM_EXTABLE_CPY(19b, 40b)
132
- _ASM_EXTABLE_CPY(21b, 50b)
133
- _ASM_EXTABLE_CPY(22b, 50b)
134
104
SYM_FUNC_END(copy_user_generic_unrolled)
135
105
EXPORT_SYMBOL(copy_user_generic_unrolled)
136
106
@@ -191,7 +161,7 @@ EXPORT_SYMBOL(copy_user_generic_string)
191
161
SYM_FUNC_START(copy_user_enhanced_fast_string)
192
162
ASM_STAC
193
163
/* CPUs without FSRM should avoid rep movsb for short copies */
194
- ALTERNATIVE "cmpl $64, %edx; jb .L_copy_short_string " , "", X86_FEATURE_FSRM
164
+ ALTERNATIVE "cmpl $64, %edx; jb copy_user_short_string " , "", X86_FEATURE_FSRM
195
165
movl %edx ,%ecx
196
166
1: rep movsb
197
167
xorl %eax ,%eax
@@ -243,6 +213,53 @@ SYM_CODE_START_LOCAL(.Lcopy_user_handle_tail)
243
213
244
214
SYM_CODE_END(.Lcopy_user_handle_tail)
245
215
216
+ /*
217
+ * Finish memcpy of less than 64 bytes. #AC should already be set.
218
+ *
219
+ * Input:
220
+ * rdi destination
221
+ * rsi source
222
+ * rdx count (< 64)
223
+ *
224
+ * Output:
225
+ * eax uncopied bytes or 0 if successful.
226
+ */
227
+ SYM_CODE_START_LOCAL (copy_user_short_string)
228
+ movl %edx ,%ecx
229
+ andl $7 ,%edx
230
+ shrl $3 ,%ecx
231
+ jz .Lcopy_user_short_string_bytes
232
+ 18: movq (%rsi ),%r8
233
+ 19: movq %r8 ,(%rdi )
234
+ leaq 8 (%rsi ),%rsi
235
+ leaq 8 (%rdi ),%rdi
236
+ decl %ecx
237
+ jnz 18b
238
+ .Lcopy_user_short_string_bytes:
239
+ andl %edx ,%edx
240
+ jz 23f
241
+ movl %edx ,%ecx
242
+ 21: movb (%rsi ),%al
243
+ 22: movb %al ,(%rdi )
244
+ incq %rsi
245
+ incq %rdi
246
+ decl %ecx
247
+ jnz 21b
248
+ 23: xor %eax ,%eax
249
+ ASM_CLAC
250
+ RET
251
+
252
+ 40: leal (%rdx ,%rcx ,8 ),%edx
253
+ jmp 60f
254
+ 50: movl %ecx ,%edx /* ecx is zerorest also */
255
+ 60: jmp .Lcopy_user_handle_tail
256
+
257
+ _ASM_EXTABLE_CPY(18b, 40b)
258
+ _ASM_EXTABLE_CPY(19b, 40b)
259
+ _ASM_EXTABLE_CPY(21b, 50b)
260
+ _ASM_EXTABLE_CPY(22b, 50b)
261
+ SYM_CODE_END(copy_user_short_string)
262
+
246
263
/*
247
264
* copy_user_nocache - Uncached memory copy with exception handling
248
265
* This will force destination out of cache for more performance.
0 commit comments