diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-06-25 17:00:56 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-06-25 17:00:56 +0000 |
commit | 47eed32a5f43f9f17420f44d68bf251135f77ce6 (patch) | |
tree | bf36188dd241f5718f750e1e8ec6915c63a5699c /pkg/sentry/kernel/futex | |
parent | 97b3e461d427c10537f58755bc1b307a5548b092 (diff) | |
parent | 03ae91c662869a37ba71dd2577d4e218a3aa4669 (diff) |
Merge 03ae91c6 (automated)
Diffstat (limited to 'pkg/sentry/kernel/futex')
-rwxr-xr-x | pkg/sentry/kernel/futex/atomicptr_bucket.go | 12 | ||||
-rwxr-xr-x | pkg/sentry/kernel/futex/futex_state_autogen.go | 13 |
2 files changed, 24 insertions, 1 deletions
diff --git a/pkg/sentry/kernel/futex/atomicptr_bucket.go b/pkg/sentry/kernel/futex/atomicptr_bucket.go index 2251a6e72..d3fdf09b0 100755 --- a/pkg/sentry/kernel/futex/atomicptr_bucket.go +++ b/pkg/sentry/kernel/futex/atomicptr_bucket.go @@ -11,8 +11,18 @@ import ( // Note that copying AtomicPtr by value performs a non-atomic read of the // stored pointer, which is unsafe if Store() can be called concurrently; in // this case, do `dst.Store(src.Load())` instead. +// +// +stateify savable type AtomicPtrBucket struct { - ptr unsafe.Pointer + ptr unsafe.Pointer `state:".(*bucket)"` +} + +func (p *AtomicPtrBucket) savePtr() *bucket { + return p.Load() +} + +func (p *AtomicPtrBucket) loadPtr(v *bucket) { + p.Store(v) } // Load returns the value set by the most recent Store. It returns nil if there diff --git a/pkg/sentry/kernel/futex/futex_state_autogen.go b/pkg/sentry/kernel/futex/futex_state_autogen.go index 9c0092bb2..b2ff39f17 100755 --- a/pkg/sentry/kernel/futex/futex_state_autogen.go +++ b/pkg/sentry/kernel/futex/futex_state_autogen.go @@ -6,6 +6,18 @@ import ( "gvisor.dev/gvisor/pkg/state" ) +func (x *AtomicPtrBucket) beforeSave() {} +func (x *AtomicPtrBucket) save(m state.Map) { + x.beforeSave() + var ptr *bucket = x.savePtr() + m.SaveValue("ptr", ptr) +} + +func (x *AtomicPtrBucket) afterLoad() {} +func (x *AtomicPtrBucket) load(m state.Map) { + m.LoadValue("ptr", new(*bucket), func(y interface{}) { x.loadPtr(y.(*bucket)) }) +} + func (x *bucket) beforeSave() {} func (x *bucket) save(m state.Map) { x.beforeSave() @@ -55,6 +67,7 @@ func (x *waiterEntry) load(m state.Map) { } func init() { + state.Register("futex.AtomicPtrBucket", (*AtomicPtrBucket)(nil), state.Fns{Save: (*AtomicPtrBucket).save, Load: (*AtomicPtrBucket).load}) state.Register("futex.bucket", (*bucket)(nil), state.Fns{Save: (*bucket).save, Load: (*bucket).load}) state.Register("futex.Manager", (*Manager)(nil), state.Fns{Save: (*Manager).save, Load: (*Manager).load}) state.Register("futex.waiterList", (*waiterList)(nil), state.Fns{Save: (*waiterList).save, Load: (*waiterList).load}) |