7 Commits

Author SHA1 Message Date
Meng Zhuo
c0a9559877 cpu: add crypto extensions detection for riscv64
This CL adds RISC-V cryptography extensions detection.
Direct detection of the extensions zvkned, zvknhb, zvksed and
zvksh is not supported, since the crypto spec requires these
extensions implemented with data independent timing (zkt).

However, their presence may be inferred by checking for
the shorthand extensions: zvkn, zvknc, zvkng, zvks, zvksc, zvksg.

Change-Id: Ic00038cebf1b9f77426876b06b08f206473ad6fb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/664375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-05-01 02:30:04 -07:00
Mark Ryan
3283fc3f61 cpu: add support for detecting RISC-V extensions
Add a RISCV64 variable to cpu that indicates both the presence
of RISC-V extensions and performance information about the underlying
RISC-V cores.  The variable is only populated with non false values on
Linux.  The detection code first attempts to use the riscv_hwprobe
syscall introduced in Linux 6.4, falling back to HWCAP if riscv_hwprobe
is not supported.  The patch can detect the C, V, Zba, Zbb and Zbs
extensions.  V, Zba, Zbb and Zbs can only be detected on a 6.5 kernel
or later (without backports).

Updates golang/go#61416

Change-Id: I40f92724ee3d337c06bdc559ff0b18a8f6bfda9f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/605815
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2024-08-23 10:43:34 +00:00
Dmitri Shuralyov
1bfbee0e20 all: update go directive to 1.18
Done with:

go get go@1.18
go mod tidy
go fix ./...

Using go1.21.3.

Also update code generators to use only the new go:build lines,
not the old +build ones.

For golang/go#60268.

Change-Id: I6aabc42efb6ab3329981100e1db2263aac5e92a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/534222
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11 21:54:30 +00:00
Meng Zhuo
38ebf4150f cpu: fix wrong cache line size of riscv64
This CL follows CL526659 as cache line should be 64 Bytes

Change-Id: Id3a49dbfbfad6aeb439eb5e585fd2d6228a3d3ed
Reviewed-on: https://go-review.googlesource.com/c/sys/+/526935
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-13 01:34:38 +00:00
Russ Cox
9a76102bfb all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I01667f826428426a39c84717d02efa25fa44553c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/294490
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2021-02-20 05:07:31 +00:00
Polina Osadcha
0cf7623e9d cpu: add GODEBUG options to disable use of instruction set extensions
The GODEBUG environment variable can be used to disable usage of
specific processor features of Go programs that use the sys/cpu package.
This is useful for testing and benchmarking different code paths that
are guarded by sys/cpu variable checks.

Use of processor features can not be enabled through GODEBUG.

To disable usage of AVX and SSE41 cpu features on GOARCH amd64 use:
GODEBUG=cpu.avx=off,cpu.sse41=off

The special "all" option can be used to disable all options:
GODEBUG=all=off

This aligns the support of GODEBUG for sys/cpu with existing support
for GODEBUG in the Go standard library package internal/cpu.

Fixes golang/go#33963

Change-Id: I618b71af397bf06c57a49b2a300d032a16d05664
Reviewed-on: https://go-review.googlesource.com/c/sys/+/245237
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-08-05 06:55:43 +00:00
Tobias Klauser
2f3576d2c5 cpu: add basic support for GOARCH=riscv64
Updates golang/go#27532

Change-Id: I7250f272ff46f2765d498a97644fb570ae745a6c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/206860
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-13 15:47:02 +00:00