1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
/* $Id: entry64.S,v 1.7 2002/02/09 19:49:31 davem Exp $
* entry64.S: Solaris syscall emulation entry point.
*
* Copyright (C) 1996,1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
* Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
* Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
*/
#include <linux/errno.h>
#include <asm/head.h>
#include <asm/asi.h>
#include <asm/smp.h>
#include <asm/ptrace.h>
#include <asm/page.h>
#include <asm/signal.h>
#include <asm/pgtable.h>
#include <asm/processor.h>
#include <asm/thread_info.h>
#include "conv.h"
#define NR_SYSCALLS 256
.text
solaris_syscall_trace:
call syscall_trace
nop
srl %i0, 0, %o0
mov %i4, %o4
srl %i1, 0, %o1
mov %i5, %o5
andcc %l3, 1, %g0
be,pt %icc, 2f
srl %i2, 0, %o2
b,pt %xcc, 2f
add %sp, PTREGS_OFF, %o0
solaris_sucks:
/* Solaris is a big system which needs to be able to do all the things
* in Inf+1 different ways */
add %i6, 0x5c, %o0
mov %i0, %g1
mov %i1, %i0
mov %i2, %i1
srl %o0, 0, %o0
mov %i3, %i2
movrz %g1, 256, %g1 /* Ensure we don't loop forever */
mov %i4, %i3
mov %i5, %i4
ba,pt %xcc, solaris_sparc_syscall
exen: lduwa [%o0] ASI_S, %i5
exenf: ba,pt %xcc, solaris_sparc_syscall
clr %i5
/* For shared binaries, binfmt_elf32 already sets up personality
and exec_domain. This is to handle static binaries as well */
solaris_reg:
call solaris_register
nop
ba,pt %xcc, 1f
mov %i4, %o4
linux_syscall_for_solaris:
sethi %hi(sys_call_table32), %l6
or %l6, %lo(sys_call_table32), %l6
sll %l3, 2, %l4
ba,pt %xcc, 10f
lduw [%l6 + %l4], %l3
/* Solaris system calls enter here... */
.align 32
.globl solaris_sparc_syscall, entry64_personality_patch
solaris_sparc_syscall:
entry64_personality_patch:
ldub [%g4 + 0x0], %l0
cmp %g1, 255
bg,pn %icc, solaris_unimplemented
srl %g1, 0, %g1
sethi %hi(solaris_sys_table), %l7
or %l7, %lo(solaris_sys_table), %l7
brz,pn %g1, solaris_sucks
mov %i4, %o4
sll %g1, 2, %l4
cmp %l0, 1
bne,pn %icc, solaris_reg
1: srl %i0, 0, %o0
lduw [%l7 + %l4], %l3
srl %i1, 0, %o1
ldx [%g6 + TI_FLAGS], %l5
cmp %l3, NR_SYSCALLS
bleu,a,pn %xcc, linux_syscall_for_solaris
nop
andcc %l3, 1, %g0
bne,a,pn %icc, 10f
add %sp, PTREGS_OFF, %o0
10: srl %i2, 0, %o2
mov %i5, %o5
andn %l3, 3, %l7
andcc %l5, _TIF_SYSCALL_TRACE, %g0
bne,pn %icc, solaris_syscall_trace
mov %i0, %l5
2: call %l7
srl %i3, 0, %o3
ret_from_solaris:
stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
ldx [%g6 + TI_FLAGS], %l6
sra %o0, 0, %o0
mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
cmp %o0, -ERESTART_RESTARTBLOCK
sllx %g2, 32, %g2
bgeu,pn %xcc, 1f
andcc %l6, _TIF_SYSCALL_TRACE, %l6
/* System call success, clear Carry condition code. */
andn %g3, %g2, %g3
stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
bne,pn %icc, solaris_syscall_trace2
ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1
andcc %l1, 1, %g0
bne,pn %icc, 2f
clr %l6
add %l1, 0x4, %l2
stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc
call rtrap
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4
/* When tnpc & 1, this comes from setcontext and we don't want to advance pc */
2: andn %l1, 3, %l1
call rtrap
stx %l1, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc&~3
1:
/* System call failure, set Carry condition code.
* Also, get abs(errno) to return to the process.
*/
sub %g0, %o0, %o0
or %g3, %g2, %g3
cmp %o0, ERANGE /* 0-ERANGE are identity mapped */
bleu,pt %icc, 1f
cmp %o0, EMEDIUMTYPE
bgu,pn %icc, 1f
sethi %hi(solaris_err_table), %l6
sll %o0, 2, %o0
or %l6, %lo(solaris_err_table), %l6
ldsw [%l6 + %o0], %o0
1: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
mov 1, %l6
stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
bne,pn %icc, solaris_syscall_trace2
ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1
andcc %l1, 1, %g0
bne,pn %icc, 2b
add %l1, 0x4, %l2
stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] ! pc = npc
call rtrap
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] !npc = npc+4
solaris_syscall_trace2:
call syscall_trace
add %l1, 0x4, %l2 /* npc = npc+4 */
andcc %l1, 1, %g0
bne,pn %icc, 2b
nop
stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
call rtrap
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
/* This one is tricky, so that's why we do it in assembly */
.globl solaris_sigsuspend
solaris_sigsuspend:
call do_sol_sigsuspend
nop
brlz,pn %o0, ret_from_solaris
nop
call sys_sigsuspend
stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
.globl solaris_getpid
solaris_getpid:
call sys_getppid
nop
call sys_getpid
stx %o0, [%sp + PTREGS_OFF + PT_V9_I1]
b,pt %xcc, ret_from_solaris
nop
.globl solaris_getuid
solaris_getuid:
call sys_geteuid
nop
call sys_getuid
stx %o1, [%sp + PTREGS_OFF + PT_V9_I1]
b,pt %xcc, ret_from_solaris
nop
.globl solaris_getgid
solaris_getgid:
call sys_getegid
nop
call sys_getgid
stx %o1, [%sp + PTREGS_OFF + PT_V9_I1]
b,pt %xcc, ret_from_solaris
nop
.globl solaris_unimplemented
solaris_unimplemented:
call do_sol_unimplemented
add %sp, PTREGS_OFF, %o0
ba,pt %xcc, ret_from_solaris
nop
.section __ex_table,#alloc
.align 4
.word exen, exenf
|