aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/opGen.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-01-06 10:31:39 -0500
committerRuss Cox <rsc@golang.org>2020-03-13 19:05:46 +0000
commit877ef86bec593cd7e40899ac5446791e65b47839 (patch)
tree1889b71db027e147f6b2aef734c928ff572a4d95 /src/cmd/compile/internal/ssa/opGen.go
parentd84cbec8908a04aa56889919942a3210963abaef (diff)
downloadgo-877ef86bec593cd7e40899ac5446791e65b47839.tar.gz
go-877ef86bec593cd7e40899ac5446791e65b47839.zip
cmd/compile: add spectre mitigation mode enabled by -spectre
This commit adds a new cmd/compile flag -spectre, which accepts a comma-separated list of possible Spectre mitigations to apply, or the empty string (none), or "all". The only known mitigation right now is "index", which uses conditional moves to ensure that x86-64 CPUs do not speculate past index bounds checks. Speculating past index bounds checks may be problematic on systems running privileged servers that accept requests from untrusted users who can execute their own programs on the same machine. (And some more constraints that make it even more unlikely in practice.) The cases this protects against are analogous to the ones Microsoft explains in the "Array out of bounds load/store feeding ..." sections here: https://docs.microsoft.com/en-us/cpp/security/developer-guidance-speculative-execution?view=vs-2019#array-out-of-bounds-load-feeding-an-indirect-branch Change-Id: Ib7532d7e12466b17e04c4e2075c2a456dc98f610 Reviewed-on: https://go-review.googlesource.com/c/go/+/222660 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/opGen.go')
-rw-r--r--src/cmd/compile/internal/ssa/opGen.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go
index 9da7376a8a..2573ba1f2f 100644
--- a/src/cmd/compile/internal/ssa/opGen.go
+++ b/src/cmd/compile/internal/ssa/opGen.go
@@ -2654,6 +2654,8 @@ const (
OpSignmask
OpZeromask
OpSlicemask
+ OpSpectreIndex
+ OpSpectreSliceIndex
OpCvt32Uto32F
OpCvt32Uto64F
OpCvt32Fto32U
@@ -33042,6 +33044,16 @@ var opcodeTable = [...]opInfo{
generic: true,
},
{
+ name: "SpectreIndex",
+ argLen: 2,
+ generic: true,
+ },
+ {
+ name: "SpectreSliceIndex",
+ argLen: 2,
+ generic: true,
+ },
+ {
name: "Cvt32Uto32F",
argLen: 1,
generic: true,