ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / x86_64 / kernel / vsyscall.S
1 /*
2  * Code for the vsyscall page.  This version uses the syscall instruction.
3  */
4
5 #include <asm/ia32_unistd.h>
6 #include <asm/offset.h>
7
8         .text
9         .globl __kernel_vsyscall
10         .type __kernel_vsyscall,@function
11 __kernel_vsyscall:
12 .LSTART_vsyscall:
13         push    %ebp
14 .Lpush_ebp:
15         movl    %ecx, %ebp
16         syscall
17         popl    %ebp
18 .Lpop_ebp:
19         ret
20 .LEND_vsyscall:
21         .size __kernel_vsyscall,.-.LSTART_vsyscall
22
23         .balign 32
24         .globl __kernel_sigreturn
25         .type __kernel_sigreturn,@function
26 __kernel_sigreturn:
27 .LSTART_sigreturn:
28         popl %eax
29         movl $__NR_ia32_sigreturn, %eax
30         syscall
31 .LEND_sigreturn:
32         .size __kernel_sigreturn,.-.LSTART_sigreturn
33
34         .balign 32
35         .globl __kernel_rt_sigreturn
36         .type __kernel_rt_sigreturn,@function
37 __kernel_rt_sigreturn:
38 .LSTART_rt_sigreturn:
39         movl $__NR_ia32_rt_sigreturn, %eax
40         syscall
41 .LEND_rt_sigreturn:
42         .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
43
44         .section .eh_frame,"a",@progbits
45 .LSTARTFRAME:
46         .long .LENDCIE-.LSTARTCIE
47 .LSTARTCIE:
48         .long 0                 /* CIE ID */
49         .byte 1                 /* Version number */
50         .string "zR"            /* NUL-terminated augmentation string */
51         .uleb128 1              /* Code alignment factor */
52         .sleb128 -4             /* Data alignment factor */
53         .byte 8                 /* Return address register column */
54         .uleb128 1              /* Augmentation value length */
55         .byte 0x1b              /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
56         .byte 0x0c              /* DW_CFA_def_cfa */
57         .uleb128 4
58         .uleb128 4
59         .byte 0x88              /* DW_CFA_offset, column 0x8 */
60         .uleb128 1
61         .align 4
62 .LENDCIE:
63
64         .long .LENDFDE1-.LSTARTFDE1     /* Length FDE */
65 .LSTARTFDE1:
66         .long .LSTARTFDE1-.LSTARTFRAME  /* CIE pointer */
67         .long .LSTART_vsyscall-.        /* PC-relative start address */
68         .long .LEND_vsyscall-.LSTART_vsyscall
69         .uleb128 0                      /* Augmentation length */
70         /* What follows are the instructions for the table generation.
71            We have to record all changes of the stack pointer.  */
72         .byte 0x40 + .Lpush_ebp-.LSTART_vsyscall /* DW_CFA_advance_loc */
73         .byte 0x0e              /* DW_CFA_def_cfa_offset */
74         .uleb128 8
75         .byte 0x85, 0x02        /* DW_CFA_offset %ebp -8 */
76         .byte 0x40 + .Lpop_ebp-.Lpush_ebp /* DW_CFA_advance_loc */
77         .byte 0xc5              /* DW_CFA_restore %ebp */
78         .byte 0x0e              /* DW_CFA_def_cfa_offset */
79         .uleb128 4
80         .align 4
81 .LENDFDE1:
82
83         .long .LENDFDE2-.LSTARTFDE2     /* Length FDE */
84 .LSTARTFDE2:
85         .long .LSTARTFDE2-.LSTARTFRAME  /* CIE pointer */
86         /* HACK: The dwarf2 unwind routines will subtract 1 from the
87            return address to get an address in the middle of the
88            presumed call instruction.  Since we didn't get here via
89            a call, we need to include the nop before the real start
90            to make up for it.  */
91         .long .LSTART_sigreturn-1-.     /* PC-relative start address */
92         .long .LEND_sigreturn-.LSTART_sigreturn+1
93         .uleb128 0                      /* Augmentation length */
94         /* What follows are the instructions for the table generation.
95            We record the locations of each register saved.  This is
96            complicated by the fact that the "CFA" is always assumed to
97            be the value of the stack pointer in the caller.  This means
98            that we must define the CFA of this body of code to be the
99            saved value of the stack pointer in the sigcontext.  Which
100            also means that there is no fixed relation to the other 
101            saved registers, which means that we must use DW_CFA_expression
102            to compute their addresses.  It also means that when we 
103            adjust the stack with the popl, we have to do it all over again.  */
104
105 #define do_cfa_expr(offset)                                             \
106         .byte 0x0f;                     /* DW_CFA_def_cfa_expression */ \
107         .uleb128 1f-0f;                 /*   length */                  \
108 0:      .byte 0x74;                     /*     DW_OP_breg4 */           \
109         .sleb128 offset;                /*      offset */               \
110         .byte 0x06;                     /*     DW_OP_deref */           \
111 1:
112
113 #define do_expr(regno, offset)                                          \
114         .byte 0x10;                     /* DW_CFA_expression */         \
115         .uleb128 regno;                 /*   regno */                   \
116         .uleb128 1f-0f;                 /*   length */                  \
117 0:      .byte 0x74;                     /*     DW_OP_breg4 */           \
118         .sleb128 offset;                /*       offset */              \
119 1:
120
121         do_cfa_expr(IA32_SIGCONTEXT_esp+4)
122         do_expr(0, IA32_SIGCONTEXT_eax+4)
123         do_expr(1, IA32_SIGCONTEXT_ecx+4)
124         do_expr(2, IA32_SIGCONTEXT_edx+4)
125         do_expr(3, IA32_SIGCONTEXT_ebx+4)
126         do_expr(5, IA32_SIGCONTEXT_ebp+4)
127         do_expr(6, IA32_SIGCONTEXT_esi+4)
128         do_expr(7, IA32_SIGCONTEXT_edi+4)
129         do_expr(8, IA32_SIGCONTEXT_eip+4)
130
131         .byte 0x42      /* DW_CFA_advance_loc 2 -- nop; popl eax. */
132
133         do_cfa_expr(IA32_SIGCONTEXT_esp)
134         do_expr(0, IA32_SIGCONTEXT_eax)
135         do_expr(1, IA32_SIGCONTEXT_ecx)
136         do_expr(2, IA32_SIGCONTEXT_edx)
137         do_expr(3, IA32_SIGCONTEXT_ebx)
138         do_expr(5, IA32_SIGCONTEXT_ebp)
139         do_expr(6, IA32_SIGCONTEXT_esi)
140         do_expr(7, IA32_SIGCONTEXT_edi)
141         do_expr(8, IA32_SIGCONTEXT_eip)
142
143         .align 4
144 .LENDFDE2:
145
146         .long .LENDFDE3-.LSTARTFDE3     /* Length FDE */
147 .LSTARTFDE3:
148         .long .LSTARTFDE3-.LSTARTFRAME  /* CIE pointer */
149         /* HACK: See above wrt unwind library assumptions.  */
150         .long .LSTART_rt_sigreturn-1-.  /* PC-relative start address */
151         .long .LEND_rt_sigreturn-.LSTART_rt_sigreturn+1
152         .uleb128 0                      /* Augmentation */
153         /* What follows are the instructions for the table generation.
154            We record the locations of each register saved.  This is
155            slightly less complicated than the above, since we don't
156            modify the stack pointer in the process.  */
157
158         do_cfa_expr(IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_esp)
159         do_expr(0, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_eax)
160         do_expr(1, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ecx)
161         do_expr(2, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_edx)
162         do_expr(3, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ebx)
163         do_expr(5, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ebp)
164         do_expr(6, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_esi)
165         do_expr(7, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_edi)
166         do_expr(8, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_eip)
167
168         .align 4
169 .LENDFDE3: