Skip to content

Commit fe67ce2

Browse files
committed
runtime: fix vet complaints for linux/amd64
Working toward making the tree vet-safe instead of having so many exceptions in cmd/vet/all/whitelist. This CL makes "GOOS=linux GOARCH=amd64 go vet -unsafeptr=false runtime" happy, while keeping "GO_BUILDER_NAME=misc-vetall go tool dist test" happy too. For #31916. Change-Id: I4ca1acb02f4666b102d25fcc55fac96b8f80379a Reviewed-on: https://go-review.googlesource.com/c/go/+/176100 Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 6ed2ec4 commit fe67ce2

20 files changed

+17
-55
lines changed

src/cmd/vet/all/whitelist/amd64.txt

-15
This file was deleted.

src/cmd/vet/all/whitelist/android_amd64.txt

-3
This file was deleted.

src/cmd/vet/all/whitelist/darwin_amd64.txt

-3
This file was deleted.

src/cmd/vet/all/whitelist/dragonfly_amd64.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// dragonfly/amd64-specific vet whitelist. See readme.txt for details.
22

3-
runtime/sys_dragonfly_amd64.s: [amd64] settls: function settls missing Go declaration
43

54
syscall/asm9_unix2_amd64.s: [amd64] Syscall9: 8(SP) should be num+0(FP)
65
syscall/asm9_unix2_amd64.s: [amd64] Syscall9: 16(SP) should be a1+8(FP)
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// freebsd/amd64-specific vet whitelist. See readme.txt for details.
22

3-
runtime/sys_freebsd_amd64.s: [amd64] settls: function settls missing Go declaration
43
syscall/asm9_unix2_amd64.s: [amd64] Syscall9: 8(SP) should be num+0(FP)
54
syscall/asm9_unix2_amd64.s: [amd64] Syscall9: 16(SP) should be a1+8(FP)
65
syscall/asm9_unix2_amd64.s: [amd64] Syscall9: 24(SP) should be a2+16(FP)
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// illumos/amd64-specific vet whitelist. See readme.txt for details.
22

3-
runtime/sys_solaris_amd64.s: [amd64] settls: function settls missing Go declaration
43
runtime/sys_solaris_amd64.s: [amd64] pipe1: function pipe1 missing Go declaration
54
runtime/sys_solaris_amd64.s: [amd64] asmsysvicall6: function asmsysvicall6 missing Go declaration
65
runtime/sys_solaris_amd64.s: [amd64] usleep2: function usleep2 missing Go declaration

src/cmd/vet/all/whitelist/linux_amd64.txt

-3
This file was deleted.

src/cmd/vet/all/whitelist/nacl_amd64p32.txt

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ runtime/sys_nacl_amd64p32.s: [amd64p32] sigtramp: unknown variable ctxt
1010
runtime/sys_nacl_amd64p32.s: [amd64p32] sigtramp: unknown variable ctxt
1111
runtime/sys_nacl_amd64p32.s: [amd64p32] nacl_sysinfo: function nacl_sysinfo missing Go declaration
1212
runtime/sys_nacl_amd64p32.s: [amd64p32] nacl_clock_gettime: function nacl_clock_gettime missing Go declaration
13-
runtime/sys_nacl_amd64p32.s: [amd64p32] settls: function settls missing Go declaration
1413

1514
// Clearer using FP than SP, but that requires named offsets.
1615
runtime/asm_amd64p32.s: [amd64p32] rt0_go: unknown variable argc

src/cmd/vet/all/whitelist/netbsd_386.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// netbsd/386-specific vet whitelist. See readme.txt for details.
22

3-
runtime/sys_netbsd_ARCHSUFF.s: [GOARCH] settls: function settls missing Go declaration
4-
runtime/sys_netbsd_ARCHSUFF.s: [GOARCH] sigreturn_tramp: function sigreturn_tramp missing Go declaration
5-
63
runtime/sys_netbsd_386.s: [386] sigreturn_tramp: use of 140(SP) points beyond argument frame
74
runtime/sys_netbsd_386.s: [386] sigreturn_tramp: use of 4(SP) points beyond argument frame
85
runtime/sys_netbsd_386.s: [386] sigreturn_tramp: use of 4(SP) points beyond argument frame

src/cmd/vet/all/whitelist/netbsd_amd64.txt

-5
This file was deleted.

src/cmd/vet/all/whitelist/openbsd_386.txt

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
runtime/sys_openbsd_386.s: [386] sigtramp: unknown variable signo
44
runtime/sys_openbsd_386.s: [386] sigtramp: unknown variable info
55
runtime/sys_openbsd_386.s: [386] sigtramp: unknown variable context
6-
runtime/sys_openbsd_386.s: [386] settls: function settls missing Go declaration
76
syscall/asm_unix_386.s: [386] Syscall: 8(SP) should be a1+4(FP)
87
syscall/asm_unix_386.s: [386] Syscall: 4(SP) should be trap+0(FP)
98
syscall/asm_unix_386.s: [386] Syscall6: 8(SP) should be a1+4(FP)

src/cmd/vet/all/whitelist/openbsd_amd64.txt

-3
This file was deleted.

src/cmd/vet/all/whitelist/plan9_amd64.txt

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// solaris/amd64-specific vet whitelist. See readme.txt for details.
22

