Add context.FullStateChanged()

It indicates that the Sentry has changed the state of the thread and
next calls of PullFullState() has to do nothing.

PiperOrigin-RevId: 325567415
This commit is contained in:
Andrei Vagin
2020-08-07 22:49:55 -07:00
committed by gVisor bot
parent 3be26a271c
commit 13a8ae81b2
6 changed files with 18 additions and 11 deletions
+1 -1
View File
@@ -1063,7 +1063,7 @@ func (t *Task) Ptrace(req int64, pid ThreadID, addr, data usermem.Addr) error {
if err != nil {
return err
}
t.p.FloatingPointStateChanged()
t.p.FullStateChanged()
ar.End -= usermem.Addr(n)
return t.CopyOutIovecs(data, usermem.AddrRangeSeqOf(ar))
+1
View File
@@ -226,6 +226,7 @@ func (r *runSyscallAfterExecStop) execute(t *Task) taskRunState {
t.tc = *r.tc
t.mu.Unlock()
t.unstopVforkParent()
t.p.FullStateChanged()
// NOTE(b/30316266): All locks must be dropped prior to calling Activate.
t.MemoryManager().Activate(t)
+2 -2
View File
@@ -280,7 +280,7 @@ func (t *Task) deliverSignalToHandler(info *arch.SignalInfo, act arch.SignalAct)
if err := t.Arch().SignalSetup(st, &act, info, &alt, mask); err != nil {
return err
}
t.p.FloatingPointStateChanged()
t.p.FullStateChanged()
t.haveSavedSignalMask = false
// Add our signal mask.
@@ -312,7 +312,7 @@ func (t *Task) SignalReturn(rt bool) (*SyscallControl, error) {
// Restore our signal mask. SIGKILL and SIGSTOP should not be blocked.
t.SetSignalMask(sigset &^ UnblockableSignals)
t.p.FloatingPointStateChanged()
t.p.FullStateChanged()
return ctrlResume, nil
}
+2 -2
View File
@@ -91,8 +91,8 @@ func (c *context) Interrupt() {
// Release implements platform.Context.Release().
func (c *context) Release() {}
// FloatingPointStateChanged implements platform.Context.FloatingPointStateChanged.
func (c *context) FloatingPointStateChanged() {}
// FullStateChanged implements platform.Context.FullStateChanged.
func (c *context) FullStateChanged() {}
// PullFullState implements platform.Context.PullFullState.
func (c *context) PullFullState(as platform.AddressSpace, ac arch.Context) {}
+10 -4
View File
@@ -171,14 +171,20 @@ type Context interface {
// Preconditions: The caller must be running on the task goroutine.
PullFullState(as AddressSpace, ac arch.Context)
// FloatingPointStateChanged forces restoring a full state of the application thread.
// FullStateChanged() indicates that a thread state has been changed by
// the Sentry. This happens in case of the rt_sigreturn, execve, etc.
//
// A platform can support lazy loading/restoring of a thread state.
// This means that if the Sentry has not changed a thread state,
// First, it indicates that the Sentry has the full state of the thread
// and PullFullState() has to do nothing if it is called after
// FullStateChanged().
//
// Second, it forces restoring the full state of the application
// thread. A platform can support lazy loading/restoring of a thread
// state. This means that if the Sentry has not changed a thread state,
// the platform may not restore it.
//
// Preconditions: The caller must be running on the task goroutine.
FloatingPointStateChanged()
FullStateChanged()
// Interrupt interrupts a concurrent call to Switch(), causing it to return
// ErrContextInterrupt.
+2 -2
View File
@@ -182,8 +182,8 @@ func (c *context) Interrupt() {
// Release implements platform.Context.Release().
func (c *context) Release() {}
// FloatingPointStateChanged implements platform.Context.FloatingPointStateChanged.
func (c *context) FloatingPointStateChanged() {}
// FullStateChanged implements platform.Context.FullStateChanged.
func (c *context) FullStateChanged() {}
// PullFullState implements platform.Context.PullFullState.
func (c *context) PullFullState(as platform.AddressSpace, ac arch.Context) {}