blob: 1a6056171fd92c38dc312465c4dfa56dd6d21c84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build i386 amd64 arm64
package arch
import (
"gvisor.dev/gvisor/pkg/usermem"
)
const (
// SignalStackFlagOnStack is possible set on return from getaltstack,
// in order to indicate that the thread is currently on the alt stack.
SignalStackFlagOnStack = 1
// SignalStackFlagDisable is a flag to indicate the stack is disabled.
SignalStackFlagDisable = 2
)
// IsEnabled returns true iff this signal stack is marked as enabled.
func (s SignalStack) IsEnabled() bool {
return s.Flags&SignalStackFlagDisable == 0
}
// Top returns the stack's top address.
func (s SignalStack) Top() usermem.Addr {
return usermem.Addr(s.Addr + s.Size)
}
// SetOnStack marks this signal stack as in use.
//
// Note that there is no corresponding ClearOnStack, and that this should only
// be called on copies that are serialized to userspace.
func (s *SignalStack) SetOnStack() {
s.Flags |= SignalStackFlagOnStack
}
// Contains checks if the stack pointer is within this stack.
func (s *SignalStack) Contains(sp usermem.Addr) bool {
return usermem.Addr(s.Addr) < sp && sp <= usermem.Addr(s.Addr+s.Size)
}
// NativeSignalStack is a type that is equivalent to stack_t in the guest
// architecture.
type NativeSignalStack interface {
// SerializeFrom copies the data in the host SignalStack s into this
// object.
SerializeFrom(s *SignalStack)
// DeserializeTo copies the data in this object into the host SignalStack
// s.
DeserializeTo(s *SignalStack)
}
|