1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * linux/arch/arm/lib/csumpartialcopyuser.S 4 * 5 * Copyright (C) 1995-1998 Russell King 6 * 7 * 27/03/03 Ian Molton Clean up CONFIG_CPU 8 */ 9#include <linux/linkage.h> 10#include <asm/assembler.h> 11#include <asm/errno.h> 12#include <asm/asm-offsets.h> 13 14 .text 15 16#ifdef CONFIG_CPU_SW_DOMAIN_PAN 17 .macro save_regs 18 mrc p15, 0, ip, c3, c0, 0 19 stmfd sp!, {r1, r2, r4 - r8, ip, lr} 20 uaccess_enable ip 21 .endm 22 23 .macro load_regs 24 ldmfd sp!, {r1, r2, r4 - r8, ip, lr} 25 mcr p15, 0, ip, c3, c0, 0 26 ret lr 27 .endm 28#else 29 .macro save_regs 30 stmfd sp!, {r1, r2, r4 - r8, lr} 31 .endm 32 33 .macro load_regs 34 ldmfd sp!, {r1, r2, r4 - r8, pc} 35 .endm 36#endif 37 38 .macro load1b, reg1 39 ldrusr \reg1, r0, 1 40 .endm 41 42 .macro load2b, reg1, reg2 43 ldrusr \reg1, r0, 1 44 ldrusr \reg2, r0, 1 45 .endm 46 47 .macro load1l, reg1 48 ldrusr \reg1, r0, 4 49 .endm 50 51 .macro load2l, reg1, reg2 52 ldrusr \reg1, r0, 4 53 ldrusr \reg2, r0, 4 54 .endm 55 56 .macro load4l, reg1, reg2, reg3, reg4 57 ldrusr \reg1, r0, 4 58 ldrusr \reg2, r0, 4 59 ldrusr \reg3, r0, 4 60 ldrusr \reg4, r0, 4 61 .endm 62 63/* 64 * unsigned int 65 * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr) 66 * r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr 67 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT 68 */ 69 70#define FN_ENTRY ENTRY(csum_partial_copy_from_user) 71#define FN_EXIT ENDPROC(csum_partial_copy_from_user) 72 73#include "csumpartialcopygeneric.S" 74 75/* 76 * FIXME: minor buglet here 77 * We don't return the checksum for the data present in the buffer. To do 78 * so properly, we would have to add in whatever registers were loaded before 79 * the fault, which, with the current asm above is not predictable. 80 */ 81 .pushsection .text.fixup,"ax" 82 .align 4 839001: mov r4, #-EFAULT 84#ifdef CONFIG_CPU_SW_DOMAIN_PAN 85 ldr r5, [sp, #9*4] @ *err_ptr 86#else 87 ldr r5, [sp, #8*4] @ *err_ptr 88#endif 89 str r4, [r5] 90 ldmia sp, {r1, r2} @ retrieve dst, len 91 add r2, r2, r1 92 mov r0, #0 @ zero the buffer 939002: teq r2, r1 94 strbne r0, [r1], #1 95 bne 9002b 96 load_regs 97 .popsection 98