3-
runtime/sys_solaris_amd64.s: [amd64] settls: function settls missing Go declaration
43
runtime/sys_solaris_amd64.s: [amd64] pipe1: function pipe1 missing Go declaration
54
runtime/sys_solaris_amd64.s: [amd64] asmsysvicall6: function asmsysvicall6 missing Go declaration
65
runtime/sys_solaris_amd64.s: [amd64] usleep2: function usleep2 missing Go declaration

src/cmd/vet/all/whitelist/windows_amd64.txt

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
runtime/sys_windows_amd64.s: [amd64] ctrlhandler: RET without writing to 4-byte ret+8(FP)
44
runtime/sys_windows_amd64.s: [amd64] callbackasm1: function callbackasm1 missing Go declaration
55
runtime/sys_windows_amd64.s: [amd64] tstart_stdcall: RET without writing to 4-byte ret+8(FP)
6-
runtime/sys_windows_amd64.s: [amd64] settls: function settls missing Go declaration

src/runtime/asm_amd64.s

+4-3
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0
424424

425425
// Called from f.
426426
// Set m->morebuf to f's caller.
427+
NOP SP // tell vet SP changed - stop checking offsets
427428
MOVQ 8(SP), AX // f's caller's PC
428429
MOVQ AX, (m_morebuf+gobuf_pc)(BX)
429430
LEAQ 16(SP), AX // f's caller's SP
@@ -890,20 +891,20 @@ TEXT runtime·aeshash(SB),NOSPLIT,$0-32
890891
MOVQ p+0(FP), AX // ptr to data
891892
MOVQ s+16(FP), CX // size
892893
LEAQ ret+24(FP), DX
893-
JMP runtime·aeshashbody(SB)
894+
JMP aeshashbody<>(SB)
894895

895896
// func aeshashstr(p unsafe.Pointer, h uintptr) uintptr
896897
TEXT runtime·aeshashstr(SB),NOSPLIT,$0-24
897898
MOVQ p+0(FP), AX // ptr to string struct
898899
MOVQ 8(AX), CX // length of string
899900
MOVQ (AX), AX // string data
900901
LEAQ ret+16(FP), DX
901-
JMP runtime·aeshashbody(SB)
902+
JMP aeshashbody<>(SB)
902903

903904
// AX: data
904905
// CX: length
905906
// DX: address to put return value
906-
TEXT runtime·aeshashbody(SB),NOSPLIT,$0-0
907+
TEXT aeshashbody<>(SB),NOSPLIT,$0-0
907908
// Fill an SSE register with our seeds.
908909
MOVQ h+8(FP), X0 // 64 bits of per-table hash seed
909910
PINSRW $4, CX, X0 // 16 bits of length

src/runtime/stubs_386.go

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import "unsafe"
99
func float64touint32(a float64) uint32
1010
func uint32tofloat64(a uint32) float64
1111

12+
// stackcheck checks that SP is in range [g->stack.lo, g->stack.hi).
13+
func stackcheck()
14+
1215
// Called from assembly only; declared for go vet.
1316
func setldt(slot uintptr, base unsafe.Pointer, size uintptr)
1417
func emptyfunc()

src/runtime/stubs_x86.go renamed to src/runtime/stubs_amd64x.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build amd64 amd64p32 386
5+
// +build amd64 amd64p32
66

77
package runtime
88

99
// stackcheck checks that SP is in range [g->stack.lo, g->stack.hi).
1010
func stackcheck()
11+
12+
// Called from assembly only; declared for go vet.
13+
func settls() // argument in DI

src/runtime/sys_netbsd_386.s

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ TEXT runtime·lwp_tramp(SB),NOSPLIT,$0
324324
LEAL m_tls(BX), BP
325325
PUSHAL // save registers
326326
PUSHL BP
327-
CALL runtime·settls(SB)
327+
CALL lwp_setprivate<>(SB)
328328
POPL AX
329329
POPAL
330330

@@ -363,10 +363,10 @@ TEXT runtime·setldt(SB),NOSPLIT,$8
363363
// Under NetBSD we set the GS base instead of messing with the LDT.
364364
MOVL base+4(FP), AX
365365
MOVL AX, 0(SP)
366-
CALL runtime·settls(SB)
366+
CALL lwp_setprivate<>(SB)
367367
RET
368368

369-
TEXT runtime·settls(SB),NOSPLIT,$16
369+
TEXT lwp_setprivate<>(SB),NOSPLIT,$16
370370
// adjust for ELF: wants to use -4(GS) for g
371371
MOVL base+0(FP), CX
372372
ADDL $4, CX

src/runtime/sys_openbsd_386.s

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ TEXT runtime·tfork(SB),NOSPLIT,$12
292292
LEAL m_tls(BX), BP
293293
PUSHAL // save registers
294294
PUSHL BP
295-
CALL runtime·settls(SB)
295+
CALL set_tcb<>(SB)
296296
POPL AX
297297
POPAL
298298

@@ -331,10 +331,10 @@ TEXT runtime·setldt(SB),NOSPLIT,$4
331331
// Under OpenBSD we set the GS base instead of messing with the LDT.
332332
MOVL base+4(FP), AX
333333
MOVL AX, 0(SP)
334-
CALL runtime·settls(SB)
334+
CALL set_tcb<>(SB)
335335
RET
336336

337-
TEXT runtime·settls(SB),NOSPLIT,$8
337+
TEXT set_tcb<>(SB),NOSPLIT,$8
338338
// adjust for ELF: wants to use -4(GS) for g
339339
MOVL tlsbase+0(FP), CX
340340
ADDL $4, CX

0 commit comments

Comments
 (0)