[go] cmd/compile: truncate uint64 indices for imm8 jump tables

0 views
Skip to first unread message

David Chase (Gerrit)

unread,
Jul 23, 2026, 11:01:39 AM (4 days ago) Jul 23
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Carlos Amedee, t hepudds, golang...@luci-project-accounts.iam.gserviceaccount.com, Junyang Shao, Gopher Robot, golang-co...@googlegroups.com

David Chase submitted the change

Unreviewed changes

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
cmd/compile: truncate uint64 indices for imm8 jump tables

Variable uint64 arguments lowered through immJumpTable were converted
directly to uintptr. Since the generated table has 256 entries, values
above 255 could dispatch outside the table and corrupt control flow. With
-spectre=ret, the binary-search fallback instead selected case 255,
differing from constant lowering.

Convert uint64 indices to uint8 before either dispatch path, matching
imm8 constant encoding. Extend the ShiftAllRightConcatMod32 tests through
the first out-of-range value.

Tests:

- GOEXPERIMENT=simd ./bin/go test simd/...
- GOEXPERIMENT=simd ./bin/go test -short cmd/compile/...
- GOEXPERIMENT=simd ./bin/go vet cmd/compile/internal/ssagen simd/...
- linux/amd64 PoC, ordinary and -spectre=ret dispatch

Fixes #80522.
Change-Id: I4a663f91c561e8212509b155e10acfc7245a59a1
GitHub-Last-Rev: 18cbbde1817affdce75d96be0a10ec908e0a785a
GitHub-Pull-Request: golang/go#80526
Reviewed-by: Carlos Amedee <car...@golang.org>
Reviewed-by: David Chase <drc...@google.com>
Files:
  • M src/cmd/compile/internal/ssagen/intrinsics.go
  • M src/simd/archsimd/internal/simd_test/shift_amd64_test.go
Change size: S
Delta: 2 files changed, 15 insertions(+), 4 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4a663f91c561e8212509b155e10acfc7245a59a1
Gerrit-Change-Number: 803273
Gerrit-PatchSet: 3
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: t hepudds <thepud...@gmail.com>
open
diffy
satisfied_requirement

Gopher Robot (Gerrit)

unread,
Jul 24, 2026, 1:29:28 PM (2 days ago) Jul 24
to David Chase, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Keith Randall, Keith Randall, golang...@luci-project-accounts.iam.gserviceaccount.com, Robert Griesemer, Matthew Dempsky, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
[release-branch.go1.27] cmd/compile: truncate uint64 indices for imm8 jump tables


Variable uint64 arguments lowered through immJumpTable were converted
directly to uintptr. Since the generated table has 256 entries, values
above 255 could dispatch outside the table and corrupt control flow. With
-spectre=ret, the binary-search fallback instead selected case 255,
differing from constant lowering.

Convert uint64 indices to uint8 before either dispatch path, matching
imm8 constant encoding. Extend the ShiftAllRightConcatMod32 tests through
the first out-of-range value.

Tests:

- GOEXPERIMENT=simd ./bin/go test simd/...
- GOEXPERIMENT=simd ./bin/go test -short cmd/compile/...
- GOEXPERIMENT=simd ./bin/go vet cmd/compile/internal/ssagen simd/...
- linux/amd64 PoC, ordinary and -spectre=ret dispatch

Updates #80522.


Change-Id: I4a663f91c561e8212509b155e10acfc7245a59a1
GitHub-Last-Rev: 18cbbde1817affdce75d96be0a10ec908e0a785a
GitHub-Pull-Request: golang/go#80526
Reviewed-on: https://go-review.googlesource.com/c/go/+/803273
Reviewed-by: Carlos Amedee <car...@golang.org>
Reviewed-by: David Chase <drc...@google.com>
LUCI-TryBot-Result: golang...@luci-project-accounts.iam.gserviceaccount.com <golang...@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit b590fd1075ed62322d7866cf2c7e4498a8b5061c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/804581
Reviewed-by: Keith Randall <k...@google.com>
Reviewed-by: Keith Randall <k...@golang.org>
Auto-Submit: David Chase <drc...@google.com>
Files:
  • M src/cmd/compile/internal/ssagen/intrinsics.go
  • M src/simd/archsimd/internal/simd_test/shift_amd64_test.go
Change size: S
Delta: 2 files changed, 15 insertions(+), 4 deletions(-)
Branch: refs/heads/release-branch.go1.27
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Keith Randall, +1 by Keith Randall
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: release-branch.go1.27
Gerrit-Change-Id: I4a663f91c561e8212509b155e10acfc7245a59a1
Gerrit-Change-Number: 804581
Gerrit-PatchSet: 2
Gerrit-Owner: David Chase <drc...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Matthew Dempsky <mat...@go.dev>
Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages