Commit 5cbbc3b1eb37bdc72eefd2de03b39f5e784400c2

Authored by Glauber Costa
Committed by Ingo Molnar
1 parent 2528de431d

x86: merge putuser asm functions.

putuser_32.S and putuser_64.S are merged into putuser.S.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 4 changed files with 98 additions and 185 deletions Side-by-side Diff

arch/x86/lib/Makefile
... ... @@ -5,7 +5,7 @@
5 5 obj-$(CONFIG_SMP) := msr-on-cpu.o
6 6  
7 7 lib-y := delay.o
8   -lib-y += usercopy_$(BITS).o getuser.o putuser_$(BITS).o
  8 +lib-y += usercopy_$(BITS).o getuser.o putuser.o
9 9 lib-y += memcpy_$(BITS).o
10 10  
11 11 ifeq ($(CONFIG_X86_32),y)
arch/x86/lib/putuser.S
  1 +/*
  2 + * __put_user functions.
  3 + *
  4 + * (C) Copyright 2005 Linus Torvalds
  5 + * (C) Copyright 2005 Andi Kleen
  6 + * (C) Copyright 2008 Glauber Costa
  7 + *
  8 + * These functions have a non-standard call interface
  9 + * to make them more efficient, especially as they
  10 + * return an error value in addition to the "real"
  11 + * return value.
  12 + */
  13 +#include <linux/linkage.h>
  14 +#include <asm/dwarf2.h>
  15 +#include <asm/thread_info.h>
  16 +#include <asm/errno.h>
  17 +#include <asm/asm.h>
  18 +
  19 +
  20 +/*
  21 + * __put_user_X
  22 + *
  23 + * Inputs: %eax[:%edx] contains the data
  24 + * %ecx contains the address
  25 + *
  26 + * Outputs: %eax is error code (0 or -EFAULT)
  27 + *
  28 + * These functions should not modify any other registers,
  29 + * as they get called from within inline assembly.
  30 + */
  31 +
  32 +#define ENTER CFI_STARTPROC ; \
  33 + GET_THREAD_INFO(%_ASM_BX)
  34 +#define EXIT ret ; \
  35 + CFI_ENDPROC
  36 +
  37 +.text
  38 +ENTRY(__put_user_1)
  39 + ENTER
  40 + cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
  41 + jae bad_put_user
  42 +1: movb %al,(%_ASM_CX)
  43 + xor %eax,%eax
  44 + EXIT
  45 +ENDPROC(__put_user_1)
  46 +
  47 +ENTRY(__put_user_2)
  48 + ENTER
  49 + mov TI_addr_limit(%_ASM_BX),%_ASM_BX
  50 + sub $1,%_ASM_BX
  51 + cmp %_ASM_BX,%_ASM_CX
  52 + jae bad_put_user
  53 +2: movw %ax,(%_ASM_CX)
  54 + xor %eax,%eax
  55 + EXIT
  56 +ENDPROC(__put_user_2)
  57 +
  58 +ENTRY(__put_user_4)
  59 + ENTER
  60 + mov TI_addr_limit(%_ASM_BX),%_ASM_BX
  61 + sub $3,%_ASM_BX
  62 + cmp %_ASM_BX,%_ASM_CX
  63 + jae bad_put_user
  64 +3: movl %eax,(%_ASM_CX)
  65 + xor %eax,%eax
  66 + EXIT
  67 +ENDPROC(__put_user_4)
  68 +
  69 +ENTRY(__put_user_8)
  70 + ENTER
  71 + mov TI_addr_limit(%_ASM_BX),%_ASM_BX
  72 + sub $7,%_ASM_BX
  73 + cmp %_ASM_BX,%_ASM_CX
  74 + jae bad_put_user
  75 +4: mov %_ASM_AX,(%_ASM_CX)
  76 +#ifdef CONFIG_X86_32
  77 +5: movl %edx,4(%_ASM_CX)
  78 +#endif
  79 + xor %eax,%eax
  80 + EXIT
  81 +ENDPROC(__put_user_8)
  82 +
  83 +bad_put_user:
  84 + CFI_STARTPROC
  85 + movl $-EFAULT,%eax
  86 + EXIT
  87 +END(bad_put_user)
  88 +
  89 +.section __ex_table,"a"
  90 + _ASM_PTR 1b,bad_put_user
  91 + _ASM_PTR 2b,bad_put_user
  92 + _ASM_PTR 3b,bad_put_user
  93 + _ASM_PTR 4b,bad_put_user
  94 +#ifdef CONFIG_X86_32
  95 + _ASM_PTR 5b,bad_put_user
  96 +#endif
  97 +.previous
