Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * __get_user functions. |
| 3 | * |
| 4 | * (C) Copyright 1998 Linus Torvalds |
| 5 | * |
| 6 | * These functions have a non-standard call interface |
| 7 | * to make them more efficient, especially as they |
| 8 | * return an error value in addition to the "real" |
| 9 | * return value. |
| 10 | */ |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 11 | #include <linux/linkage.h> |
| 12 | #include <asm/dwarf2.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/thread_info.h> |
| 14 | |
| 15 | |
| 16 | /* |
| 17 | * __get_user_X |
| 18 | * |
| 19 | * Inputs: %eax contains the address |
| 20 | * |
| 21 | * Outputs: %eax is error code (0 or -EFAULT) |
| 22 | * %edx contains zero-extended value |
| 23 | * |
| 24 | * These functions should not modify any other registers, |
| 25 | * as they get called from within inline assembly. |
| 26 | */ |
| 27 | |
| 28 | .text |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 29 | ENTRY(__get_user_1) |
| 30 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | GET_THREAD_INFO(%edx) |
| 32 | cmpl TI_addr_limit(%edx),%eax |
| 33 | jae bad_get_user |
| 34 | 1: movzbl (%eax),%edx |
| 35 | xorl %eax,%eax |
| 36 | ret |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 37 | CFI_ENDPROC |
| 38 | ENDPROC(__get_user_1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 40 | ENTRY(__get_user_2) |
| 41 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | addl $1,%eax |
| 43 | jc bad_get_user |
| 44 | GET_THREAD_INFO(%edx) |
| 45 | cmpl TI_addr_limit(%edx),%eax |
| 46 | jae bad_get_user |
| 47 | 2: movzwl -1(%eax),%edx |
| 48 | xorl %eax,%eax |
| 49 | ret |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 50 | CFI_ENDPROC |
| 51 | ENDPROC(__get_user_2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 53 | ENTRY(__get_user_4) |
| 54 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | addl $3,%eax |
| 56 | jc bad_get_user |
| 57 | GET_THREAD_INFO(%edx) |
| 58 | cmpl TI_addr_limit(%edx),%eax |
| 59 | jae bad_get_user |
| 60 | 3: movl -3(%eax),%edx |
| 61 | xorl %eax,%eax |
| 62 | ret |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 63 | CFI_ENDPROC |
| 64 | ENDPROC(__get_user_4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | bad_get_user: |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 67 | CFI_STARTPROC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | xorl %edx,%edx |
| 69 | movl $-14,%eax |
| 70 | ret |
Jan Beulich | 00e065e | 2007-05-02 19:27:05 +0200 | [diff] [blame] | 71 | CFI_ENDPROC |
| 72 | END(bad_get_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | .section __ex_table,"a" |
| 75 | .long 1b,bad_get_user |
| 76 | .long 2b,bad_get_user |
| 77 | .long 3b,bad_get_user |
| 78 | .previous |