mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 16:47:27 -04:00
cpu: pretend AVX-512 is disabled on Darwin
Darwin doesn't save/restore the AVX-512 mask registers when processing a signal. Go generates lots of signals, which cause the mask registers to randomly get clobbered. Better to pretend that AVX-512 isn't supported. Update golang/go#49233 Change-Id: I0dda77a6f205e10eefccd82e6f4f0f184dae42d9 Reviewed-on: https://go-review.googlesource.com/c/sys/+/361255 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Martin Möhrmann <martin@golang.org>
This commit is contained in:
+4
-3
@@ -90,9 +90,10 @@ func archInit() {
|
|||||||
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
|
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
// Check darwin commpage for AVX512 support. Necessary because:
|
// Darwin doesn't save/restore AVX-512 mask registers correctly across signal handlers.
|
||||||
// https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/osfmk/i386/fpu.c#L175-L201
|
// Since users can't rely on mask register contents, let's not advertise AVX-512 support.
|
||||||
osSupportsAVX512 = osSupportsAVX && darwinSupportsAVX512()
|
// See issue 49233.
|
||||||
|
osSupportsAVX512 = false
|
||||||
} else {
|
} else {
|
||||||
// Check if OPMASK and ZMM registers have OS support.
|
// Check if OPMASK and ZMM registers have OS support.
|
||||||
osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax)
|
osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax)
|
||||||
|
|||||||
@@ -26,27 +26,3 @@ TEXT ·xgetbv(SB),NOSPLIT,$0-8
|
|||||||
MOVL AX, eax+0(FP)
|
MOVL AX, eax+0(FP)
|
||||||
MOVL DX, edx+4(FP)
|
MOVL DX, edx+4(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func darwinSupportsAVX512() bool
|
|
||||||
TEXT ·darwinSupportsAVX512(SB), NOSPLIT, $0-1
|
|
||||||
MOVB $0, ret+0(FP) // default to false
|
|
||||||
#ifdef GOOS_darwin // return if not darwin
|
|
||||||
#ifdef GOARCH_amd64 // return if not amd64
|
|
||||||
// These values from:
|
|
||||||
// https://github.com/apple/darwin-xnu/blob/xnu-4570.1.46/osfmk/i386/cpu_capabilities.h
|
|
||||||
#define commpage64_base_address 0x00007fffffe00000
|
|
||||||
#define commpage64_cpu_capabilities64 (commpage64_base_address+0x010)
|
|
||||||
#define commpage64_version (commpage64_base_address+0x01E)
|
|
||||||
#define hasAVX512F 0x0000004000000000
|
|
||||||
MOVQ $commpage64_version, BX
|
|
||||||
CMPW (BX), $13 // cpu_capabilities64 undefined in versions < 13
|
|
||||||
JL no_avx512
|
|
||||||
MOVQ $commpage64_cpu_capabilities64, BX
|
|
||||||
MOVQ $hasAVX512F, CX
|
|
||||||
TESTQ (BX), CX
|
|
||||||
JZ no_avx512
|
|
||||||
MOVB $1, ret+0(FP)
|
|
||||||
no_avx512:
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
RET
|
|
||||||
|
|||||||
Reference in New Issue
Block a user