blob: 11de126e2ed6bc757f5185ccf8ef0fe5551c6c08 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/lib/putuser.S
3 *
4 * Copyright (C) 2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
11 *
12 * These functions have a non-standard call interface to make
13 * them more efficient, especially as they return an error
14 * value in addition to the "real" return value.
15 *
16 * __put_user_X
17 *
18 * Inputs: r0 contains the address
Russell King84046632012-09-07 18:22:28 +010019 * r1 contains the address limit, which must be preserved
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 * r2, r3 contains the value
21 * Outputs: r0 is the error code
22 * lr corrupted
23 *
Russell King4baa9922008-08-02 10:55:55 +010024 * No other registers must be altered. (see <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 * for specific ASM register usage).
26 *
27 * Note that ADDR_LIMIT is either 0 or 0xc0000000
28 * Note also that it is intended that __put_user_bad is not global.
29 */
Catalin Marinas93ed3972008-08-28 11:22:32 +010030#include <linux/linkage.h>
Russell King84046632012-09-07 18:22:28 +010031#include <asm/assembler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <asm/errno.h>
Catalin Marinas247055a2010-09-13 16:03:21 +010033#include <asm/domain.h>
Al Viro4dd18372016-01-13 13:46:22 -050034#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Catalin Marinas93ed3972008-08-28 11:22:32 +010036ENTRY(__put_user_1)
Russell King84046632012-09-07 18:22:28 +010037 check_uaccess r0, 1, r1, ip, __put_user_bad
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100381: TUSER(strb) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 mov r0, #0
Russell King6ebbf2c2014-06-30 16:29:12 +010040 ret lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010041ENDPROC(__put_user_1)
Al Viro4dd18372016-01-13 13:46:22 -050042EXPORT_SYMBOL(__put_user_1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Catalin Marinas93ed3972008-08-28 11:22:32 +010044ENTRY(__put_user_2)
Russell King84046632012-09-07 18:22:28 +010045 check_uaccess r0, 2, r1, ip, __put_user_bad
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 mov ip, r2, lsr #8
Catalin Marinas8b592782009-07-24 12:32:57 +010047#ifdef CONFIG_THUMB2_KERNEL
48#ifndef __ARMEB__
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100492: TUSER(strb) r2, [r0]
503: TUSER(strb) ip, [r0, #1]
Catalin Marinas8b592782009-07-24 12:32:57 +010051#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100522: TUSER(strb) ip, [r0]
533: TUSER(strb) r2, [r0, #1]
Catalin Marinas8b592782009-07-24 12:32:57 +010054#endif
55#else /* !CONFIG_THUMB2_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#ifndef __ARMEB__
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100572: TUSER(strb) r2, [r0], #1
583: TUSER(strb) ip, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100602: TUSER(strb) ip, [r0], #1
613: TUSER(strb) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#endif
Catalin Marinas8b592782009-07-24 12:32:57 +010063#endif /* CONFIG_THUMB2_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 mov r0, #0
Russell King6ebbf2c2014-06-30 16:29:12 +010065 ret lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010066ENDPROC(__put_user_2)
Al Viro4dd18372016-01-13 13:46:22 -050067EXPORT_SYMBOL(__put_user_2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Catalin Marinas93ed3972008-08-28 11:22:32 +010069ENTRY(__put_user_4)
Russell King84046632012-09-07 18:22:28 +010070 check_uaccess r0, 4, r1, ip, __put_user_bad
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100714: TUSER(str) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 mov r0, #0
Russell King6ebbf2c2014-06-30 16:29:12 +010073 ret lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010074ENDPROC(__put_user_4)
Al Viro4dd18372016-01-13 13:46:22 -050075EXPORT_SYMBOL(__put_user_4)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Catalin Marinas93ed3972008-08-28 11:22:32 +010077ENTRY(__put_user_8)
Russell King84046632012-09-07 18:22:28 +010078 check_uaccess r0, 8, r1, ip, __put_user_bad
Catalin Marinas8b592782009-07-24 12:32:57 +010079#ifdef CONFIG_THUMB2_KERNEL
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100805: TUSER(str) r2, [r0]
816: TUSER(str) r3, [r0, #4]
Catalin Marinas8b592782009-07-24 12:32:57 +010082#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100835: TUSER(str) r2, [r0], #4
846: TUSER(str) r3, [r0]
Catalin Marinas8b592782009-07-24 12:32:57 +010085#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 mov r0, #0
Russell King6ebbf2c2014-06-30 16:29:12 +010087 ret lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010088ENDPROC(__put_user_8)
Al Viro4dd18372016-01-13 13:46:22 -050089EXPORT_SYMBOL(__put_user_8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91__put_user_bad:
92 mov r0, #-EFAULT
Russell King6ebbf2c2014-06-30 16:29:12 +010093 ret lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010094ENDPROC(__put_user_bad)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Russell King42604152010-04-19 10:15:03 +010096.pushsection __ex_table, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 .long 1b, __put_user_bad
98 .long 2b, __put_user_bad
99 .long 3b, __put_user_bad
100 .long 4b, __put_user_bad
101 .long 5b, __put_user_bad
102 .long 6b, __put_user_bad
Russell King42604152010-04-19 10:15:03 +0100103.popsection