summaryrefslogtreecommitdiffhomepage
path: root/pkg/ring0/lib_amd64.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/lib_amd64.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/lib_amd64.go')
-rw-r--r--pkg/ring0/lib_amd64.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/pkg/ring0/lib_amd64.go b/pkg/ring0/lib_amd64.go
index 3e6bb9663..46746fd80 100644
--- a/pkg/ring0/lib_amd64.go
+++ b/pkg/ring0/lib_amd64.go
@@ -43,8 +43,8 @@ func xsave(*byte)
// xsaveopt uses xsaveopt to save floating point state.
func xsaveopt(*byte)
-// WriteFS sets the GS address (set by init).
-var WriteFS func(addr uintptr)
+// writeFS sets the FS base address (selects one of wrfsbase or wrfsmsr).
+func writeFS(addr uintptr)
// wrfsbase writes to the GS base address.
func wrfsbase(addr uintptr)
@@ -116,10 +116,8 @@ func Init(featureSet *cpuid.FeatureSet) {
LoadFloatingPoint = fxrstor
}
if hasFSGSBASE {
- WriteFS = wrfsbase
WriteGS = wrgsbase
} else {
- WriteFS = wrfsmsr
WriteGS = wrgsmsr
}
}