Commit 40faf463 authored by Glauber Costa's avatar Glauber Costa Committed by Ingo Molnar

x86: introduce __ASM_REG macro.

There are situations in which the architecture wants to use the
register that represents its word-size, whatever it is. For those,
introduce __ASM_REG in asm.h, along with the first users _ASM_AX
and _ASM_DX. They have users waiting for it, namely the getuser
functions.
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 ef8c1a2d
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/dwarf2.h> #include <asm/dwarf2.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/asm.h>
/* /*
...@@ -28,10 +29,10 @@ ...@@ -28,10 +29,10 @@
.text .text
ENTRY(__get_user_1) ENTRY(__get_user_1)
CFI_STARTPROC CFI_STARTPROC
GET_THREAD_INFO(%edx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%edx),%eax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
1: movzb (%eax),%edx 1: movzb (%_ASM_AX),%edx
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -39,12 +40,12 @@ ENDPROC(__get_user_1) ...@@ -39,12 +40,12 @@ ENDPROC(__get_user_1)
ENTRY(__get_user_2) ENTRY(__get_user_2)
CFI_STARTPROC CFI_STARTPROC
add $1,%eax add $1,%_ASM_AX
jc bad_get_user jc bad_get_user
GET_THREAD_INFO(%edx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%edx),%eax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
2: movzwl -1(%eax),%edx 2: movzwl -1(%_ASM_AX),%edx
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -52,12 +53,12 @@ ENDPROC(__get_user_2) ...@@ -52,12 +53,12 @@ ENDPROC(__get_user_2)
ENTRY(__get_user_4) ENTRY(__get_user_4)
CFI_STARTPROC CFI_STARTPROC
add $3,%eax add $3,%_ASM_AX
jc bad_get_user jc bad_get_user
GET_THREAD_INFO(%edx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%edx),%eax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
3: mov -3(%eax),%edx 3: mov -3(%_ASM_AX),%edx
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -66,7 +67,7 @@ ENDPROC(__get_user_4) ...@@ -66,7 +67,7 @@ ENDPROC(__get_user_4)
bad_get_user: bad_get_user:
CFI_STARTPROC CFI_STARTPROC
xor %edx,%edx xor %edx,%edx
mov $-14,%eax mov $-14,%_ASM_AX
ret ret
CFI_ENDPROC CFI_ENDPROC
END(bad_get_user) END(bad_get_user)
......
...@@ -13,14 +13,13 @@ ...@@ -13,14 +13,13 @@
/* /*
* __get_user_X * __get_user_X
* *
* Inputs: %rcx contains the address. * Inputs: %rax contains the address.
* The register is modified, but all changes are undone * The register is modified, but all changes are undone
* before returning because the C code doesn't know about it. * before returning because the C code doesn't know about it.
* *
* Outputs: %rax is error code (0 or -EFAULT) * Outputs: %rax is error code (0 or -EFAULT)
* %rdx contains zero-extended value * %rdx contains zero-extended value
* *
* %r8 is destroyed.
* *
* These functions should not modify any other registers, * These functions should not modify any other registers,
* as they get called from within inline assembly. * as they get called from within inline assembly.
...@@ -32,14 +31,15 @@ ...@@ -32,14 +31,15 @@
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/asm.h>
.text .text
ENTRY(__get_user_1) ENTRY(__get_user_1)
CFI_STARTPROC CFI_STARTPROC
GET_THREAD_INFO(%rdx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%rdx),%rax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
1: movzb (%rax),%edx 1: movzb (%_ASM_AX),%edx
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -47,12 +47,12 @@ ENDPROC(__get_user_1) ...@@ -47,12 +47,12 @@ ENDPROC(__get_user_1)
ENTRY(__get_user_2) ENTRY(__get_user_2)
CFI_STARTPROC CFI_STARTPROC
add $1,%rax add $1,%_ASM_AX
jc bad_get_user jc bad_get_user
GET_THREAD_INFO(%rdx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%rdx),%rax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
2: movzwl -1(%rax),%edx 2: movzwl -1(%_ASM_AX),%edx
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -60,12 +60,12 @@ ENDPROC(__get_user_2) ...@@ -60,12 +60,12 @@ ENDPROC(__get_user_2)
ENTRY(__get_user_4) ENTRY(__get_user_4)
CFI_STARTPROC CFI_STARTPROC
add $3,%rax add $3,%_ASM_AX
jc bad_get_user jc bad_get_user
GET_THREAD_INFO(%rdx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%rdx),%rax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
3: mov -3(%rax),%edx 3: mov -3(%_ASM_AX),%edx
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -73,12 +73,12 @@ ENDPROC(__get_user_4) ...@@ -73,12 +73,12 @@ ENDPROC(__get_user_4)
ENTRY(__get_user_8) ENTRY(__get_user_8)
CFI_STARTPROC CFI_STARTPROC
add $7,%rax add $7,%_ASM_AX
jc bad_get_user jc bad_get_user
GET_THREAD_INFO(%rdx) GET_THREAD_INFO(%_ASM_DX)
cmp TI_addr_limit(%rdx),%rax cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
jae bad_get_user jae bad_get_user
4: movq -7(%rax),%rdx 4: movq -7(%_ASM_AX),%_ASM_DX
xor %eax,%eax xor %eax,%eax
ret ret
CFI_ENDPROC CFI_ENDPROC
...@@ -87,7 +87,7 @@ ENDPROC(__get_user_8) ...@@ -87,7 +87,7 @@ ENDPROC(__get_user_8)
bad_get_user: bad_get_user:
CFI_STARTPROC CFI_STARTPROC
xor %edx,%edx xor %edx,%edx
mov $(-EFAULT),%rax mov $(-EFAULT),%_ASM_AX
ret ret
CFI_ENDPROC CFI_ENDPROC
END(bad_get_user) END(bad_get_user)
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#endif #endif
#define __ASM_SIZE(inst) __ASM_SEL(inst##l, inst##q) #define __ASM_SIZE(inst) __ASM_SEL(inst##l, inst##q)
#define __ASM_REG(reg) __ASM_SEL(e##reg, r##reg)
#define _ASM_PTR __ASM_SEL(.long, .quad) #define _ASM_PTR __ASM_SEL(.long, .quad)
#define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8) #define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8)
...@@ -24,6 +25,8 @@ ...@@ -24,6 +25,8 @@
#define _ASM_ADD __ASM_SIZE(add) #define _ASM_ADD __ASM_SIZE(add)
#define _ASM_SUB __ASM_SIZE(sub) #define _ASM_SUB __ASM_SIZE(sub)
#define _ASM_XADD __ASM_SIZE(xadd) #define _ASM_XADD __ASM_SIZE(xadd)
#define _ASM_AX __ASM_REG(ax)
#define _ASM_DX __ASM_REG(dx)
/* Exception table entry */ /* Exception table entry */
# define _ASM_EXTABLE(from,to) \ # define _ASM_EXTABLE(from,to) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment