putuser_32.S 1.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10
/*
 * __put_user functions.
 *
 * (C) Copyright 2005 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 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include <asm/thread_info.h>


/*
 * __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.
 */

28 29
#define ENTER	CFI_STARTPROC ; \
		GET_THREAD_INFO(%ebx)
30
#define EXIT	ret ; \
31
		CFI_ENDPROC
L
Linus Torvalds 已提交
32 33

.text
34
ENTRY(__put_user_1)
L
Linus Torvalds 已提交
35
	ENTER
36
	cmp TI_addr_limit(%ebx),%ecx
L
Linus Torvalds 已提交
37 38
	jae bad_put_user
1:	movb %al,(%ecx)
39
	xor %eax,%eax
L
Linus Torvalds 已提交
40
	EXIT
41
ENDPROC(__put_user_1)
L
Linus Torvalds 已提交
42

43
ENTRY(__put_user_2)
L
Linus Torvalds 已提交
44
	ENTER
45 46 47
	mov TI_addr_limit(%ebx),%ebx
	sub $1,%ebx
	cmp %ebx,%ecx
L
Linus Torvalds 已提交
48 49
	jae bad_put_user
2:	movw %ax,(%ecx)
50
	xor %eax,%eax
L
Linus Torvalds 已提交
51
	EXIT
52
ENDPROC(__put_user_2)
L
Linus Torvalds 已提交
53

54
ENTRY(__put_user_4)
L
Linus Torvalds 已提交
55
	ENTER
56 57 58
	mov TI_addr_limit(%ebx),%ebx
	sub $3,%ebx
	cmp %ebx,%ecx
L
Linus Torvalds 已提交
59 60
	jae bad_put_user
3:	movl %eax,(%ecx)
61
	xor %eax,%eax
L
Linus Torvalds 已提交
62
	EXIT
63
ENDPROC(__put_user_4)
L
Linus Torvalds 已提交
64

65
ENTRY(__put_user_8)
L
Linus Torvalds 已提交
66
	ENTER
67 68 69
	mov TI_addr_limit(%ebx),%ebx
	sub $7,%ebx
	cmp %ebx,%ecx
L
Linus Torvalds 已提交
70 71 72
	jae bad_put_user
4:	movl %eax,(%ecx)
5:	movl %edx,4(%ecx)
73
	xor %eax,%eax
L
Linus Torvalds 已提交
74
	EXIT
75
ENDPROC(__put_user_8)
L
Linus Torvalds 已提交
76 77

bad_put_user:
78
	CFI_STARTPROC
L
Linus Torvalds 已提交
79 80
	movl $-14,%eax
	EXIT
81
END(bad_put_user)
L
Linus Torvalds 已提交
82 83 84 85 86 87 88 89

.section __ex_table,"a"
	.long 1b,bad_put_user
	.long 2b,bad_put_user
	.long 3b,bad_put_user
	.long 4b,bad_put_user
	.long 5b,bad_put_user
.previous