Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edf10162 authored by Glauber Costa's avatar Glauber Costa Committed by Ingo Molnar
Browse files

x86: don't clobber r8 nor use rcx.



There's really no reason to clobber r8 or pass the address in rcx.
We can safely use only two registers (which we already have to touch anyway)
to do the job.

Signed-off-by: default avatarGlauber Costa <gcosta@redhat.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f8dd0d3c
Loading
Loading
Loading
Loading
+21 −21
Original line number Original line Diff line number Diff line
@@ -36,10 +36,10 @@
	.text
	.text
ENTRY(__get_user_1)
ENTRY(__get_user_1)
	CFI_STARTPROC
	CFI_STARTPROC
	GET_THREAD_INFO(%r8)
	GET_THREAD_INFO(%rdx)
	cmpq threadinfo_addr_limit(%r8),%rcx
	cmpq threadinfo_addr_limit(%rdx),%rax
	jae bad_get_user
	jae bad_get_user
1:	movzb (%rcx),%edx
1:	movzb (%rax),%edx
	xorl %eax,%eax
	xorl %eax,%eax
	ret
	ret
	CFI_ENDPROC
	CFI_ENDPROC
@@ -47,48 +47,48 @@ ENDPROC(__get_user_1)


ENTRY(__get_user_2)
ENTRY(__get_user_2)
	CFI_STARTPROC
	CFI_STARTPROC
	GET_THREAD_INFO(%r8)
	GET_THREAD_INFO(%rdx)
	addq $1,%rcx
	addq $1,%rax
	jc 20f
	jc 20f
	cmpq threadinfo_addr_limit(%r8),%rcx
	cmpq threadinfo_addr_limit(%rdx),%rax
	jae 20f
	jae 20f
	decq   %rcx
	decq   %rax
2:	movzwl (%rcx),%edx
2:	movzwl (%rax),%edx
	xorl %eax,%eax
	xorl %eax,%eax
	ret
	ret
20:	decq    %rcx
20:	decq    %rax
	jmp	bad_get_user
	jmp	bad_get_user
	CFI_ENDPROC
	CFI_ENDPROC
ENDPROC(__get_user_2)
ENDPROC(__get_user_2)


ENTRY(__get_user_4)
ENTRY(__get_user_4)
	CFI_STARTPROC
	CFI_STARTPROC
	GET_THREAD_INFO(%r8)
	GET_THREAD_INFO(%rdx)
	addq $3,%rcx
	addq $3,%rax
	jc 30f
	jc 30f
	cmpq threadinfo_addr_limit(%r8),%rcx
	cmpq threadinfo_addr_limit(%rdx),%rax
	jae 30f
	jae 30f
	subq $3,%rcx
	subq $3,%rax
3:	movl (%rcx),%edx
3:	movl (%rax),%edx
	xorl %eax,%eax
	xorl %eax,%eax
	ret
	ret
30:	subq $3,%rcx
30:	subq $3,%rax
	jmp bad_get_user
	jmp bad_get_user
	CFI_ENDPROC
	CFI_ENDPROC
ENDPROC(__get_user_4)
ENDPROC(__get_user_4)


ENTRY(__get_user_8)
ENTRY(__get_user_8)
	CFI_STARTPROC
	CFI_STARTPROC
	GET_THREAD_INFO(%r8)
	GET_THREAD_INFO(%rdx)
	addq $7,%rcx
	addq $7,%rax
	jc 40f
	jc 40f
	cmpq threadinfo_addr_limit(%r8),%rcx
	cmpq threadinfo_addr_limit(%rdx),%rax
	jae	40f
	jae	40f
	subq	$7,%rcx
	subq	$7,%rax
4:	movq (%rcx),%rdx
4:	movq (%rax),%rdx
	xorl %eax,%eax
	xorl %eax,%eax
	ret
	ret
40:	subq $7,%rcx
40:	subq $7,%rax
	jmp bad_get_user
	jmp bad_get_user
	CFI_ENDPROC
	CFI_ENDPROC
ENDPROC(__get_user_8)
ENDPROC(__get_user_8)
+1 −2
Original line number Original line Diff line number Diff line
@@ -90,8 +90,7 @@ extern int fixup_exception(struct pt_regs *regs);
#define __get_user_x(size, ret, x, ptr)		      \
#define __get_user_x(size, ret, x, ptr)		      \
	asm volatile("call __get_user_" #size	      \
	asm volatile("call __get_user_" #size	      \
		     : "=a" (ret),"=d" (x)	      \
		     : "=a" (ret),"=d" (x)	      \
		     : "c" (ptr)		      \
		     : "0" (ptr))		      \
		     : "r8")


/* Careful: we have to cast the result to the type of the pointer
/* Careful: we have to cast the result to the type of the pointer
 * for sign reasons */
 * for sign reasons */