1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copy from user space to user space 4 * 5 * Copyright (C) 2012 ARM Ltd. 6 */ 7 8#include <linux/linkage.h> 9 10#include <asm/asm-uaccess.h> 11#include <asm/assembler.h> 12#include <asm/cache.h> 13 14/* 15 * Copy from user space to user space (alignment handled by the hardware) 16 * 17 * Parameters: 18 * x0 - to 19 * x1 - from 20 * x2 - n 21 * Returns: 22 * x0 - bytes not copied 23 */ 24 .macro ldrb1 reg, ptr, val 25 uao_user_alternative 9998f, ldrb, ldtrb, \reg, \ptr, \val 26 .endm 27 28 .macro strb1 reg, ptr, val 29 uao_user_alternative 9998f, strb, sttrb, \reg, \ptr, \val 30 .endm 31 32 .macro ldrh1 reg, ptr, val 33 uao_user_alternative 9997f, ldrh, ldtrh, \reg, \ptr, \val 34 .endm 35 36 .macro strh1 reg, ptr, val 37 uao_user_alternative 9997f, strh, sttrh, \reg, \ptr, \val 38 .endm 39 40 .macro ldr1 reg, ptr, val 41 uao_user_alternative 9997f, ldr, ldtr, \reg, \ptr, \val 42 .endm 43 44 .macro str1 reg, ptr, val 45 uao_user_alternative 9997f, str, sttr, \reg, \ptr, \val 46 .endm 47 48 .macro ldp1 reg1, reg2, ptr, val 49 uao_ldp 9997f, \reg1, \reg2, \ptr, \val 50 .endm 51 52 .macro stp1 reg1, reg2, ptr, val 53 uao_stp 9997f, \reg1, \reg2, \ptr, \val 54 .endm 55 56end .req x5 57srcin .req x15 58SYM_FUNC_START(__arch_copy_in_user) 59 add end, x0, x2 60 mov srcin, x1 61#include "copy_template.S" 62 mov x0, #0 63 ret 64SYM_FUNC_END(__arch_copy_in_user) 65EXPORT_SYMBOL(__arch_copy_in_user) 66 67 .section .fixup,"ax" 68 .align 2 699997: cmp dst, dstin 70 b.ne 9998f 71 // Before being absolutely sure we couldn't copy anything, try harder 72USER(9998f, ldtrb tmp1w, [srcin]) 73USER(9998f, sttrb tmp1w, [dst]) 74 add dst, dst, #1 759998: sub x0, end, dst // bytes not copied 76 ret 77 .previous 78