aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2015-10-17 17:46:25 -0400
committerBrad Fitzpatrick <bradfitz@golang.org>2015-12-05 17:43:51 +0000
commit35e84546d7c3cc599dd5bf31ad86bf8d3d841d04 (patch)
tree02bacd0a592dd84c8a695abab3c9e880023715f0 /src/runtime
parent4a2915052bcfd1c24d0277be2e4f53f309e7be89 (diff)
downloadgo-35e84546d7c3cc599dd5bf31ad86bf8d3d841d04.tar.xz
runtime: check and fail early with a message if MMX is not available on 386
Fixes #12970. Change-Id: Id0026e8274e071d65d47df63d65a93110abbec5d Reviewed-on: https://go-review.googlesource.com/15998 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/asm_386.s42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s
index 3dcb026f0c..c5f0c51566 100644
--- a/src/runtime/asm_386.s
+++ b/src/runtime/asm_386.s
@@ -26,6 +26,32 @@ TEXT runtime·rt0_go(SB),NOSPLIT,$0
MOVL SP, (g_stack+stack_hi)(BP)
// find out information about the processor we're on
+#ifdef GOOS_nacl // NaCl doesn't like PUSHFL/POPFL
+ JMP has_cpuid
+#else
+ // first see if CPUID instruction is supported.
+ PUSHFL
+ PUSHFL
+ XORL $(1<<21), 0(SP) // flip ID bit
+ POPFL
+ PUSHFL
+ POPL AX
+ XORL 0(SP), AX
+ POPFL // restore EFLAGS
+ TESTL $(1<<21), AX
+ JNE has_cpuid
+#endif
+
+bad_proc: // show that the program requires MMX.
+ MOVL $2, 0(SP)
+ MOVL $bad_proc_msg<>(SB), 4(SP)
+ MOVL $0x3d, 8(SP)
+ CALL runtime·write(SB)
+ MOVL $1, 0(SP)
+ CALL runtime·exit(SB)
+ INT $3
+
+has_cpuid:
MOVL $0, AX
CPUID
CMPL AX, $0
@@ -48,6 +74,11 @@ notintel:
MOVL CX, AX // Move to global variable clobbers CX when generating PIC
MOVL AX, runtime·cpuid_ecx(SB)
MOVL DX, runtime·cpuid_edx(SB)
+
+ // Check for MMX support
+ TESTL $(1<<23), DX // MMX
+ JZ bad_proc
+
nocpuinfo:
// if there is an _cgo_init, call it to let it
@@ -129,6 +160,17 @@ ok:
INT $3
RET
+DATA bad_proc_msg<>+0x00(SB)/8, $"This pro"
+DATA bad_proc_msg<>+0x08(SB)/8, $"gram can"
+DATA bad_proc_msg<>+0x10(SB)/8, $" only be"
+DATA bad_proc_msg<>+0x18(SB)/8, $" run on "
+DATA bad_proc_msg<>+0x20(SB)/8, $"processe"
+DATA bad_proc_msg<>+0x28(SB)/8, $"rs with "
+DATA bad_proc_msg<>+0x30(SB)/8, $"MMX supp"
+DATA bad_proc_msg<>+0x38(SB)/4, $"ort."
+DATA bad_proc_msg<>+0x3c(SB)/1, $0xa
+GLOBL bad_proc_msg<>(SB), RODATA, $0x3d
+
DATA runtime·mainPC+0(SB)/4,$runtime·main(SB)
GLOBL runtime·mainPC(SB),RODATA,$4