Dmitry Vyukov has uploaded this change for review.
runtime: support riscv64 SV57 mode
Riscv64 has SV57 mode when user-space VA is 56 bits.
Linux kernel recently got support for this mode and Go binaries started crashing as:
runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1
packed=0xffff5908a9400001 -> node=0xffff5908a940
Adjust lfstack code to use only 8 top bits of pointers on riscv64.
For context see:
https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ
Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25
---
M src/runtime/lfstack_64bit.go
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/runtime/lfstack_64bit.go b/src/runtime/lfstack_64bit.go
index 154130c..afe1d4c 100644
--- a/src/runtime/lfstack_64bit.go
+++ b/src/runtime/lfstack_64bit.go
@@ -36,12 +36,19 @@
// We use one bit to distinguish between the two ranges.
aixAddrBits = 57
aixCntBits = 64 - aixAddrBits + 3
+
+ // Riscv64 SV57 mode gives 56 bits of userspace VA.
+ riscv64AddrBits = 56
+ riscv64CntBits = 64 - riscv64AddrBits + 3
)
func lfstackPack(node *lfnode, cnt uintptr) uint64 {
if GOARCH == "ppc64" && GOOS == "aix" {
return uint64(uintptr(unsafe.Pointer(node)))<<(64-aixAddrBits) | uint64(cnt&(1<<aixCntBits-1))
}
+ if GOARCH == "riscv64" {
+ return uint64(uintptr(unsafe.Pointer(node)))<<(64-riscv64AddrBits) | uint64(cnt&(1<<riscv64CntBits-1))
+ }
return uint64(uintptr(unsafe.Pointer(node)))<<(64-addrBits) | uint64(cnt&(1<<cntBits-1))
}
@@ -54,5 +61,8 @@
if GOARCH == "ppc64" && GOOS == "aix" {
return (*lfnode)(unsafe.Pointer(uintptr((val >> aixCntBits << 3) | 0xa<<56)))
}
+ if GOARCH == "riscv64" {
+ return (*lfnode)(unsafe.Pointer(uintptr(val >> riscv64CntBits << 3)))
+ }
return (*lfnode)(unsafe.Pointer(uintptr(val >> cntBits << 3)))
}
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 1:Run-TryBot +1
1 comment:
Patchset:
TryBots are happy.
Does normal trybot run include riscv machines?
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patchset:
Btw x86 now has 5-level page tables with 56 bit addresses as well.
Maybe we should switch to 56 bits everywhere?
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitry Vyukov.
1 comment:
Patchset:
Does normal trybot run include riscv machines?
No, You have to use `TRY=linux-riscv64` in the commit message for trybots.
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitry Vyukov.
Patch set 1:Run-TryBot +1
1 comment:
Patchset:
TRY=linux-riscv64
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitry Vyukov, Zhuo Meng.
Dmitry Vyukov uploaded patch set #2 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Dmitry Vyukov, Run-TryBot+1 by Zhuo Meng, TryBot-Result+1 by Gopher Robot
runtime: support riscv64 SV57 mode
Riscv64 has SV57 mode when user-space VA is 56 bits.
Linux kernel recently got support for this mode and Go binaries started crashing as:
runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1
packed=0xffff5908a9400001 -> node=0xffff5908a940
Adjust lfstack code to use only 8 top bits of pointers on riscv64.
For context see:
https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ
TRY=linux-riscv64
Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25
---
M src/runtime/lfstack_64bit.go
1 file changed, 32 insertions(+), 0 deletions(-)
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Zhuo Meng.
Patch set 2:Run-TryBot +1
Attention is currently required from: Dmitry Vyukov.
1 comment:
Patchset:
Sorry, I mean "comment message" not "commit message".
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitry Vyukov.
Dmitry Vyukov uploaded patch set #3 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Dmitry Vyukov
runtime: support riscv64 SV57 mode
Riscv64 has SV57 mode when user-space VA is 56 bits.
Linux kernel recently got support for this mode and Go binaries started crashing as:
runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1
packed=0xffff5908a9400001 -> node=0xffff5908a940
Adjust lfstack code to use only 8 top bits of pointers on riscv64.
For context see:
https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ
Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25
---
M src/runtime/lfstack_64bit.go
1 file changed, 30 insertions(+), 0 deletions(-)
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Dmitry Vyukov, Ian Lance Taylor, Joel Sing.
Patch set 3:Run-TryBot +1
Patchset:
hi, Dimtry, could you open an issue on Github?
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Patchset:
Hi, Cherry, Ian
Since [Linux 5.18 has merged with SV57 support](https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.18-RISC-V), I think we should include this CL in 1.19
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Austin Clements, Dmitry Vyukov, Meng Zhuo, Michael Knyszek.
1 comment:
Patchset:
Hi, Cherry, Ian […]
Is there a way we can test this configuration? I'm not sure whether this is enough to support address space beyond 48 bits. There are other places in the runtime that makes assumptions about the address space.
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Austin Clements, Cherry Mui, Dmitry Vyukov, Meng Zhuo.
1 comment:
Patchset:
Is there a way we can test this configuration? I'm not sure whether this is enough to support addres […]
yeah there are quite a few other places.
the page allocator constants also need to be updated, as well as heapAddrBits, it's corresponding documentation, and making sure constants derived from it continue to make sense.
when that happens, there will also be an increase in address space use from mheap_.arenas and the page allocator's structures. should be fine for most people, but will likely generate more complaints from users of `ulimit -v` if we make it the default on Linux. we can use less address space for these structures by addinng indirections, but at the cost of performance (these structures are hot, so in the single-digit percent).
(and I would actually prefer this be the default; supporting both 48-bit and 57-bit mode would be another bifurcation in the configurations we need to test. it shouldn't be too hard to just update our builder images to use kernels in 57-bit mode? maybe lots of other things will break.)
I personally would welcome support for this, but I think this is going to be a bit of a journey.
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Christian Stewart, Dmitry Vyukov, Michael Knyszek.
1 comment:
Patchset:
yeah there are quite a few other places. […]
Go binaries are no longer working due to this issue on qemu-riscv (which I guess is in SV57 mode).
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor, Meng Zhuo, Michael Knyszek.
1 comment:
Patchset:
Go binaries are no longer working due to this issue on qemu-riscv (which I guess is in SV57 mode).
Hi all, after applying this patch to Buildroot, running Go binaries in qemu-riscv (SV57 mode) works fine. Without the patch, they crash.
Could this be merged for the next release?
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor, Michael Knyszek.
Patch set 3:Code-Review +1
Attention is currently required from: Cherry Mui, Dmitri Goutnik, Dmitry Vyukov, Michael Knyszek.
1 comment:
Patchset:
mknyszek, austin: it seems that this CL fixes an immediate problem (issue #54104). Should we go ahead and submit this, or is this problematic by itself? Thanks.
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor.
3 comments:
Commit Message:
please add a reference to the issue, such as a line like:
For #54104.
Patchset:
mknyszek, austin: it seems that this CL fixes an immediate problem (issue #54104). […]
it's just incomplete, and we could be OK with that. it can be a little jarring that the *only* thing that supports SV57 mode explicitly is lfstack.
at the very least, there should probably be an additional comment. I left a comment about that.
File src/runtime/lfstack_64bit.go:
Patch Set #3, Line 40: // Riscv64 SV57 mode gives 56 bits of userspace VA.
please add a comment that although lfstack supports it, broader support for SV57 mode is incomplete, and there may be other issues. please reference the issue (#54104) as well.
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor, Meng Zhuo.
Dmitry Vyukov uploaded patch set #4 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Meng Zhuo, TryBot-Result+1 by Gopher Robot
runtime: support riscv64 SV57 mode
Riscv64 has SV57 mode when user-space VA is 56 bits.
Linux kernel recently got support for this mode and Go binaries started crashing as:
runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1
packed=0xffff5908a9400001 -> node=0xffff5908a940
Adjust lfstack code to use only 8 top bits of pointers on riscv64.
For context see:
https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ
Update #54104
Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25
---
M src/runtime/lfstack_64bit.go
1 file changed, 34 insertions(+), 0 deletions(-)
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui, Dmitri Goutnik, Ian Lance Taylor, Meng Zhuo, Michael Knyszek.
3 comments:
Commit Message:
please add a reference to the issue, such as a line like: […]
Done
Patchset:
PTAL
File src/runtime/lfstack_64bit.go:
Patch Set #3, Line 40: // Riscv64 SV57 mode gives 56 bits of userspace VA.
please add a comment that although lfstack supports it, broader support for SV57 mode is incomplete, […]
Done
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor, Meng Zhuo, Michael Knyszek.
Patch set 4:Code-Review +1
Attention is currently required from: Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor, Michael Knyszek.
Patch set 4:Run-TryBot +1Code-Review +1
Attention is currently required from: Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor.
Patch set 4:Code-Review +2
Attention is currently required from: Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor.
Patch set 4:Code-Review +1
2 comments:
Commit Message:
Patch Set #4, Line 9: Riscv64
Nit: 'RISC-V' or 'riscv64'
File src/runtime/lfstack_64bit.go:
Patch Set #4, Line 40: Riscv64
Nit: 'RISC-V' or 'riscv64'
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitri Goutnik, Dmitry Vyukov, Ian Lance Taylor, Meng Zhuo.
Dmitry Vyukov uploaded patch set #5 to this change.
The following approvals got outdated and were removed: Run-TryBot+1 by Meng Zhuo, TryBot-Result+1 by Gopher Robot
runtime: support riscv64 SV57 mode
riscv64 has SV57 mode when user-space VA is 56 bits.
Linux kernel recently got support for this mode and Go binaries started crashing as:
runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1
packed=0xffff5908a9400001 -> node=0xffff5908a940
Adjust lfstack code to use only 8 top bits of pointers on riscv64.
For context see:
https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ
Update #54104
Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25
---
M src/runtime/lfstack_64bit.go
1 file changed, 34 insertions(+), 0 deletions(-)
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Dmitri Goutnik, Ian Lance Taylor, Joel Sing, Meng Zhuo.
2 comments:
Commit Message:
Patch Set #4, Line 9: Riscv64
Nit: 'RISC-V' or 'riscv64'
Done
File src/runtime/lfstack_64bit.go:
Patch Set #4, Line 40: Riscv64
Nit: 'RISC-V' or 'riscv64'
Done
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.
Dmitry Vyukov submitted this change.
4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: src/runtime/lfstack_64bit.go
Insertions: 1, Deletions: 1.
@@ -37,7 +37,7 @@
aixAddrBits = 57
aixCntBits = 64 - aixAddrBits + 3
- // Riscv64 SV57 mode gives 56 bits of userspace VA.
+ // riscv64 SV57 mode gives 56 bits of userspace VA.
// lfstack code supports it, but broader support for SV57 mode is incomplete,
// and there may be other issues (see #54104).
riscv64AddrBits = 56
```
runtime: support riscv64 SV57 mode
riscv64 has SV57 mode when user-space VA is 56 bits.
Linux kernel recently got support for this mode and Go binaries started crashing as:
runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1
packed=0xffff5908a9400001 -> node=0xffff5908a940
Adjust lfstack code to use only 8 top bits of pointers on riscv64.
For context see:
https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ
Update #54104
Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/409055
Reviewed-by: Joel Sing <jo...@sing.id.au>
Reviewed-by: Meng Zhuo <m...@golangcn.org>
Reviewed-by: Michael Knyszek <mkny...@google.com>
Reviewed-by: Cherry Mui <cher...@google.com>
---
M src/runtime/lfstack_64bit.go
1 file changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/runtime/lfstack_64bit.go b/src/runtime/lfstack_64bit.go
index 154130c..88cbd3b 100644
--- a/src/runtime/lfstack_64bit.go
+++ b/src/runtime/lfstack_64bit.go
@@ -36,12 +36,21 @@
// We use one bit to distinguish between the two ranges.
aixAddrBits = 57
aixCntBits = 64 - aixAddrBits + 3
+
+ // riscv64 SV57 mode gives 56 bits of userspace VA.
+ // lfstack code supports it, but broader support for SV57 mode is incomplete,
+ // and there may be other issues (see #54104).
+ riscv64AddrBits = 56
+ riscv64CntBits = 64 - riscv64AddrBits + 3
)
func lfstackPack(node *lfnode, cnt uintptr) uint64 {
if GOARCH == "ppc64" && GOOS == "aix" {
return uint64(uintptr(unsafe.Pointer(node)))<<(64-aixAddrBits) | uint64(cnt&(1<<aixCntBits-1))
}
+ if GOARCH == "riscv64" {
+ return uint64(uintptr(unsafe.Pointer(node)))<<(64-riscv64AddrBits) | uint64(cnt&(1<<riscv64CntBits-1))
+ }
return uint64(uintptr(unsafe.Pointer(node)))<<(64-addrBits) | uint64(cnt&(1<<cntBits-1))
}
@@ -54,5 +63,8 @@
if GOARCH == "ppc64" && GOOS == "aix" {
return (*lfnode)(unsafe.Pointer(uintptr((val >> aixCntBits << 3) | 0xa<<56)))
}
+ if GOARCH == "riscv64" {
+ return (*lfnode)(unsafe.Pointer(uintptr(val >> riscv64CntBits << 3)))
+ }
return (*lfnode)(unsafe.Pointer(uintptr(val >> cntBits << 3)))
}
To view, visit change 409055. To unsubscribe, or for help writing mail filters, visit settings.