]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.25] runtime: use one more address bit for tagged pointers
authorKeith Randall <khr@golang.org>
Tue, 2 Sep 2025 22:46:11 +0000 (15:46 -0700)
committerMichael Knyszek <mknyszek@google.com>
Mon, 27 Oct 2025 16:44:44 +0000 (09:44 -0700)
We use one extra bit to placate systems which simulate amd64 binaries on
an arm64 host. Allocated arm64 addresses could be as high as 1<<48-1,
which would be invalid if we assumed 48-bit sign-extended addresses.

(Note that this does not help the other way around, simluating arm64
on amd64, but we don't have that problem at the moment.)

For #69255.
Fixes #75775.

Change-Id: Iace17a5d41a65e34abf201d03d8b0ff6f7bf1150
Reviewed-on: https://go-review.googlesource.com/c/go/+/700515
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
(cherry picked from commit 2a7f1d47b0650c92b47f0cd5bc3536d438e4bbbe)
Reviewed-on: https://go-review.googlesource.com/c/go/+/712800
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/runtime/tagptr_64bit.go

index 3d79332e2dcaff7d811ea3ba8242bf7d59a125c5..76733cc1d646306f5b0a210d9fd283058435bce9 100644 (file)
@@ -22,10 +22,17 @@ const (
        // On AMD64, virtual addresses are 48-bit (or 57-bit) sign-extended.
        // Other archs are 48-bit zero-extended.
        //
+       // We use one extra bit to placate systems which simulate amd64 binaries on
+       // an arm64 host. Allocated arm64 addresses could be as high as 1<<48-1,
+       // which would be invalid if we assumed 48-bit sign-extended addresses.
+       // See issue 69255.
+       // (Note that this does not help the other way around, simluating arm64
+       // on amd64, but we don't have that problem at the moment.)
+       //
        // On s390x, virtual addresses are 64-bit. There's not much we
        // can do about this, so we just hope that the kernel doesn't
        // get to really high addresses and panic if it does.
-       defaultAddrBits = 48
+       defaultAddrBits = 48 + 1
 
        // On AIX, 64-bit addresses are split into 36-bit segment number and 28-bit
        // offset in segment.  Segment numbers in the range 0x0A0000000-0x0AFFFFFFF(LSA)