getuser_32.S 1.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10
/*
 * __get_user functions.
 *
 * (C) Copyright 1998 Linus Torvalds
 *
 * 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.
 */
11 12
#include <linux/linkage.h>
#include <asm/dwarf2.h>
L
Linus Torvalds 已提交
13
#include <asm/thread_info.h>
G
Glauber Costa 已提交
14
#include <asm/asm.h>
L
Linus Torvalds 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29


/*
 * __get_user_X
 *
 * Inputs:	%eax contains the address
 *
 * Outputs:	%eax is error code (0 or -EFAULT)
 *		%edx contains zero-extended value
 *
 * These functions should not modify any other registers,
 * as they get called from within inline assembly.
 */

.text
30 31
ENTRY(__get_user_1)
	CFI_STARTPROC
G
Glauber Costa 已提交
32 33
	GET_THREAD_INFO(%_ASM_DX)
	cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
L
Linus Torvalds 已提交
34
	jae bad_get_user
G
Glauber Costa 已提交
35
1:	movzb (%_ASM_AX),%edx
36
	xor %eax,%eax
L
Linus Torvalds 已提交
37
	ret
38 39
	CFI_ENDPROC
ENDPROC(__get_user_1)
L
Linus Torvalds 已提交
40

41 42
ENTRY(__get_user_2)
	CFI_STARTPROC
G
Glauber Costa 已提交
43
	add $1,%_ASM_AX
L
Linus Torvalds 已提交
44
	jc bad_get_user
G
Glauber Costa 已提交
45 46
	GET_THREAD_INFO(%_ASM_DX)
	cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
L
Linus Torvalds 已提交
47
	jae bad_get_user
G
Glauber Costa 已提交
48
2:	movzwl -1(%_ASM_AX),%edx
49
	xor %eax,%eax
L
Linus Torvalds 已提交
50
	ret
51 52
	CFI_ENDPROC
ENDPROC(__get_user_2)
L
Linus Torvalds 已提交
53

54 55
ENTRY(__get_user_4)
	CFI_STARTPROC
G
Glauber Costa 已提交
56
	add $3,%_ASM_AX
L
Linus Torvalds 已提交
57
	jc bad_get_user
G
Glauber Costa 已提交
58 59
	GET_THREAD_INFO(%_ASM_DX)
	cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
L
Linus Torvalds 已提交
60
	jae bad_get_user
G
Glauber Costa 已提交
61
3:	mov -3(%_ASM_AX),%edx
62
	xor %eax,%eax
L
Linus Torvalds 已提交
63
	ret
64 65
	CFI_ENDPROC
ENDPROC(__get_user_4)
L
Linus Torvalds 已提交
66 67

bad_get_user:
68
	CFI_STARTPROC
69
	xor %edx,%edx
G
Glauber Costa 已提交
70
	mov $-14,%_ASM_AX
L
Linus Torvalds 已提交
71
	ret
72 73
	CFI_ENDPROC
END(bad_get_user)
L
Linus Torvalds 已提交
74 75

.section __ex_table,"a"
76 77 78
	_ASM_PTR 1b,bad_get_user
	_ASM_PTR 2b,bad_get_user
	_ASM_PTR 3b,bad_get_user
L
Linus Torvalds 已提交
79
.previous