Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  linux/arch/arm/lib/putuser.S
0004  *
0005  *  Copyright (C) 2001 Russell King
0006  *
0007  *  Idea from x86 version, (C) Copyright 1998 Linus Torvalds
0008  *
0009  * These functions have a non-standard call interface to make
0010  * them more efficient, especially as they return an error
0011  * value in addition to the "real" return value.
0012  *
0013  * __put_user_X
0014  *
0015  * Inputs:  r0 contains the address
0016  *      r1 contains the address limit, which must be preserved
0017  *      r2, r3 contains the value
0018  * Outputs: r0 is the error code
0019  *      lr corrupted
0020  *
0021  * No other registers must be altered.  (see <asm/uaccess.h>
0022  * for specific ASM register usage).
0023  *
0024  * Note that ADDR_LIMIT is either 0 or 0xc0000000
0025  * Note also that it is intended that __put_user_bad is not global.
0026  */
0027 #include <linux/linkage.h>
0028 #include <asm/assembler.h>
0029 #include <asm/errno.h>
0030 #include <asm/domain.h>
0031 
0032 ENTRY(__put_user_1)
0033     check_uaccess r0, 1, r1, ip, __put_user_bad
0034 1: TUSER(strb)  r2, [r0]
0035     mov r0, #0
0036     ret lr
0037 ENDPROC(__put_user_1)
0038 
0039 ENTRY(__put_user_2)
0040     check_uaccess r0, 2, r1, ip, __put_user_bad
0041 #if __LINUX_ARM_ARCH__ >= 6
0042 
0043 2: TUSER(strh)  r2, [r0]
0044 
0045 #else
0046 
0047     mov ip, r2, lsr #8
0048 #ifndef __ARMEB__
0049 2: TUSER(strb)  r2, [r0], #1
0050 3: TUSER(strb)  ip, [r0]
0051 #else
0052 2: TUSER(strb)  ip, [r0], #1
0053 3: TUSER(strb)  r2, [r0]
0054 #endif
0055 
0056 #endif /* __LINUX_ARM_ARCH__ >= 6 */
0057     mov r0, #0
0058     ret lr
0059 ENDPROC(__put_user_2)
0060 
0061 ENTRY(__put_user_4)
0062     check_uaccess r0, 4, r1, ip, __put_user_bad
0063 4: TUSER(str)   r2, [r0]
0064     mov r0, #0
0065     ret lr
0066 ENDPROC(__put_user_4)
0067 
0068 ENTRY(__put_user_8)
0069     check_uaccess r0, 8, r1, ip, __put_user_bad
0070 #ifdef CONFIG_THUMB2_KERNEL
0071 5: TUSER(str)   r2, [r0]
0072 6: TUSER(str)   r3, [r0, #4]
0073 #else
0074 5: TUSER(str)   r2, [r0], #4
0075 6: TUSER(str)   r3, [r0]
0076 #endif
0077     mov r0, #0
0078     ret lr
0079 ENDPROC(__put_user_8)
0080 
0081 __put_user_bad:
0082     mov r0, #-EFAULT
0083     ret lr
0084 ENDPROC(__put_user_bad)
0085 
0086 .pushsection __ex_table, "a"
0087     .long   1b, __put_user_bad
0088     .long   2b, __put_user_bad
0089 #if __LINUX_ARM_ARCH__ < 6
0090     .long   3b, __put_user_bad
0091 #endif
0092     .long   4b, __put_user_bad
0093     .long   5b, __put_user_bad
0094     .long   6b, __put_user_bad
0095 .popsection