From eb9b8e53a3ef7bb96dcb59a0121fa9ed22f01bfd Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Tue, 30 Mar 2021 21:40:07 -0700 Subject: platform/kvm/x86: restore mxcsr when switching from guest to sentry Goruntime sets mxcsr once and never changes it. Reported-by: syzbot+ec55cea6e57ec083b7a6@syzkaller.appspotmail.com Fixes: #5754 --- pkg/ring0/kernel_amd64.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pkg/ring0/kernel_amd64.go') diff --git a/pkg/ring0/kernel_amd64.go b/pkg/ring0/kernel_amd64.go index 92d2330cb..6e17fb796 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. + ldmxcsr(&kernelMXCSR) // escapes: no. Restore kernel MXCSR. return } @@ -321,3 +322,13 @@ 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 + +func init() { + stmxcsr(&kernelMXCSR) +} -- cgit v1.2.3