Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Delta Between Two Patch Sets: src/pkg/runtime/linux/386/sys.s

Issue 4817054: code review 4817054: runtime, syscall: use the vdso page on linux x86 for fa... (Closed)
Left Patch Set: diff -r ac36ef8727b4 https://go.googlecode.com/hg/ Created 13 years, 8 months ago
Right Patch Set: diff -r 18c733109246 http://go.googlecode.com/hg/ Created 13 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/linux/386/signal.c ('k') | src/pkg/syscall/asm_linux_386.s » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // 5 //
6 // System calls and other sys.stuff for 386, Linux 6 // System calls and other sys.stuff for 386, Linux
7 // 7 //
8 8
9 #include "386/asm.h" 9 #include "386/asm.h"
10 10
11 TEXT runtime·exit(SB),7,$0 11 TEXT runtime·exit(SB),7,$0
12 MOVL $252, AX // syscall number 12 MOVL $252, AX // syscall number
13 MOVL 4(SP), BX 13 MOVL 4(SP), BX
14 » VDSO_SYSENTER 14 » CALL» *runtime·_vdso(SB)
15 INT $3 // not reached 15 INT $3 // not reached
16 RET 16 RET
17 17
18 TEXT runtime·exit1(SB),7,$0 18 TEXT runtime·exit1(SB),7,$0
19 MOVL $1, AX // exit - exit the current os thread 19 MOVL $1, AX // exit - exit the current os thread
20 MOVL 4(SP), BX 20 MOVL 4(SP), BX
21 » VDSO_SYSENTER 21 » CALL» *runtime·_vdso(SB)
22 INT $3 // not reached 22 INT $3 // not reached
23 RET
24
25 TEXT runtime·open(SB),7,$0
26 MOVL $5, AX // syscall - open
27 MOVL 4(SP), BX
28 MOVL 8(SP), CX
29 MOVL 12(SP), DX
30 CALL *runtime·_vdso(SB)
31 RET
32
33 TEXT runtime·close(SB),7,$0
34 MOVL $6, AX // syscall - close
35 MOVL 4(SP), BX
36 CALL *runtime·_vdso(SB)
23 RET 37 RET
24 38
25 TEXT runtime·write(SB),7,$0 39 TEXT runtime·write(SB),7,$0
26 MOVL $4, AX // syscall - write 40 MOVL $4, AX // syscall - write
27 » MOVL» 4(SP), BX 41 » MOVL» 4(SP), BX
28 » MOVL» 8(SP), CX 42 » MOVL» 8(SP), CX
29 » MOVL» 12(SP), DX 43 » MOVL» 12(SP), DX
30 » VDSO_SYSENTER 44 » CALL» *runtime·_vdso(SB)
45 » RET
46
47 TEXT runtime·read(SB),7,$0
48 » MOVL» $3, AX» » // syscall - read
49 » MOVL» 4(SP), BX
50 » MOVL» 8(SP), CX
51 » MOVL» 12(SP), DX
52 » CALL» *runtime·_vdso(SB)
31 RET 53 RET
32 54
33 TEXT runtime·raisesigpipe(SB),7,$12 55 TEXT runtime·raisesigpipe(SB),7,$12
34 MOVL $224, AX // syscall - gettid 56 MOVL $224, AX // syscall - gettid
35 » VDSO_SYSENTER 57 » CALL» *runtime·_vdso(SB)
36 MOVL AX, 0(SP) // arg 1 tid 58 MOVL AX, 0(SP) // arg 1 tid
37 MOVL $13, 4(SP) // arg 2 SIGPIPE 59 MOVL $13, 4(SP) // arg 2 SIGPIPE
38 MOVL $238, AX // syscall - tkill 60 MOVL $238, AX // syscall - tkill
39 » VDSO_SYSENTER 61 » CALL» *runtime·_vdso(SB)
40 RET 62 RET
41 63
42 TEXT runtime·setitimer(SB),7,$0-24 64 TEXT runtime·setitimer(SB),7,$0-24
43 MOVL $104, AX // syscall - setitimer 65 MOVL $104, AX // syscall - setitimer
44 MOVL 4(SP), BX 66 MOVL 4(SP), BX
45 MOVL 8(SP), CX 67 MOVL 8(SP), CX
46 MOVL 12(SP), DX 68 MOVL 12(SP), DX
47 » VDSO_SYSENTER 69 » CALL» *runtime·_vdso(SB)
48 RET 70 RET
49 71
50 TEXT runtime·mincore(SB),7,$0-24 72 TEXT runtime·mincore(SB),7,$0-24
51 MOVL $218, AX // syscall - mincore 73 MOVL $218, AX // syscall - mincore
52 MOVL 4(SP), BX 74 MOVL 4(SP), BX
53 MOVL 8(SP), CX 75 MOVL 8(SP), CX
54 MOVL 12(SP), DX 76 MOVL 12(SP), DX
55 » VDSO_SYSENTER 77 » CALL» *runtime·_vdso(SB)
56 RET 78 RET
57 79
58 TEXT runtime·gettime(SB), 7, $32 80 TEXT runtime·gettime(SB), 7, $32
59 MOVL $78, AX // syscall - gettimeofday 81 MOVL $78, AX // syscall - gettimeofday
60 LEAL 8(SP), BX 82 LEAL 8(SP), BX
61 MOVL $0, CX 83 MOVL $0, CX
62 MOVL $0, DX 84 MOVL $0, DX
63 » VDSO_SYSENTER 85 » CALL» *runtime·_vdso(SB)
64 86
65 MOVL 8(SP), BX // sec 87 MOVL 8(SP), BX // sec
66 MOVL sec+0(FP), DI 88 MOVL sec+0(FP), DI
67 MOVL BX, (DI) 89 MOVL BX, (DI)
68 MOVL $0, 4(DI) // zero extend 32 -> 64 bits 90 MOVL $0, 4(DI) // zero extend 32 -> 64 bits
69 91
70 MOVL 12(SP), BX // usec 92 MOVL 12(SP), BX // usec
71 MOVL usec+4(FP), DI 93 MOVL usec+4(FP), DI
72 MOVL BX, (DI) 94 MOVL BX, (DI)
73 RET 95 RET
74 96
75 TEXT runtime·rt_sigaction(SB),7,$0 97 TEXT runtime·rt_sigaction(SB),7,$0
76 MOVL $174, AX // syscall - rt_sigaction 98 MOVL $174, AX // syscall - rt_sigaction
77 MOVL 4(SP), BX 99 MOVL 4(SP), BX
78 MOVL 8(SP), CX 100 MOVL 8(SP), CX
79 MOVL 12(SP), DX 101 MOVL 12(SP), DX
80 MOVL 16(SP), SI 102 MOVL 16(SP), SI
81 » VDSO_SYSENTER 103 » CALL» *runtime·_vdso(SB)
82 RET 104 RET
83 105
84 TEXT runtime·sigtramp(SB),7,$44 106 TEXT runtime·sigtramp(SB),7,$44
85 get_tls(CX) 107 get_tls(CX)
86 ········ 108 ········
87 // save g 109 // save g
88 MOVL g(CX), DI 110 MOVL g(CX), DI
89 MOVL DI, 20(SP) 111 MOVL DI, 20(SP)
90 ········ 112 ········
91 // g = m->gsignal 113 // g = m->gsignal
(...skipping 17 matching lines...) Expand all
109 MOVL 20(SP), BX 131 MOVL 20(SP), BX
110 MOVL BX, g(CX) 132 MOVL BX, g(CX)
111 ········ 133 ········
112 RET 134 RET
113 135
114 TEXT runtime·sigignore(SB),7,$0 136 TEXT runtime·sigignore(SB),7,$0
115 RET 137 RET
116 138
117 TEXT runtime·sigreturn(SB),7,$0 139 TEXT runtime·sigreturn(SB),7,$0
118 MOVL $173, AX // rt_sigreturn 140 MOVL $173, AX // rt_sigreturn
141 // Sigreturn expects same SP as signal handler,
142 // so cannot CALL *runtime._vsdo(SB) here.
119 INT $0x80 143 INT $0x80
paulzhol 2011/07/27 14:34:34 using VDSO_SYSENTER instead causes http/cgi test t
rsc 2011/08/03 20:15:04 Please put that in a comment in the file. I can be
120 INT $3 // not reached 144 INT $3 // not reached
121 RET 145 RET
122 146
123 TEXT runtime·mmap(SB),7,$0 147 TEXT runtime·mmap(SB),7,$0
124 MOVL $192, AX // mmap2 148 MOVL $192, AX // mmap2
125 MOVL 4(SP), BX 149 MOVL 4(SP), BX
126 MOVL 8(SP), CX 150 MOVL 8(SP), CX
127 MOVL 12(SP), DX 151 MOVL 12(SP), DX
128 MOVL 16(SP), SI 152 MOVL 16(SP), SI
129 MOVL 20(SP), DI 153 MOVL 20(SP), DI
130 MOVL 24(SP), BP 154 MOVL 24(SP), BP
131 SHRL $12, BP 155 SHRL $12, BP
132 » VDSO_SYSENTER 156 » CALL» *runtime·_vdso(SB)
133 CMPL AX, $0xfffff001 157 CMPL AX, $0xfffff001
134 JLS 3(PC) 158 JLS 3(PC)
135 NOTL AX 159 NOTL AX
136 INCL AX 160 INCL AX
137 RET 161 RET
138 162
139 TEXT runtime·munmap(SB),7,$0 163 TEXT runtime·munmap(SB),7,$0
140 MOVL $91, AX // munmap 164 MOVL $91, AX // munmap
141 MOVL 4(SP), BX 165 MOVL 4(SP), BX
142 MOVL 8(SP), CX 166 MOVL 8(SP), CX
143 » VDSO_SYSENTER 167 » CALL» *runtime·_vdso(SB)
144 CMPL AX, $0xfffff001 168 CMPL AX, $0xfffff001
145 JLS 2(PC) 169 JLS 2(PC)
146 INT $3 170 INT $3
147 RET 171 RET
148 172
149 // int32 futex(int32 *uaddr, int32 op, int32 val, 173 // int32 futex(int32 *uaddr, int32 op, int32 val,
150 // struct timespec *timeout, int32 *uaddr2, int32 val2); 174 // struct timespec *timeout, int32 *uaddr2, int32 val2);
151 TEXT runtime·futex(SB),7,$0 175 TEXT runtime·futex(SB),7,$0
152 MOVL $240, AX // futex 176 MOVL $240, AX // futex
153 MOVL 4(SP), BX 177 MOVL 4(SP), BX
154 MOVL 8(SP), CX 178 MOVL 8(SP), CX
155 MOVL 12(SP), DX 179 MOVL 12(SP), DX
156 MOVL 16(SP), SI 180 MOVL 16(SP), SI
157 MOVL 20(SP), DI 181 MOVL 20(SP), DI
158 MOVL 24(SP), BP 182 MOVL 24(SP), BP
159 » VDSO_SYSENTER 183 » CALL» *runtime·_vdso(SB)
160 RET 184 RET
161 185
162 // int32 clone(int32 flags, void *stack, M *m, G *g, void (*fn)(void)); 186 // int32 clone(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
163 TEXT runtime·clone(SB),7,$0 187 TEXT runtime·clone(SB),7,$0
164 MOVL $120, AX // clone 188 MOVL $120, AX // clone
165 MOVL flags+4(SP), BX 189 MOVL flags+4(SP), BX
166 MOVL stack+8(SP), CX 190 MOVL stack+8(SP), CX
167 MOVL $0, DX // parent tid ptr 191 MOVL $0, DX // parent tid ptr
168 MOVL $0, DI // child tid ptr 192 MOVL $0, DI // child tid ptr
169 193
170 // Copy m, g, fn off parent stack for use by child. 194 // Copy m, g, fn off parent stack for use by child.
171 SUBL $16, CX 195 SUBL $16, CX
172 MOVL mm+12(SP), SI 196 MOVL mm+12(SP), SI
173 MOVL SI, 0(CX) 197 MOVL SI, 0(CX)
174 MOVL gg+16(SP), SI 198 MOVL gg+16(SP), SI
175 MOVL SI, 4(CX) 199 MOVL SI, 4(CX)
176 MOVL fn+20(SP), SI 200 MOVL fn+20(SP), SI
177 MOVL SI, 8(CX) 201 MOVL SI, 8(CX)
178 MOVL $1234, 12(CX) 202 MOVL $1234, 12(CX)
179 203
204 // cannot use CALL *runtime·_vdso(SB) here, because
205 // the stack changes during the system call (after·
206 // CALL *runtime·_vdso(SB), the child is still using
207 // the parent's stack when executing its RET instruction).
180 INT $0x80 208 INT $0x80
paulzhol 2011/07/27 14:34:34 using VDSO_SYSENTER instead causes cgo to segfault
rsc 2011/08/03 20:15:04 Add comment here too. Clone is even more magic, be
paulzhol 2011/08/05 16:14:23 Why is the stack change affecting an address in th
181 209
182 // In parent, return. 210 // In parent, return.
183 CMPL AX, $0 211 CMPL AX, $0
184 JEQ 2(PC) 212 JEQ 2(PC)
185 RET 213 RET
186 214
187 // Paranoia: check that SP is as we expect. 215 // Paranoia: check that SP is as we expect.
188 MOVL 12(SP), BP 216 MOVL 12(SP), BP
189 CMPL BP, $1234 217 CMPL BP, $1234
190 JEQ 2(PC) 218 JEQ 2(PC)
191 INT $3 219 INT $3
192 220
193 // Initialize AX to Linux tid 221 // Initialize AX to Linux tid
194 MOVL $224, AX 222 MOVL $224, AX
195 » VDSO_SYSENTER 223 » CALL» *runtime·_vdso(SB)
196 224
197 // In child on new stack. Reload registers (paranoia). 225 // In child on new stack. Reload registers (paranoia).
198 MOVL 0(SP), BX // m 226 MOVL 0(SP), BX // m
199 MOVL 4(SP), DX // g 227 MOVL 4(SP), DX // g
200 MOVL 8(SP), SI // fn 228 MOVL 8(SP), SI // fn
201 229
202 MOVL AX, m_procid(BX) // save tid as m->procid 230 MOVL AX, m_procid(BX) // save tid as m->procid
203 231
204 // set up ldt 7+id to point at m->tls. 232 // set up ldt 7+id to point at m->tls.
205 // newosproc left the id in tls[0]. 233 // newosproc left the id in tls[0].
(...skipping 27 matching lines...) Expand all
233 261
234 CALL SI // fn() 262 CALL SI // fn()
235 CALL runtime·exit1(SB) 263 CALL runtime·exit1(SB)
236 MOVL $0x1234, 0x1005 264 MOVL $0x1234, 0x1005
237 RET 265 RET
238 266
239 TEXT runtime·sigaltstack(SB),7,$-8 267 TEXT runtime·sigaltstack(SB),7,$-8
240 MOVL $186, AX // sigaltstack 268 MOVL $186, AX // sigaltstack
241 MOVL new+4(SP), BX 269 MOVL new+4(SP), BX
242 MOVL old+8(SP), CX 270 MOVL old+8(SP), CX
243 » VDSO_SYSENTER 271 » CALL» *runtime·_vdso(SB)
244 CMPL AX, $0xfffff001 272 CMPL AX, $0xfffff001
245 JLS 2(PC) 273 JLS 2(PC)
246 INT $3 274 INT $3
247 RET 275 RET
248 276
249 // <asm-i386/ldt.h> 277 // <asm-i386/ldt.h>
250 // struct user_desc { 278 // struct user_desc {
251 // unsigned int entry_number; 279 // unsigned int entry_number;
252 // unsigned long base_addr; 280 // unsigned long base_addr;
253 // unsigned int limit; 281 // unsigned int limit;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 MOVL BX, 0(AX) 322 MOVL BX, 0(AX)
295 MOVL CX, 4(AX) 323 MOVL CX, 4(AX)
296 MOVL $0xfffff, 8(AX) 324 MOVL $0xfffff, 8(AX)
297 MOVL $(SEG_32BIT|LIMIT_IN_PAGES|USEABLE|CONTENTS_DATA), 12(AX) // flag bits 325 MOVL $(SEG_32BIT|LIMIT_IN_PAGES|USEABLE|CONTENTS_DATA), 12(AX) // flag bits
298 326
299 // call modify_ldt 327 // call modify_ldt
300 MOVL $1, BX // func = 1 (write) 328 MOVL $1, BX // func = 1 (write)
301 MOVL AX, CX // user_desc 329 MOVL AX, CX // user_desc
302 MOVL $16, DX // sizeof(user_desc) 330 MOVL $16, DX // sizeof(user_desc)
303 MOVL $123, AX // syscall - modify_ldt 331 MOVL $123, AX // syscall - modify_ldt
304 » VDSO_SYSENTER 332 » CALL» *runtime·_vdso(SB)
305 333
306 // breakpoint on error 334 // breakpoint on error
307 CMPL AX, $0xfffff001 335 CMPL AX, $0xfffff001
308 JLS 2(PC) 336 JLS 2(PC)
309 INT $3 337 INT $3
310 338
311 // compute segment selector - (entry*8+7) 339 // compute segment selector - (entry*8+7)
312 MOVL entry+0(FP), AX 340 MOVL entry+0(FP), AX
313 SHLL $3, AX 341 SHLL $3, AX
314 ADDL $7, AX 342 ADDL $7, AX
315 MOVW AX, GS 343 MOVW AX, GS
316 344
317 RET 345 RET
346
347 TEXT runtime·osyield(SB),7,$0
348 MOVL $158, AX
349 CALL *runtime·_vdso(SB)
350 RET
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b