diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-04-09 17:15:06 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-09 17:15:06 -0700 |
commit | 7420821a7b5fe15f3666bb4971796cd45fc5ff38 (patch) | |
tree | e589b5c862322dd86a1d0ebee93c0bb5c2710e3b /pkg/ring0/kernel_amd64.go | |
parent | dc8f6c6914747c700a629b7717e45759cf1f7650 (diff) | |
parent | eb9b8e53a3ef7bb96dcb59a0121fa9ed22f01bfd (diff) |
Merge pull request #5767 from avagin:mxcsr
PiperOrigin-RevId: 367730917
Diffstat (limited to 'pkg/ring0/kernel_amd64.go')
-rw-r--r-- | pkg/ring0/kernel_amd64.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/ring0/kernel_amd64.go b/pkg/ring0/kernel_amd64.go index 92d2330cb..41dfd0bf9 100644 --- a/pkg/ring0/kernel_amd64.go +++ b/pkg/ring0/kernel_amd64.go @@ -250,6 +250,7 @@ func (c *CPU) SwitchToUser(switchOpts SwitchOpts) (vector Vector) { } SaveFloatingPoint(switchOpts.FloatingPointState.BytePointer()) // escapes: no. Copy out floating point. WriteFS(uintptr(c.registers.Fs_base)) // escapes: no. Restore kernel FS. + RestoreKernelFPState() // escapes: no. Restore kernel MXCSR. return } @@ -321,3 +322,21 @@ func SetCPUIDFaulting(on bool) bool { func ReadCR2() uintptr { return readCR2() } + +// kernelMXCSR is the value of the mxcsr register in the Sentry. +// +// The MXCSR control configuration is initialized once and never changed. Look +// at src/cmd/compile/abi-internal.md in the golang sources for more details. +var kernelMXCSR uint32 + +// RestoreKernelFPState restores the Sentry floating point state. +// +//go:nosplit +func RestoreKernelFPState() { + // Restore the MXCSR control configuration. + ldmxcsr(&kernelMXCSR) +} + +func init() { + stmxcsr(&kernelMXCSR) +} |