summaryrefslogtreecommitdiffhomepage
path: root/pkg/ring0/kernel_unsafe.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-07-12 07:59:47 -0700
committergVisor bot <gvisor-bot@google.com>2021-07-12 08:01:53 -0700
commit36a17a814bf90bad33eac25ddbb7a416143a4be7 (patch)
treefaa4d72267f1efc227cd56d0e8f8cb23c5dacb16 /pkg/ring0/kernel_unsafe.go
parentd78713e2da5331a22fc51fb9a9ad33cc1873879c (diff)
Go 1.17 support for the KVM platform
Go 1.17 adds a new register-based calling convention. While transparent for most applications, the KVM platform needs special work in a few cases. First of all, we need the actual address of some assembly functions, rather than the address of a wrapper. See http://gvisor.dev/pr/5832 for complete discussion of this. More relevant to this CL is that ABI0-to-ABIInternal wrappers (i.e., calls from assembly to Go) access the G via FS_BASE. The KVM quite fast-and-loose about the Go environment, often calling into (nosplit) Go functions with uninitialized FS_BASE. That will no longer work in Go 1.17, so this CL changes the platform to consistently restore FS_BASE before calling into Go code. This CL does not affect arm64 code. Go 1.17 does not support the register-based calling convention for arm64 (it will come in 1.18), but arm64 also does not use a non-standard register like FS_BASE for TLS, so it may not require any changes. PiperOrigin-RevId: 384234305
Diffstat (limited to 'pkg/ring0/kernel_unsafe.go')
-rw-r--r--pkg/ring0/kernel_unsafe.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/pkg/ring0/kernel_unsafe.go b/pkg/ring0/kernel_unsafe.go
index 16955ad91..04c60d0a7 100644
--- a/pkg/ring0/kernel_unsafe.go
+++ b/pkg/ring0/kernel_unsafe.go
@@ -35,7 +35,6 @@ func kernelAddr(obj interface{}) uintptr {
// kernelFunc returns the address of the given function.
//
//go:nosplit
-func kernelFunc(fn func()) uintptr {
- fnptr := (**uintptr)(unsafe.Pointer(&fn))
- return KernelStartAddress | **fnptr
+func kernelFunc(fn uintptr) uintptr {
+ return KernelStartAddress | fn
}