2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* __put_user functions.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2005 Linus Torvalds
|
2008-06-25 04:40:14 +08:00
|
|
|
* (C) Copyright 2005 Andi Kleen
|
|
|
|
* (C) Copyright 2008 Glauber Costa
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* These functions have a non-standard call interface
|
|
|
|
* to make them more efficient, especially as they
|
|
|
|
* return an error value in addition to the "real"
|
|
|
|
* return value.
|
|
|
|
*/
|
2007-05-03 01:27:05 +08:00
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <asm/dwarf2.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/thread_info.h>
|
2008-06-25 04:40:14 +08:00
|
|
|
#include <asm/errno.h>
|
2008-06-25 04:36:31 +08:00
|
|
|
#include <asm/asm.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* __put_user_X
|
|
|
|
*
|
|
|
|
* Inputs: %eax[:%edx] contains the data
|
|
|
|
* %ecx contains the address
|
|
|
|
*
|
|
|
|
* Outputs: %eax is error code (0 or -EFAULT)
|
|
|
|
*
|
|
|
|
* These functions should not modify any other registers,
|
|
|
|
* as they get called from within inline assembly.
|
|
|
|
*/
|
|
|
|
|
2007-05-03 01:27:05 +08:00
|
|
|
#define ENTER CFI_STARTPROC ; \
|
2008-06-25 04:36:31 +08:00
|
|
|
GET_THREAD_INFO(%_ASM_BX)
|
2008-06-24 23:40:55 +08:00
|
|
|
#define EXIT ret ; \
|
2007-05-03 01:27:05 +08:00
|
|
|
CFI_ENDPROC
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
.text
|
2007-05-03 01:27:05 +08:00
|
|
|
ENTRY(__put_user_1)
|
2005-04-17 06:20:36 +08:00
|
|
|
ENTER
|
2008-06-25 04:36:31 +08:00
|
|
|
cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
|
2005-04-17 06:20:36 +08:00
|
|
|
jae bad_put_user
|
2008-06-25 04:36:31 +08:00
|
|
|
1: movb %al,(%_ASM_CX)
|
2008-06-25 03:59:05 +08:00
|
|
|
xor %eax,%eax
|
2005-04-17 06:20:36 +08:00
|
|
|
EXIT
|
2007-05-03 01:27:05 +08:00
|
|
|
ENDPROC(__put_user_1)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-03 01:27:05 +08:00
|
|
|
ENTRY(__put_user_2)
|
2005-04-17 06:20:36 +08:00
|
|
|
ENTER
|
2008-06-25 04:36:31 +08:00
|
|
|
mov TI_addr_limit(%_ASM_BX),%_ASM_BX
|
|
|
|
sub $1,%_ASM_BX
|
|
|
|
cmp %_ASM_BX,%_ASM_CX
|
2005-04-17 06:20:36 +08:00
|
|
|
jae bad_put_user
|
2008-06-25 04:36:31 +08:00
|
|
|
2: movw %ax,(%_ASM_CX)
|
2008-06-25 03:59:05 +08:00
|
|
|
xor %eax,%eax
|
2005-04-17 06:20:36 +08:00
|
|
|
EXIT
|
2007-05-03 01:27:05 +08:00
|
|
|
ENDPROC(__put_user_2)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-03 01:27:05 +08:00
|
|
|
ENTRY(__put_user_4)
|
2005-04-17 06:20:36 +08:00
|
|
|
ENTER
|
2008-06-25 04:36:31 +08:00
|
|
|
mov TI_addr_limit(%_ASM_BX),%_ASM_BX
|
|
|
|
sub $3,%_ASM_BX
|
|
|
|
cmp %_ASM_BX,%_ASM_CX
|
2005-04-17 06:20:36 +08:00
|
|
|
jae bad_put_user
|
2008-06-25 04:36:31 +08:00
|
|
|
3: movl %eax,(%_ASM_CX)
|
2008-06-25 03:59:05 +08:00
|
|
|
xor %eax,%eax
|
2005-04-17 06:20:36 +08:00
|
|
|
EXIT
|
2007-05-03 01:27:05 +08:00
|
|
|
ENDPROC(__put_user_4)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-03 01:27:05 +08:00
|
|
|
ENTRY(__put_user_8)
|
2005-04-17 06:20:36 +08:00
|
|
|
ENTER
|
2008-06-25 04:36:31 +08:00
|
|
|
mov TI_addr_limit(%_ASM_BX),%_ASM_BX
|
|
|
|
sub $7,%_ASM_BX
|
|
|
|
cmp %_ASM_BX,%_ASM_CX
|
2005-04-17 06:20:36 +08:00
|
|
|
jae bad_put_user
|
2008-06-25 04:40:14 +08:00
|
|
|
4: mov %_ASM_AX,(%_ASM_CX)
|
|
|
|
#ifdef CONFIG_X86_32
|
2008-06-25 04:36:31 +08:00
|
|
|
5: movl %edx,4(%_ASM_CX)
|
2008-06-25 04:40:14 +08:00
|
|
|
#endif
|
2008-06-25 03:59:05 +08:00
|
|
|
xor %eax,%eax
|
2005-04-17 06:20:36 +08:00
|
|
|
EXIT
|
2007-05-03 01:27:05 +08:00
|
|
|
ENDPROC(__put_user_8)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
bad_put_user:
|
2008-06-24 23:40:55 +08:00
|
|
|
CFI_STARTPROC
|
2008-06-25 04:40:14 +08:00
|
|
|
movl $-EFAULT,%eax
|
2005-04-17 06:20:36 +08:00
|
|
|
EXIT
|
2007-05-03 01:27:05 +08:00
|
|
|
END(bad_put_user)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
.section __ex_table,"a"
|
2008-06-25 04:36:31 +08:00
|
|
|
_ASM_PTR 1b,bad_put_user
|
|
|
|
_ASM_PTR 2b,bad_put_user
|
|
|
|
_ASM_PTR 3b,bad_put_user
|
|
|
|
_ASM_PTR 4b,bad_put_user
|
2008-06-25 04:40:14 +08:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-06-25 04:36:31 +08:00
|
|
|
_ASM_PTR 5b,bad_put_user
|
2008-06-25 04:40:14 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
.previous
|