systrap: Enable using xsaveopt.

PiperOrigin-RevId: 554906814
This commit is contained in:
Konstantin Bogomolov
2023-08-08 12:33:59 -07:00
committed by gVisor bot
parent 3458b18514
commit 821459c942
4 changed files with 11 additions and 19 deletions
@@ -172,16 +172,12 @@ func (sc *sharedContext) threadID() uint32 {
// EnableSentryFastPath indicates that the polling mode is enabled for the
// Sentry. It has to be called before putting the context into the context queue.
// This function is used if contextDecouplingExp=true because the fastpath
// is negotiated in ThreadContext.
func (sc *sharedContext) enableSentryFastPath() {
atomic.StoreUint32(&sc.shared.SentryFastPath, 1)
}
// DisableSentryFastPath indicates that the polling mode for the sentry is
// disabled for the Sentry.
// This function is used if contextDecouplingExp=true because the fastpath
// is negotiated in ThreadContext.
func (sc *sharedContext) disableSentryFastPath() {
atomic.StoreUint32(&sc.shared.SentryFastPath, 0)
}
@@ -125,17 +125,11 @@ restored_gs:
movl $0xffffffff, %eax
movl $0xffffffff, %edx
movl __export_arch_state+offsetof_arch_state_xsave_mode(%rip), %esi
// TODO(b/268366549): Fix use of xsavec/xsaveopt.
// cmpl $XSAVE_MODE_XSAVEC, %esi
// jl use_xsaveopt
// xsavec (%rdi)
// jmp fpu_saved
// use_xsaveopt:
// cmpl $XSAVE_MODE_XSAVEOPT, %esi
// jl use_xsave
// xsaveopt (%rdi)
// jmp fpu_saved
// use_xsave:
cmpl $XSAVE_MODE_XSAVEOPT, %esi
jl use_xsave
xsaveopt (%rdi)
jmp fpu_saved
use_xsave:
cmpl $XSAVE_MODE_XSAVE, %esi
jl use_fxsave
xsave (%rdi)
@@ -38,11 +38,13 @@ type ArchState struct {
fsgsbase uint32
}
// The linux kernel does not allow using xsavec from userspace, so we are limited
// to xsaveopt.
// See arch/x86/kernel/fpu/xstate.c:validate_user_xstate_header for details.
const (
fxsave = iota
xsave
xsaveopt
xsavec
)
// Init initializes the arch specific state.
@@ -51,8 +53,9 @@ func (s *ArchState) Init() {
fpLenUint, _ := fs.ExtendedStateSize()
s.fpLen = uint32(fpLenUint)
// TODO(b/268366549): Fix use of xsavec/xsaveopt.
if fs.UseXsave() {
if fs.UseXsaveopt() {
s.xsaveMode = xsaveopt
} else if fs.UseXsave() {
s.xsaveMode = xsave
} else {
s.xsaveMode = fxsave
@@ -24,7 +24,6 @@
#define XSAVE_MODE_FXSAVE (0x0)
#define XSAVE_MODE_XSAVE (0x1)
#define XSAVE_MODE_XSAVEOPT (0x2)
#define XSAVE_MODE_XSAVEC (0x3)
// LINT.ThenChange(sysmsg.h, sysmsg_amd64.go)
// LINT.IfChange