hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/m68k/lib/checksum.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * INET An implementation of the TCP/IP protocol suite for the LINUX
34 * operating system. INET is implemented using the BSD Socket
....@@ -21,11 +22,6 @@
2122 * data-registers to hold input values and one tries to
2223 * specify d0 and d1 as scratch registers. Letting gcc
2324 * choose these registers itself solves the problem.
24
- *
25
- * This program is free software; you can redistribute it and/or
26
- * modify it under the terms of the GNU General Public License
27
- * as published by the Free Software Foundation; either version
28
- * 2 of the License, or (at your option) any later version.
2925 *
3026 * 1998/8/31 Andreas Schwab:
3127 * Zero out rest of buffer on exception in
....@@ -133,8 +129,7 @@
133129 */
134130
135131 __wsum
136
-csum_partial_copy_from_user(const void __user *src, void *dst,
137
- int len, __wsum sum, int *csum_err)
132
+csum_and_copy_from_user(const void __user *src, void *dst, int len)
138133 {
139134 /*
140135 * GCC doesn't like more than 10 operands for the asm
....@@ -142,6 +137,7 @@
142137 * code.
143138 */
144139 unsigned long tmp1, tmp2;
140
+ __wsum sum = ~0U;
145141
146142 __asm__("movel %2,%4\n\t"
147143 "btst #1,%4\n\t" /* Check alignment */
....@@ -240,87 +236,36 @@
240236 "clrl %5\n\t"
241237 "addxl %5,%0\n\t" /* add X bit */
242238 "7:\t"
243
- "clrl %5\n" /* no error - clear return value */
244
- "8:\n"
245239 ".section .fixup,\"ax\"\n"
246240 ".even\n"
247
- /* If any exception occurs zero out the rest.
248
- Similarities with the code above are intentional :-) */
241
+ /* If any exception occurs, return 0 */
249242 "90:\t"
250
- "clrw %3@+\n\t"
251
- "movel %1,%4\n\t"
252
- "lsrl #5,%1\n\t"
253
- "jeq 1f\n\t"
254
- "subql #1,%1\n"
255
- "91:\t"
256
- "clrl %3@+\n"
257
- "92:\t"
258
- "clrl %3@+\n"
259
- "93:\t"
260
- "clrl %3@+\n"
261
- "94:\t"
262
- "clrl %3@+\n"
263
- "95:\t"
264
- "clrl %3@+\n"
265
- "96:\t"
266
- "clrl %3@+\n"
267
- "97:\t"
268
- "clrl %3@+\n"
269
- "98:\t"
270
- "clrl %3@+\n\t"
271
- "dbra %1,91b\n\t"
272
- "clrw %1\n\t"
273
- "subql #1,%1\n\t"
274
- "jcc 91b\n"
275
- "1:\t"
276
- "movel %4,%1\n\t"
277
- "andw #0x1c,%4\n\t"
278
- "jeq 1f\n\t"
279
- "lsrw #2,%4\n\t"
280
- "subqw #1,%4\n"
281
- "99:\t"
282
- "clrl %3@+\n\t"
283
- "dbra %4,99b\n\t"
284
- "1:\t"
285
- "andw #3,%1\n\t"
286
- "jeq 9f\n"
287
- "100:\t"
288
- "clrw %3@+\n\t"
289
- "tstw %1\n\t"
290
- "jeq 9f\n"
291
- "101:\t"
292
- "clrb %3@+\n"
293
- "9:\t"
294
-#define STR(X) STR1(X)
295
-#define STR1(X) #X
296
- "moveq #-" STR(EFAULT) ",%5\n\t"
297
- "jra 8b\n"
243
+ "clrl %0\n"
244
+ "jra 7b\n"
298245 ".previous\n"
299246 ".section __ex_table,\"a\"\n"
300247 ".long 10b,90b\n"
301
- ".long 11b,91b\n"
302
- ".long 12b,92b\n"
303
- ".long 13b,93b\n"
304
- ".long 14b,94b\n"
305
- ".long 15b,95b\n"
306
- ".long 16b,96b\n"
307
- ".long 17b,97b\n"
308
- ".long 18b,98b\n"
309
- ".long 19b,99b\n"
310
- ".long 20b,100b\n"
311
- ".long 21b,101b\n"
248
+ ".long 11b,90b\n"
249
+ ".long 12b,90b\n"
250
+ ".long 13b,90b\n"
251
+ ".long 14b,90b\n"
252
+ ".long 15b,90b\n"
253
+ ".long 16b,90b\n"
254
+ ".long 17b,90b\n"
255
+ ".long 18b,90b\n"
256
+ ".long 19b,90b\n"
257
+ ".long 20b,90b\n"
258
+ ".long 21b,90b\n"
312259 ".previous"
313260 : "=d" (sum), "=d" (len), "=a" (src), "=a" (dst),
314261 "=&d" (tmp1), "=d" (tmp2)
315262 : "0" (sum), "1" (len), "2" (src), "3" (dst)
316263 );
317264
318
- *csum_err = tmp2;
319
-
320
- return(sum);
265
+ return sum;
321266 }
322267
323
-EXPORT_SYMBOL(csum_partial_copy_from_user);
268
+EXPORT_SYMBOL(csum_and_copy_from_user);
324269
325270
326271 /*
....@@ -328,9 +273,10 @@
328273 */
329274
330275 __wsum
331
-csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
276
+csum_partial_copy_nocheck(const void *src, void *dst, int len)
332277 {
333278 unsigned long tmp1, tmp2;
279
+ __wsum sum = 0;
334280 __asm__("movel %2,%4\n\t"
335281 "btst #1,%4\n\t" /* Check alignment */
336282 "jeq 2f\n\t"