putuser_64.S 1.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * __put_user functions.
 *
 * (C) Copyright 1998 Linus Torvalds
 * (C) Copyright 2005 Andi Kleen
 *
 * 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.
 */

/*
 * __put_user_X
 *
 * Inputs:	%rcx contains the address
 *		%rdx contains new value
 *
 * Outputs:	%rax is error code (0 or -EFAULT)
 *
 * %r8 is destroyed.
 *
 * These functions should not modify any other registers,
 * as they get called from within inline assembly.
 */

#include <linux/linkage.h>
28
#include <asm/dwarf2.h>
L
Linus Torvalds 已提交
29 30
#include <asm/page.h>
#include <asm/errno.h>
31
#include <asm/asm-offsets.h>
L
Linus Torvalds 已提交
32 33 34
#include <asm/thread_info.h>

	.text
35 36
ENTRY(__put_user_1)
	CFI_STARTPROC
L
Linus Torvalds 已提交
37 38 39 40 41 42
	GET_THREAD_INFO(%r8)
	cmpq threadinfo_addr_limit(%r8),%rcx
	jae bad_put_user
1:	movb %dl,(%rcx)
	xorl %eax,%eax
	ret
43 44
	CFI_ENDPROC
ENDPROC(__put_user_1)
L
Linus Torvalds 已提交
45

46 47
ENTRY(__put_user_2)
	CFI_STARTPROC
L
Linus Torvalds 已提交
48 49
	GET_THREAD_INFO(%r8)
	addq $1,%rcx
50
	jc 20f
L
Linus Torvalds 已提交
51
	cmpq threadinfo_addr_limit(%r8),%rcx
52
	jae 20f
53 54
	decq %rcx
2:	movw %dx,(%rcx)
L
Linus Torvalds 已提交
55 56
	xorl %eax,%eax
	ret
57 58
20:	decq %rcx
	jmp bad_put_user
59 60
	CFI_ENDPROC
ENDPROC(__put_user_2)
L
Linus Torvalds 已提交
61

62 63
ENTRY(__put_user_4)
	CFI_STARTPROC
L
Linus Torvalds 已提交
64 65
	GET_THREAD_INFO(%r8)
	addq $3,%rcx
66
	jc 30f
L
Linus Torvalds 已提交
67
	cmpq threadinfo_addr_limit(%r8),%rcx
68
	jae 30f
69 70
	subq $3,%rcx
3:	movl %edx,(%rcx)
L
Linus Torvalds 已提交
71 72
	xorl %eax,%eax
	ret
73 74
30:	subq $3,%rcx
	jmp bad_put_user
75 76
	CFI_ENDPROC
ENDPROC(__put_user_4)
L
Linus Torvalds 已提交
77

78 79
ENTRY(__put_user_8)
	CFI_STARTPROC
L
Linus Torvalds 已提交
80 81
	GET_THREAD_INFO(%r8)
	addq $7,%rcx
82
	jc 40f
L
Linus Torvalds 已提交
83
	cmpq threadinfo_addr_limit(%r8),%rcx
84
	jae 40f
85 86
	subq $7,%rcx
4:	movq %rdx,(%rcx)
L
Linus Torvalds 已提交
87 88
	xorl %eax,%eax
	ret
89 90
40:	subq $7,%rcx
	jmp bad_put_user
91 92
	CFI_ENDPROC
ENDPROC(__put_user_8)
L
Linus Torvalds 已提交
93 94

bad_put_user:
95
	CFI_STARTPROC
L
Linus Torvalds 已提交
96 97
	movq $(-EFAULT),%rax
	ret
98 99
	CFI_ENDPROC
END(bad_put_user)
L
Linus Torvalds 已提交
100 101 102 103 104 105 106

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