Commit 13723d44 authored by Russ Cox's avatar Russ Cox

runtime, crypto/x509: fix vet complaints for all windows

Working toward making the tree vet-safe instead of having
so many exceptions in cmd/vet/all/whitelist.

This CL makes "go vet -unsafeptr=false runtime" happy for windows/*,
while keeping "GO_BUILDER_NAME=misc-vetall go tool dist test" happy too.

For #31916.

Change-Id: If37ab2b3f6fca4696b8a6afb2ef11ba6c4fb42e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/176106Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 924c161d
// windows-specific vet whitelist. See readme.txt for details.
// Issue 18609
crypto/x509/root_windows.go: unreachable code
runtime/sys_windows_ARCHSUFF.s: [GOARCH] onosstack: unknown variable usec; offset 0 is fn+0(FP)
// windows/386-specific vet whitelist. See readme.txt for details.
runtime/sys_windows_386.s: [386] profileloop: use of 4(SP) points beyond argument frame
runtime/sys_windows_386.s: [386] ctrlhandler: 4(SP) should be _type+0(FP)
runtime/sys_windows_386.s: [386] callbackasm1+0: function callbackasm1+0 missing Go declaration
runtime/sys_windows_386.s: [386] tstart: function tstart missing Go declaration
runtime/sys_windows_386.s: [386] tstart_stdcall: RET without writing to 4-byte ret+4(FP)
runtime/sys_windows_386.s: [386] sigtramp: function sigtramp missing Go declaration
// windows/amd64-specific vet whitelist. See readme.txt for details.
runtime/sys_windows_amd64.s: [amd64] ctrlhandler: RET without writing to 4-byte ret+8(FP)
runtime/sys_windows_amd64.s: [amd64] callbackasm1: function callbackasm1 missing Go declaration
runtime/sys_windows_amd64.s: [amd64] tstart_stdcall: RET without writing to 4-byte ret+8(FP)
...@@ -229,7 +229,11 @@ func loadSystemRoots() (*CertPool, error) { ...@@ -229,7 +229,11 @@ func loadSystemRoots() (*CertPool, error) {
// TODO: restore this functionality on Windows. We tried to do // TODO: restore this functionality on Windows. We tried to do
// it in Go 1.8 but had to revert it. See Issue 18609. // it in Go 1.8 but had to revert it. See Issue 18609.
// Returning (nil, nil) was the old behavior, prior to CL 30578. // Returning (nil, nil) was the old behavior, prior to CL 30578.
return nil, nil // The if statement here avoids vet complaining about
// unreachable code below.
if true {
return nil, nil
}
const CRYPT_E_NOT_FOUND = 0x80092004 const CRYPT_E_NOT_FOUND = 0x80092004
......
...@@ -133,9 +133,9 @@ var ( ...@@ -133,9 +133,9 @@ var (
// Function to be called by windows CreateThread // Function to be called by windows CreateThread
// to start new os thread. // to start new os thread.
func tstart_stdcall(newm *m) uint32 func tstart_stdcall(newm *m)
func ctrlhandler(_type uint32) uint32 func ctrlhandler(_type uint32)
type mOS struct { type mOS struct {
waitsema uintptr // semaphore for parking on locks waitsema uintptr // semaphore for parking on locks
...@@ -907,6 +907,9 @@ func ctrlhandler1(_type uint32) uint32 { ...@@ -907,6 +907,9 @@ func ctrlhandler1(_type uint32) uint32 {
// in sys_windows_386.s and sys_windows_amd64.s // in sys_windows_386.s and sys_windows_amd64.s
func profileloop() func profileloop()
// called from zcallback_windows_*.s to sys_windows_*.s
func callbackasm1()
var profiletimer uintptr var profiletimer uintptr
func profilem(mp *m, thread uintptr) { func profilem(mp *m, thread uintptr) {
......
...@@ -76,7 +76,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 ...@@ -76,7 +76,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0
// exception record and context pointers. // exception record and context pointers.
// Handler function is stored in AX. // Handler function is stored in AX.
// Return 0 for 'not handled', -1 for handled. // Return 0 for 'not handled', -1 for handled.
TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 TEXT sigtramp<>(SB),NOSPLIT,$0-0
MOVL ptrs+0(FP), CX MOVL ptrs+0(FP), CX
SUBL $40, SP SUBL $40, SP
...@@ -155,7 +155,7 @@ done: ...@@ -155,7 +155,7 @@ done:
TEXT runtime·exceptiontramp(SB),NOSPLIT,$0 TEXT runtime·exceptiontramp(SB),NOSPLIT,$0
MOVL $runtime·exceptionhandler(SB), AX MOVL $runtime·exceptionhandler(SB), AX
JMP runtime·sigtramp(SB) JMP sigtramp<>(SB)
TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0 TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0
// is never called // is never called
...@@ -163,17 +163,21 @@ TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0 ...@@ -163,17 +163,21 @@ TEXT runtime·firstcontinuetramp(SB),NOSPLIT,$0-0
TEXT runtime·lastcontinuetramp(SB),NOSPLIT,$0-0 TEXT runtime·lastcontinuetramp(SB),NOSPLIT,$0-0
MOVL $runtime·lastcontinuehandler(SB), AX MOVL $runtime·lastcontinuehandler(SB), AX
JMP runtime·sigtramp(SB) JMP sigtramp<>(SB)
// Called by OS using stdcall ABI: bool ctrlhandler(uint32).
TEXT runtime·ctrlhandler(SB),NOSPLIT,$0 TEXT runtime·ctrlhandler(SB),NOSPLIT,$0
PUSHL $runtime·ctrlhandler1(SB) PUSHL $runtime·ctrlhandler1(SB)
NOP SP // tell vet SP changed - stop checking offsets
CALL runtime·externalthreadhandler(SB) CALL runtime·externalthreadhandler(SB)
MOVL 4(SP), CX MOVL 4(SP), CX
ADDL $12, SP ADDL $12, SP
JMP CX JMP CX
// Called by OS using stdcall ABI: uint32 profileloop(void*).
TEXT runtime·profileloop(SB),NOSPLIT,$0 TEXT runtime·profileloop(SB),NOSPLIT,$0
PUSHL $runtime·profileloop1(SB) PUSHL $runtime·profileloop1(SB)
NOP SP // tell vet SP changed - stop checking offsets
CALL runtime·externalthreadhandler(SB) CALL runtime·externalthreadhandler(SB)
MOVL 4(SP), CX MOVL 4(SP), CX
ADDL $12, SP ADDL $12, SP
...@@ -232,7 +236,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0 ...@@ -232,7 +236,7 @@ TEXT runtime·externalthreadhandler(SB),NOSPLIT,$0
GLOBL runtime·cbctxts(SB), NOPTR, $4 GLOBL runtime·cbctxts(SB), NOPTR, $4
TEXT runtime·callbackasm1+0(SB),NOSPLIT,$0 TEXT runtime·callbackasm1(SB),NOSPLIT,$0
MOVL 0(SP), AX // will use to find our callback context MOVL 0(SP), AX // will use to find our callback context
// remove return address from stack, we are not returning there // remove return address from stack, we are not returning there
...@@ -308,7 +312,7 @@ TEXT runtime·callbackasm1+0(SB),NOSPLIT,$0 ...@@ -308,7 +312,7 @@ TEXT runtime·callbackasm1+0(SB),NOSPLIT,$0
RET RET
// void tstart(M *newm); // void tstart(M *newm);
TEXT runtime·tstart(SB),NOSPLIT,$0 TEXT tstart<>(SB),NOSPLIT,$0
MOVL newm+0(FP), CX // m MOVL newm+0(FP), CX // m
MOVL m_g0(CX), DX // g MOVL m_g0(CX), DX // g
...@@ -340,7 +344,7 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT,$0 ...@@ -340,7 +344,7 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT,$0
MOVL newm+0(FP), BX MOVL newm+0(FP), BX
PUSHL BX PUSHL BX
CALL runtime·tstart(SB) CALL tstart<>(SB)
POPL BX POPL BX
// Adjust stack for stdcall to return properly. // Adjust stack for stdcall to return properly.
...@@ -383,7 +387,7 @@ TEXT runtime·onosstack(SB),NOSPLIT,$0 ...@@ -383,7 +387,7 @@ TEXT runtime·onosstack(SB),NOSPLIT,$0
MOVL SI, m_libcallg(BP) MOVL SI, m_libcallg(BP)
// sp must be the last, because once async cpu profiler finds // sp must be the last, because once async cpu profiler finds
// all three values to be non-zero, it will use them // all three values to be non-zero, it will use them
LEAL usec+0(FP), SI LEAL fn+0(FP), SI
MOVL SI, m_libcallsp(BP) MOVL SI, m_libcallsp(BP)
MOVL m_g0(BP), SI MOVL m_g0(BP), SI
......
...@@ -110,7 +110,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0 ...@@ -110,7 +110,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT,$0
// exception record and context pointers. // exception record and context pointers.
// Handler function is stored in AX. // Handler function is stored in AX.
// Return 0 for 'not handled', -1 for handled. // Return 0 for 'not handled', -1 for handled.
TEXT runtime·sigtramp(SB),NOSPLIT|NOFRAME,$0-0 TEXT sigtramp<>(SB),NOSPLIT|NOFRAME,$0-0
// CX: PEXCEPTION_POINTERS ExceptionInfo // CX: PEXCEPTION_POINTERS ExceptionInfo
// DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved // DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved
...@@ -200,18 +200,18 @@ done: ...@@ -200,18 +200,18 @@ done:
TEXT runtime·exceptiontramp(SB),NOSPLIT|NOFRAME,$0 TEXT runtime·exceptiontramp(SB),NOSPLIT|NOFRAME,$0
MOVQ $runtime·exceptionhandler(SB), AX MOVQ $runtime·exceptionhandler(SB), AX
JMP runtime·sigtramp(SB) JMP sigtramp<>(SB)
TEXT runtime·firstcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·firstcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0
MOVQ $runtime·firstcontinuehandler(SB), AX MOVQ $runtime·firstcontinuehandler(SB), AX
JMP runtime·sigtramp(SB) JMP sigtramp<>(SB)
TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0-0
MOVQ $runtime·lastcontinuehandler(SB), AX MOVQ $runtime·lastcontinuehandler(SB), AX
JMP runtime·sigtramp(SB) JMP sigtramp<>(SB)
TEXT runtime·ctrlhandler(SB),NOSPLIT|NOFRAME,$8 TEXT runtime·ctrlhandler(SB),NOSPLIT|NOFRAME,$8
MOVQ CX, 16(SP) // spill MOVQ CX, _type+16(SP) // spill
MOVQ $runtime·ctrlhandler1(SB), CX MOVQ $runtime·ctrlhandler1(SB), CX
MOVQ CX, 0(SP) MOVQ CX, 0(SP)
CALL runtime·externalthreadhandler(SB) CALL runtime·externalthreadhandler(SB)
...@@ -413,7 +413,7 @@ TEXT runtime·onosstack(SB),NOSPLIT,$0 ...@@ -413,7 +413,7 @@ TEXT runtime·onosstack(SB),NOSPLIT,$0
MOVQ R12, m_libcallg(R13) MOVQ R12, m_libcallg(R13)
// sp must be the last, because once async cpu profiler finds // sp must be the last, because once async cpu profiler finds
// all three values to be non-zero, it will use them // all three values to be non-zero, it will use them
LEAQ usec+0(FP), R12 LEAQ fn+0(FP), R12
MOVQ R12, m_libcallsp(R13) MOVQ R12, m_libcallsp(R13)
MOVQ m_g0(R13), R14 MOVQ m_g0(R13), R14
......
...@@ -116,7 +116,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT|NOFRAME,$0 ...@@ -116,7 +116,7 @@ TEXT runtime·setlasterror(SB),NOSPLIT|NOFRAME,$0
// int32_t sigtramp( // int32_t sigtramp(
// PEXCEPTION_POINTERS ExceptionInfo, // PEXCEPTION_POINTERS ExceptionInfo,
// func *GoExceptionHandler); // func *GoExceptionHandler);
TEXT runtime·sigtramp(SB),NOSPLIT|NOFRAME,$0 TEXT sigtramp<>(SB),NOSPLIT|NOFRAME,$0
MOVM.DB.W [R0, R4-R11, R14], (R13) // push {r0, r4-r11, lr} (SP-=40) MOVM.DB.W [R0, R4-R11, R14], (R13) // push {r0, r4-r11, lr} (SP-=40)
SUB $(8+20), R13 // reserve space for g, sp, and SUB $(8+20), R13 // reserve space for g, sp, and
// parameters/retval to go call // parameters/retval to go call
...@@ -198,7 +198,7 @@ done: ...@@ -198,7 +198,7 @@ done:
// handler, don't clobber the stored SP and PC on the stack. // handler, don't clobber the stored SP and PC on the stack.
MOVW 4(R3), R3 // PEXCEPTION_POINTERS->Context MOVW 4(R3), R3 // PEXCEPTION_POINTERS->Context
MOVW 0x40(R3), R2 // load PC from context record MOVW 0x40(R3), R2 // load PC from context record
MOVW $runtime·returntramp(SB), R1 MOVW $returntramp<>(SB), R1
CMP R1, R2 CMP R1, R2
B.EQ return // do not clobber saved SP/PC B.EQ return // do not clobber saved SP/PC
...@@ -211,7 +211,7 @@ done: ...@@ -211,7 +211,7 @@ done:
// Set up context record to return to returntramp on g0 stack // Set up context record to return to returntramp on g0 stack
MOVW R12, 0x38(R3) // save g0 stack pointer MOVW R12, 0x38(R3) // save g0 stack pointer
// in context record // in context record
MOVW $runtime·returntramp(SB), R2 // save resume address MOVW $returntramp<>(SB), R2 // save resume address
MOVW R2, 0x40(R3) // in context record MOVW R2, 0x40(R3) // in context record
return: return:
...@@ -222,20 +222,20 @@ return: ...@@ -222,20 +222,20 @@ return:
// This is part of the control flow guard workaround. // This is part of the control flow guard workaround.
// It switches stacks and jumps to the continuation address. // It switches stacks and jumps to the continuation address.
// //
TEXT runtime·returntramp(SB),NOSPLIT|NOFRAME,$0 TEXT returntramp<>(SB),NOSPLIT|NOFRAME,$0
MOVM.IA (R13), [R13, R15] // ldm sp, [sp, pc] MOVM.IA (R13), [R13, R15] // ldm sp, [sp, pc]
TEXT runtime·exceptiontramp(SB),NOSPLIT|NOFRAME,$0 TEXT runtime·exceptiontramp(SB),NOSPLIT|NOFRAME,$0
MOVW $runtime·exceptionhandler(SB), R1 MOVW $runtime·exceptionhandler(SB), R1
B runtime·sigtramp(SB) B sigtramp<>(SB)
TEXT runtime·firstcontinuetramp(SB),NOSPLIT|NOFRAME,$0 TEXT runtime·firstcontinuetramp(SB),NOSPLIT|NOFRAME,$0
MOVW $runtime·firstcontinuehandler(SB), R1 MOVW $runtime·firstcontinuehandler(SB), R1
B runtime·sigtramp(SB) B sigtramp<>(SB)
TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0 TEXT runtime·lastcontinuetramp(SB),NOSPLIT|NOFRAME,$0
MOVW $runtime·lastcontinuehandler(SB), R1 MOVW $runtime·lastcontinuehandler(SB), R1
B runtime·sigtramp(SB) B sigtramp<>(SB)
TEXT runtime·ctrlhandler(SB),NOSPLIT|NOFRAME,$0 TEXT runtime·ctrlhandler(SB),NOSPLIT|NOFRAME,$0
MOVW $runtime·ctrlhandler1(SB), R1 MOVW $runtime·ctrlhandler1(SB), R1
...@@ -363,7 +363,7 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT|NOFRAME,$0 ...@@ -363,7 +363,7 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT|NOFRAME,$0
BL runtime·save_g(SB) BL runtime·save_g(SB)
// do per-thread TLS initialization // do per-thread TLS initialization
BL runtime·init_thread_tls(SB) BL init_thread_tls<>(SB)
// Layout new m scheduler stack on os stack. // Layout new m scheduler stack on os stack.
MOVW R13, R0 MOVW R13, R0
...@@ -475,7 +475,7 @@ TEXT runtime·switchtothread(SB),NOSPLIT|NOFRAME,$0 ...@@ -475,7 +475,7 @@ TEXT runtime·switchtothread(SB),NOSPLIT|NOFRAME,$0
BIC $0x7, R13 // alignment for ABI BIC $0x7, R13 // alignment for ABI
MOVW runtime·_SwitchToThread(SB), R0 MOVW runtime·_SwitchToThread(SB), R0
BL (R0) BL (R0)
MOVW R4, R13 // restore stack pointer MOVW R4, R13 // restore stack pointer
MOVM.IA.W (R13), [R4, R15] // pop {R4, pc} MOVM.IA.W (R13), [R4, R15] // pop {R4, pc}
TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0 TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
...@@ -654,7 +654,7 @@ TEXT runtime·_initcgo(SB),NOSPLIT|NOFRAME,$0 ...@@ -654,7 +654,7 @@ TEXT runtime·_initcgo(SB),NOSPLIT|NOFRAME,$0
MOVW $runtime·tls_g(SB), R1 MOVW $runtime·tls_g(SB), R1
MOVW R0, (R1) MOVW R0, (R1)
BL runtime·init_thread_tls(SB) BL init_thread_tls<>(SB)
MOVW R4, R13 MOVW R4, R13
MOVM.IA.W (R13), [R4, R15] // pop {r4, pc} MOVM.IA.W (R13), [R4, R15] // pop {r4, pc}
...@@ -674,7 +674,7 @@ TEXT runtime·_initcgo(SB),NOSPLIT|NOFRAME,$0 ...@@ -674,7 +674,7 @@ TEXT runtime·_initcgo(SB),NOSPLIT|NOFRAME,$0
// handler can get the real g from the thread's m. // handler can get the real g from the thread's m.
// //
// Clobbers R0-R3 // Clobbers R0-R3
TEXT runtime·init_thread_tls(SB),NOSPLIT|NOFRAME,$0 TEXT init_thread_tls<>(SB),NOSPLIT|NOFRAME,$0
// compute &_TEB->TlsSlots[tls_g] // compute &_TEB->TlsSlots[tls_g]
MRC 15, 0, R0, C13, C0, 2 MRC 15, 0, R0, C13, C0, 2
ADD $0xe10, R0 ADD $0xe10, R0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment