go/src/runtime/os_linux_riscv64.go
aimuz b7c20413c5 runtime: remove obsolete osArchInit function
The osArchInit function was introduced as a workaround for a Linux kernel bug
that corrupted vector registers on x86 CPUs during signal delivery.
The bug was introduced in Linux 5.2 and fixed in 5.3.15, 5.4.2, and all 5.5 and later kernels.
The fix was also back-ported by major distros.

Change-Id: I59990a7df104843955301c5cb8a547614eba145b
GitHub-Last-Rev: 8425af458b
GitHub-Pull-Request: golang/go#75246
Reviewed-on: https://go-review.googlesource.com/c/go/+/700555
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-09-04 07:30:42 -07:00

35 lines
1.3 KiB
Go

// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package runtime
import (
"internal/runtime/syscall/linux"
"unsafe"
)
type riscvHWProbePairs = struct {
key int64
value uint64
}
// TODO: Consider whether to use the VDSO entry for riscv_hwprobe.
// There is a VDSO entry for riscv_hwprobe that should allow us to avoid the syscall
// entirely as it can handle the case where the caller only requests extensions that are
// supported on all cores, which is what we're doing here. However, as we're only calling
// this syscall once, it may not be worth the added effort to implement the VDSO call.
//go:linkname internal_cpu_riscvHWProbe internal/cpu.riscvHWProbe
func internal_cpu_riscvHWProbe(pairs []riscvHWProbePairs, flags uint) bool {
// sys_RISCV_HWPROBE is copied from golang.org/x/sys/unix/zsysnum_linux_riscv64.go.
const sys_RISCV_HWPROBE uintptr = 258
if len(pairs) == 0 {
return false
}
// Passing in a cpuCount of 0 and a cpu of nil ensures that only extensions supported by all the
// cores are returned, which is the behaviour we want in internal/cpu.
_, _, e1 := linux.Syscall6(sys_RISCV_HWPROBE, uintptr(unsafe.Pointer(&pairs[0])), uintptr(len(pairs)), uintptr(0), uintptr(unsafe.Pointer(nil)), uintptr(flags), 0)
return e1 == 0
}