]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * __put_user functions. | |
3 | * | |
4 | * (C) Copyright 2005 Linus Torvalds | |
5cbbc3b1 GC |
5 | * (C) Copyright 2005 Andi Kleen |
6 | * (C) Copyright 2008 Glauber Costa | |
1da177e4 LT |
7 | * |
8 | * These functions have a non-standard call interface | |
9 | * to make them more efficient, especially as they | |
10 | * return an error value in addition to the "real" | |
11 | * return value. | |
12 | */ | |
00e065ea | 13 | #include <linux/linkage.h> |
1da177e4 | 14 | #include <asm/thread_info.h> |
5cbbc3b1 | 15 | #include <asm/errno.h> |
2528de43 | 16 | #include <asm/asm.h> |
63bcff2a | 17 | #include <asm/smap.h> |
784d5699 | 18 | #include <asm/export.h> |
1da177e4 LT |
19 | |
20 | ||
21 | /* | |
22 | * __put_user_X | |
23 | * | |
24 | * Inputs: %eax[:%edx] contains the data | |
25 | * %ecx contains the address | |
26 | * | |
27 | * Outputs: %eax is error code (0 or -EFAULT) | |
28 | * | |
29 | * These functions should not modify any other registers, | |
30 | * as they get called from within inline assembly. | |
31 | */ | |
32 | ||
13d4ea09 | 33 | #define ENTER mov PER_CPU_VAR(current_task), %_ASM_BX |
63bcff2a | 34 | #define EXIT ASM_CLAC ; \ |
131484c8 | 35 | ret |
1da177e4 LT |
36 | |
37 | .text | |
00e065ea | 38 | ENTRY(__put_user_1) |
1da177e4 | 39 | ENTER |
13d4ea09 | 40 | cmp TASK_addr_limit(%_ASM_BX),%_ASM_CX |
1da177e4 | 41 | jae bad_put_user |
63bcff2a | 42 | ASM_STAC |
2528de43 | 43 | 1: movb %al,(%_ASM_CX) |
efea505d | 44 | xor %eax,%eax |
1da177e4 | 45 | EXIT |
00e065ea | 46 | ENDPROC(__put_user_1) |
784d5699 | 47 | EXPORT_SYMBOL(__put_user_1) |
1da177e4 | 48 | |
00e065ea | 49 | ENTRY(__put_user_2) |
1da177e4 | 50 | ENTER |
13d4ea09 | 51 | mov TASK_addr_limit(%_ASM_BX),%_ASM_BX |
2528de43 GC |
52 | sub $1,%_ASM_BX |
53 | cmp %_ASM_BX,%_ASM_CX | |
1da177e4 | 54 | jae bad_put_user |
63bcff2a | 55 | ASM_STAC |
2528de43 | 56 | 2: movw %ax,(%_ASM_CX) |
efea505d | 57 | xor %eax,%eax |
1da177e4 | 58 | EXIT |
00e065ea | 59 | ENDPROC(__put_user_2) |
784d5699 | 60 | EXPORT_SYMBOL(__put_user_2) |
1da177e4 | 61 | |
00e065ea | 62 | ENTRY(__put_user_4) |
1da177e4 | 63 | ENTER |
13d4ea09 | 64 | mov TASK_addr_limit(%_ASM_BX),%_ASM_BX |
2528de43 GC |
65 | sub $3,%_ASM_BX |
66 | cmp %_ASM_BX,%_ASM_CX | |
1da177e4 | 67 | jae bad_put_user |
63bcff2a | 68 | ASM_STAC |
2528de43 | 69 | 3: movl %eax,(%_ASM_CX) |
efea505d | 70 | xor %eax,%eax |
1da177e4 | 71 | EXIT |
00e065ea | 72 | ENDPROC(__put_user_4) |
784d5699 | 73 | EXPORT_SYMBOL(__put_user_4) |
1da177e4 | 74 | |
00e065ea | 75 | ENTRY(__put_user_8) |
1da177e4 | 76 | ENTER |
13d4ea09 | 77 | mov TASK_addr_limit(%_ASM_BX),%_ASM_BX |
2528de43 GC |
78 | sub $7,%_ASM_BX |
79 | cmp %_ASM_BX,%_ASM_CX | |
1da177e4 | 80 | jae bad_put_user |
63bcff2a | 81 | ASM_STAC |
5cbbc3b1 GC |
82 | 4: mov %_ASM_AX,(%_ASM_CX) |
83 | #ifdef CONFIG_X86_32 | |
2528de43 | 84 | 5: movl %edx,4(%_ASM_CX) |
5cbbc3b1 | 85 | #endif |
efea505d | 86 | xor %eax,%eax |
1da177e4 | 87 | EXIT |
00e065ea | 88 | ENDPROC(__put_user_8) |
784d5699 | 89 | EXPORT_SYMBOL(__put_user_8) |
1da177e4 LT |
90 | |
91 | bad_put_user: | |
5cbbc3b1 | 92 | movl $-EFAULT,%eax |
1da177e4 | 93 | EXIT |
00e065ea | 94 | END(bad_put_user) |
1da177e4 | 95 | |
a53a96e5 PA |
96 | _ASM_EXTABLE(1b,bad_put_user) |
97 | _ASM_EXTABLE(2b,bad_put_user) | |
98 | _ASM_EXTABLE(3b,bad_put_user) | |
99 | _ASM_EXTABLE(4b,bad_put_user) | |
5cbbc3b1 | 100 | #ifdef CONFIG_X86_32 |
a53a96e5 | 101 | _ASM_EXTABLE(5b,bad_put_user) |
5cbbc3b1 | 102 | #endif |