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/sentry/arch/fpu/fpu_amd64.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg/sentry/arch/fpu') diff --git a/pkg/sentry/arch/fpu/fpu_amd64.go b/pkg/sentry/arch/fpu/fpu_amd64.go index 1e9625bee..f0ba26736 100644 --- a/pkg/sentry/arch/fpu/fpu_amd64.go +++ b/pkg/sentry/arch/fpu/fpu_amd64.go @@ -219,6 +219,11 @@ func (s *State) PtraceSetXstateRegs(src io.Reader, maxlen int, featureSet *cpuid return copy(*s, f), nil } +// SetMXCSR sets the MXCSR control/status register in the state. +func (s *State) SetMXCSR(mxcsr uint32) { + hostarch.ByteOrder.PutUint32((*s)[mxcsrOffset:], mxcsr) +} + // BytePointer returns a pointer to the first byte of the state. // //go:nosplit -- cgit v1.2.3