arch/x86/lib/putuser_32.S
1   -/*
2   - * __put_user functions.
3   - *
4   - * (C) Copyright 2005 Linus Torvalds
5   - *
6   - * These functions have a non-standard call interface
7   - * to make them more efficient, especially as they
8   - * return an error value in addition to the "real"
9   - * return value.
10   - */
11   -#include <linux/linkage.h>
12   -#include <asm/dwarf2.h>
13   -#include <asm/thread_info.h>
14   -#include <asm/asm.h>
15   -
16   -
17   -/*
18   - * __put_user_X
19   - *
20   - * Inputs: %eax[:%edx] contains the data
21   - * %ecx contains the address
22   - *
23   - * Outputs: %eax is error code (0 or -EFAULT)
24   - *
25   - * These functions should not modify any other registers,
26   - * as they get called from within inline assembly.
27   - */
28   -
29   -#define ENTER CFI_STARTPROC ; \
30   - GET_THREAD_INFO(%_ASM_BX)
31   -#define EXIT ret ; \
32   - CFI_ENDPROC
33   -
34   -.text
35   -ENTRY(__put_user_1)
36   - ENTER
37   - cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
38   - jae bad_put_user
39   -1: movb %al,(%_ASM_CX)
40   - xor %eax,%eax
41   - EXIT
42   -ENDPROC(__put_user_1)
43   -
44   -ENTRY(__put_user_2)
45   - ENTER
46   - mov TI_addr_limit(%_ASM_BX),%_ASM_BX
47   - sub $1,%_ASM_BX
48   - cmp %_ASM_BX,%_ASM_CX
49   - jae bad_put_user
50   -2: movw %ax,(%_ASM_CX)
51   - xor %eax,%eax
52   - EXIT
53   -ENDPROC(__put_user_2)
54   -
55   -ENTRY(__put_user_4)
56   - ENTER
57   - mov TI_addr_limit(%_ASM_BX),%_ASM_BX
58   - sub $3,%_ASM_BX
59   - cmp %_ASM_BX,%_ASM_CX
60   - jae bad_put_user
61   -3: movl %eax,(%_ASM_CX)
62   - xor %eax,%eax
63   - EXIT
64   -ENDPROC(__put_user_4)
65   -
66   -ENTRY(__put_user_8)
67   - ENTER
68   - mov TI_addr_limit(%_ASM_BX),%_ASM_BX
69   - sub $7,%_ASM_BX
70   - cmp %_ASM_BX,%_ASM_CX
71   - jae bad_put_user
72   -4: movl %_ASM_AX,(%_ASM_CX)
73   -5: movl %edx,4(%_ASM_CX)
74   - xor %eax,%eax
75   - EXIT
76   -ENDPROC(__put_user_8)
77   -
78   -bad_put_user:
79   - CFI_STARTPROC
80   - movl $-14,%eax
81   - EXIT
82   -END(bad_put_user)
83   -
84   -.section __ex_table,"a"
85   - _ASM_PTR 1b,bad_put_user
86   - _ASM_PTR 2b,bad_put_user
87   - _ASM_PTR 3b,bad_put_user
88   - _ASM_PTR 4b,bad_put_user
89   - _ASM_PTR 5b,bad_put_user
90   -.previous
arch/x86/lib/putuser_64.S
1   -/*
2   - * __put_user functions.
3   - *
4   - * (C) Copyright 1998 Linus Torvalds
5   - * (C) Copyright 2005 Andi Kleen
6   - *
7   - * These functions have a non-standard call interface
8   - * to make them more efficient, especially as they
9   - * return an error value in addition to the "real"
10   - * return value.
11   - */
12   -
13   -/*
14   - * __put_user_X
15   - *
16   - * Inputs: %rcx contains the address
17   - * %rdx contains new value
18   - *
19   - * Outputs: %rax is error code (0 or -EFAULT)
20   - *
21   - * %rbx is destroyed.
22   - *
23   - * These functions should not modify any other registers,
24   - * as they get called from within inline assembly.
25   - */
26   -
27   -#include <linux/linkage.h>
28   -#include <asm/dwarf2.h>
29   -#include <asm/page.h>
30   -#include <asm/errno.h>
31   -#include <asm/asm-offsets.h>
32   -#include <asm/thread_info.h>
33   -#include <asm/asm.h>
34   -
35   -#define ENTER CFI_STARTPROC ; \
36   - GET_THREAD_INFO(%_ASM_BX)
37   -#define EXIT ret ; \
38   - CFI_ENDPROC
39   -
40   - .text
41   -ENTRY(__put_user_1)
42   - ENTER
43   - cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
44   - jae bad_put_user
45   -1: movb %al,(%_ASM_CX)
46   - xor %eax,%eax
47   - EXIT
48   -ENDPROC(__put_user_1)
49   -
50   -ENTRY(__put_user_2)
51   - ENTER
52   - mov TI_addr_limit(%_ASM_BX),%_ASM_BX
53   - sub $1, %_ASM_BX
54   - cmp %_ASM_BX ,%_ASM_CX
55   - jae bad_put_user
56   -2: movw %ax,(%_ASM_CX)
57   - xor %eax,%eax
58   - EXIT
59   -ENDPROC(__put_user_2)
60   -
61   -ENTRY(__put_user_4)
62   - ENTER
63   - mov TI_addr_limit(%_ASM_BX),%_ASM_BX
64   - sub $3, %_ASM_BX
65   - cmp %_ASM_BX, %_ASM_CX
66   - jae bad_put_user
67   -3: movl %eax,(%_ASM_CX)
68   - xor %eax,%eax
69   - EXIT
70   -ENDPROC(__put_user_4)
71   -
72   -ENTRY(__put_user_8)
73   - ENTER
74   - mov TI_addr_limit(%_ASM_BX),%_ASM_BX
75   - sub $7, %_ASM_BX
76   - cmp %_ASM_BX, %_ASM_CX
77   - jae bad_put_user
78   -4: movq %_ASM_AX,(%_ASM_CX)
79   - xor %eax,%eax
80   - EXIT
81   -ENDPROC(__put_user_8)
82   -
83   -bad_put_user:
84   - CFI_STARTPROC
85   - mov $(-EFAULT),%eax
86   - EXIT
87   -END(bad_put_user)
88   -
89   -.section __ex_table,"a"
90   - _ASM_PTR 1b,bad_put_user
91   - _ASM_PTR 2b,bad_put_user
92   - _ASM_PTR 3b,bad_put_user
93   - _ASM_PTR 4b,bad_put_user
94   -.previous