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