1*caab277bSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */ 20aea86a2SCatalin Marinas/* 30aea86a2SCatalin Marinas * Copyright (C) 2012 ARM Ltd. 40aea86a2SCatalin Marinas */ 50aea86a2SCatalin Marinas 60aea86a2SCatalin Marinas#include <linux/linkage.h> 7338d4f49SJames Morse 8b4b8664dSAl Viro#include <asm/asm-uaccess.h> 956c08ec5SMark Rutland#include <asm/assembler.h> 1056c08ec5SMark Rutland#include <asm/cache.h> 110aea86a2SCatalin Marinas 120aea86a2SCatalin Marinas/* 130aea86a2SCatalin Marinas * Copy from user space to a kernel buffer (alignment handled by the hardware) 140aea86a2SCatalin Marinas * 150aea86a2SCatalin Marinas * Parameters: 160aea86a2SCatalin Marinas * x0 - to 170aea86a2SCatalin Marinas * x1 - from 180aea86a2SCatalin Marinas * x2 - n 190aea86a2SCatalin Marinas * Returns: 200aea86a2SCatalin Marinas * x0 - bytes not copied 210aea86a2SCatalin Marinas */ 2240426882SFeng Kan 2340426882SFeng Kan .macro ldrb1 ptr, regB, val 2457f4959bSJames Morse uao_user_alternative 9998f, ldrb, ldtrb, \ptr, \regB, \val 2540426882SFeng Kan .endm 2640426882SFeng Kan 2740426882SFeng Kan .macro strb1 ptr, regB, val 2840426882SFeng Kan strb \ptr, [\regB], \val 2940426882SFeng Kan .endm 3040426882SFeng Kan 3140426882SFeng Kan .macro ldrh1 ptr, regB, val 3257f4959bSJames Morse uao_user_alternative 9998f, ldrh, ldtrh, \ptr, \regB, \val 3340426882SFeng Kan .endm 3440426882SFeng Kan 3540426882SFeng Kan .macro strh1 ptr, regB, val 3640426882SFeng Kan strh \ptr, [\regB], \val 3740426882SFeng Kan .endm 3840426882SFeng Kan 3940426882SFeng Kan .macro ldr1 ptr, regB, val 4057f4959bSJames Morse uao_user_alternative 9998f, ldr, ldtr, \ptr, \regB, \val 4140426882SFeng Kan .endm 4240426882SFeng Kan 4340426882SFeng Kan .macro str1 ptr, regB, val 4440426882SFeng Kan str \ptr, [\regB], \val 4540426882SFeng Kan .endm 4640426882SFeng Kan 4740426882SFeng Kan .macro ldp1 ptr, regB, regC, val 4857f4959bSJames Morse uao_ldp 9998f, \ptr, \regB, \regC, \val 4940426882SFeng Kan .endm 5040426882SFeng Kan 5140426882SFeng Kan .macro stp1 ptr, regB, regC, val 5240426882SFeng Kan stp \ptr, \regB, [\regC], \val 5340426882SFeng Kan .endm 5440426882SFeng Kan 5540426882SFeng Kanend .req x5 56bffe1bafSYang ShiENTRY(__arch_copy_from_user) 5727a921e7SWill Deacon uaccess_enable_not_uao x3, x4, x5 5840426882SFeng Kan add end, x0, x2 5940426882SFeng Kan#include "copy_template.S" 606b88a32cSCatalin Marinas uaccess_disable_not_uao x3, x4 6140426882SFeng Kan mov x0, #0 // Nothing to copy 620aea86a2SCatalin Marinas ret 63bffe1bafSYang ShiENDPROC(__arch_copy_from_user) 6456c08ec5SMark RutlandEXPORT_SYMBOL(__arch_copy_from_user) 650aea86a2SCatalin Marinas 660aea86a2SCatalin Marinas .section .fixup,"ax" 670aea86a2SCatalin Marinas .align 2 684855bd25SAl Viro9998: sub x0, end, dst // bytes not copied 690aea86a2SCatalin Marinas ret 700aea86a2SCatalin Marinas .previous 71