/* SPDX-License-Identifier: GPL-2.0-only */1/*2* linux/arch/arm/lib/putuser.S3*4* Copyright (C) 2001 Russell King5*6* Idea from x86 version, (C) Copyright 1998 Linus Torvalds7*8* These functions have a non-standard call interface to make9* them more efficient, especially as they return an error10* value in addition to the "real" return value.11*12* __put_user_X13*14* Inputs: r0 contains the address15* r1 contains the address limit, which must be preserved16* r2, r3 contains the value17* Outputs: r0 is the error code18* lr corrupted19*20* No other registers must be altered. (see <asm/uaccess.h>21* for specific ASM register usage).22*23* Note that ADDR_LIMIT is either 0 or 0xc000000024* Note also that it is intended that __put_user_bad is not global.25*/26#include <linux/linkage.h>27#include <asm/assembler.h>28#include <asm/errno.h>29#include <asm/domain.h>3031ENTRY(__put_user_1)32check_uaccess r0, 1, r1, ip, __put_user_bad331: TUSER(strb) r2, [r0]34mov r0, #035ret lr36ENDPROC(__put_user_1)3738ENTRY(__put_user_2)39check_uaccess r0, 2, r1, ip, __put_user_bad40#if __LINUX_ARM_ARCH__ >= 641422: TUSER(strh) r2, [r0]4344#else4546mov ip, r2, lsr #847#ifndef __ARMEB__482: TUSER(strb) r2, [r0], #1493: TUSER(strb) ip, [r0]50#else512: TUSER(strb) ip, [r0], #1523: TUSER(strb) r2, [r0]53#endif5455#endif /* __LINUX_ARM_ARCH__ >= 6 */56mov r0, #057ret lr58ENDPROC(__put_user_2)5960ENTRY(__put_user_4)61check_uaccess r0, 4, r1, ip, __put_user_bad624: TUSER(str) r2, [r0]63mov r0, #064ret lr65ENDPROC(__put_user_4)6667ENTRY(__put_user_8)68check_uaccess r0, 8, r1, ip, __put_user_bad69#ifdef CONFIG_THUMB2_KERNEL705: TUSER(str) r2, [r0]716: TUSER(str) r3, [r0, #4]72#else735: TUSER(str) r2, [r0], #4746: TUSER(str) r3, [r0]75#endif76mov r0, #077ret lr78ENDPROC(__put_user_8)7980__put_user_bad:81mov r0, #-EFAULT82ret lr83ENDPROC(__put_user_bad)8485.pushsection __ex_table, "a"86.long 1b, __put_user_bad87.long 2b, __put_user_bad88#if __LINUX_ARM_ARCH__ < 689.long 3b, __put_user_bad90#endif91.long 4b, __put_user_bad92.long 5b, __put_user_bad93.long 6b, __put_user_bad94.popsection959697