diff options
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}) |