1/*
2 * Common code for the sigreturn entry points in vDSO images.
3 * So far this code is the same for both int80 and sysenter versions.
4 * This file is #include'd by int80.S et al to define them first thing.
5 * The kernel assumes that the addresses of these routines are constant
6 * for all vDSO implementations.
7 */
8
9#include <linux/linkage.h>
10#include <asm/unistd_32.h>
11#include <asm/asm-offsets.h>
12
13#ifndef SYSCALL_ENTER_KERNEL
14#define	SYSCALL_ENTER_KERNEL	int $0x80
15#endif
16
17	.text
18	.globl __kernel_sigreturn
19	.type __kernel_sigreturn,@function
20	ALIGN
21__kernel_sigreturn:
22.LSTART_sigreturn:
23	popl %eax		/* XXX does this mean it needs unwind info? */
24	movl $__NR_sigreturn, %eax
25	SYSCALL_ENTER_KERNEL
26.LEND_sigreturn:
27	nop
28	.size __kernel_sigreturn,.-.LSTART_sigreturn
29
30	.globl __kernel_rt_sigreturn
31	.type __kernel_rt_sigreturn,@function
32	ALIGN
33__kernel_rt_sigreturn:
34.LSTART_rt_sigreturn:
35	movl $__NR_rt_sigreturn, %eax
36	SYSCALL_ENTER_KERNEL
37.LEND_rt_sigreturn:
38	nop
39	.size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
40	.previous
41
42	.section .eh_frame,"a",@progbits
43.LSTARTFRAMEDLSI1:
44	.long .LENDCIEDLSI1-.LSTARTCIEDLSI1
45.LSTARTCIEDLSI1:
46	.long 0			/* CIE ID */
47	.byte 1			/* Version number */
48	.string "zRS"		/* NUL-terminated augmentation string */
49	.uleb128 1		/* Code alignment factor */
50	.sleb128 -4		/* Data alignment factor */
51	.byte 8			/* Return address register column */
52	.uleb128 1		/* Augmentation value length */
53	.byte 0x1b		/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
54	.byte 0			/* DW_CFA_nop */
55	.align 4
56.LENDCIEDLSI1:
57	.long .LENDFDEDLSI1-.LSTARTFDEDLSI1 /* Length FDE */
58.LSTARTFDEDLSI1:
59	.long .LSTARTFDEDLSI1-.LSTARTFRAMEDLSI1 /* CIE pointer */
60	/* HACK: The dwarf2 unwind routines will subtract 1 from the
61	   return address to get an address in the middle of the
62	   presumed call instruction.  Since we didn't get here via
63	   a call, we need to include the nop before the real start
64	   to make up for it.  */
65	.long .LSTART_sigreturn-1-.	/* PC-relative start address */
66	.long .LEND_sigreturn-.LSTART_sigreturn+1
67	.uleb128 0			/* Augmentation */
68	/* What follows are the instructions for the table generation.
69	   We record the locations of each register saved.  This is
70	   complicated by the fact that the "CFA" is always assumed to
71	   be the value of the stack pointer in the caller.  This means
72	   that we must define the CFA of this body of code to be the
73	   saved value of the stack pointer in the sigcontext.  Which
74	   also means that there is no fixed relation to the other
75	   saved registers, which means that we must use DW_CFA_expression
76	   to compute their addresses.  It also means that when we
77	   adjust the stack with the popl, we have to do it all over again.  */
78
79#define do_cfa_expr(offset)						\
80	.byte 0x0f;			/* DW_CFA_def_cfa_expression */	\
81	.uleb128 1f-0f;			/*   length */			\
820:	.byte 0x74;			/*     DW_OP_breg4 */		\
83	.sleb128 offset;		/*      offset */		\
84	.byte 0x06;			/*     DW_OP_deref */		\
851:
86
87#define do_expr(regno, offset)						\
88	.byte 0x10;			/* DW_CFA_expression */		\
89	.uleb128 regno;			/*   regno */			\
90	.uleb128 1f-0f;			/*   length */			\
910:	.byte 0x74;			/*     DW_OP_breg4 */		\
92	.sleb128 offset;		/*       offset */		\
931:
94
95	do_cfa_expr(IA32_SIGCONTEXT_sp+4)
96	do_expr(0, IA32_SIGCONTEXT_ax+4)
97	do_expr(1, IA32_SIGCONTEXT_cx+4)
98	do_expr(2, IA32_SIGCONTEXT_dx+4)
99	do_expr(3, IA32_SIGCONTEXT_bx+4)
100	do_expr(5, IA32_SIGCONTEXT_bp+4)
101	do_expr(6, IA32_SIGCONTEXT_si+4)
102	do_expr(7, IA32_SIGCONTEXT_di+4)
103	do_expr(8, IA32_SIGCONTEXT_ip+4)
104
105	.byte 0x42	/* DW_CFA_advance_loc 2 -- nop; popl eax. */
106
107	do_cfa_expr(IA32_SIGCONTEXT_sp)
108	do_expr(0, IA32_SIGCONTEXT_ax)
109	do_expr(1, IA32_SIGCONTEXT_cx)
110	do_expr(2, IA32_SIGCONTEXT_dx)
111	do_expr(3, IA32_SIGCONTEXT_bx)
112	do_expr(5, IA32_SIGCONTEXT_bp)
113	do_expr(6, IA32_SIGCONTEXT_si)
114	do_expr(7, IA32_SIGCONTEXT_di)
115	do_expr(8, IA32_SIGCONTEXT_ip)
116
117	.align 4
118.LENDFDEDLSI1:
119
120	.long .LENDFDEDLSI2-.LSTARTFDEDLSI2 /* Length FDE */
121.LSTARTFDEDLSI2:
122	.long .LSTARTFDEDLSI2-.LSTARTFRAMEDLSI1 /* CIE pointer */
123	/* HACK: See above wrt unwind library assumptions.  */
124	.long .LSTART_rt_sigreturn-1-.	/* PC-relative start address */
125	.long .LEND_rt_sigreturn-.LSTART_rt_sigreturn+1
126	.uleb128 0			/* Augmentation */
127	/* What follows are the instructions for the table generation.
128	   We record the locations of each register saved.  This is
129	   slightly less complicated than the above, since we don't
130	   modify the stack pointer in the process.  */
131
132	do_cfa_expr(IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_sp)
133	do_expr(0, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ax)
134	do_expr(1, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_cx)
135	do_expr(2, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_dx)
136	do_expr(3, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_bx)
137	do_expr(5, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_bp)
138	do_expr(6, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_si)
139	do_expr(7, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_di)
140	do_expr(8, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ip)
141
142	.align 4
143.LENDFDEDLSI2:
144	.previous
145