blob: 3d73dcb959b0da83bc8affe3a781b7fcbdb17752 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Catalin Marinas93ed3972008-08-28 11:22:32 +010035ENTRY(__put_user_1)
Russell King84046632012-09-07 18:22:28 +010036 check_uaccess r0, 1, r1, ip, __put_user_bad
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100371: TUSER(strb) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 mov r0, #0
39 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010040ENDPROC(__put_user_1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Catalin Marinas93ed3972008-08-28 11:22:32 +010042ENTRY(__put_user_2)
Russell King84046632012-09-07 18:22:28 +010043 check_uaccess r0, 2, r1, ip, __put_user_bad
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 mov ip, r2, lsr #8
Catalin Marinas8b592782009-07-24 12:32:57 +010045#ifdef CONFIG_THUMB2_KERNEL
46#ifndef __ARMEB__
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100472: TUSER(strb) r2, [r0]
483: TUSER(strb) ip, [r0, #1]
Catalin Marinas8b592782009-07-24 12:32:57 +010049#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100502: TUSER(strb) ip, [r0]
513: TUSER(strb) r2, [r0, #1]
Catalin Marinas8b592782009-07-24 12:32:57 +010052#endif
53#else /* !CONFIG_THUMB2_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#ifndef __ARMEB__
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100552: TUSER(strb) r2, [r0], #1
563: TUSER(strb) ip, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100582: TUSER(strb) ip, [r0], #1
593: TUSER(strb) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#endif
Catalin Marinas8b592782009-07-24 12:32:57 +010061#endif /* CONFIG_THUMB2_KERNEL */
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 mov r0, #0
63 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010064ENDPROC(__put_user_2)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Catalin Marinas93ed3972008-08-28 11:22:32 +010066ENTRY(__put_user_4)
Russell King84046632012-09-07 18:22:28 +010067 check_uaccess r0, 4, r1, ip, __put_user_bad
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100684: TUSER(str) r2, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 mov r0, #0
70 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010071ENDPROC(__put_user_4)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Catalin Marinas93ed3972008-08-28 11:22:32 +010073ENTRY(__put_user_8)
Russell King84046632012-09-07 18:22:28 +010074 check_uaccess r0, 8, r1, ip, __put_user_bad
Catalin Marinas8b592782009-07-24 12:32:57 +010075#ifdef CONFIG_THUMB2_KERNEL
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100765: TUSER(str) r2, [r0]
776: TUSER(str) r3, [r0, #4]
Catalin Marinas8b592782009-07-24 12:32:57 +010078#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100795: TUSER(str) r2, [r0], #4
806: TUSER(str) r3, [r0]
Catalin Marinas8b592782009-07-24 12:32:57 +010081#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 mov r0, #0
83 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010084ENDPROC(__put_user_8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86__put_user_bad:
87 mov r0, #-EFAULT
88 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +010089ENDPROC(__put_user_bad)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Russell King42604152010-04-19 10:15:03 +010091.pushsection __ex_table, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 .long 1b, __put_user_bad
93 .long 2b, __put_user_bad
94 .long 3b, __put_user_bad
95 .long 4b, __put_user_bad
96 .long 5b, __put_user_bad
97 .long 6b, __put_user_bad
Russell King42604152010-04-19 10:15:03 +010098.popsection