diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-06-24 06:37:35 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-24 06:37:35 +0000 |
commit | 9183888b520beeee8609170819a28bea89202909 (patch) | |
tree | 3cdcfa4de9ced4c539ab7c57e4cf58ffea980f6c /pkg/sentry/kernel/futex | |
parent | cab13958a54419262aba2a0cd7f1075ed02c8ee0 (diff) | |
parent | 364ac92baf83f2352f78b718090472639bd92a76 (diff) |
Merge release-20200608.0-119-g364ac92ba (automated)
Diffstat (limited to 'pkg/sentry/kernel/futex')
-rw-r--r-- | pkg/sentry/kernel/futex/futex_state_autogen.go | 96 | ||||
-rw-r--r-- | pkg/sentry/kernel/futex/futex_unsafe_state_autogen.go | 22 | ||||
-rw-r--r-- | pkg/sentry/kernel/futex/waiter_list.go | 6 |
3 files changed, 92 insertions, 32 deletions
diff --git a/pkg/sentry/kernel/futex/futex_state_autogen.go b/pkg/sentry/kernel/futex/futex_state_autogen.go index 12a0788ff..13e9a97d0 100644 --- a/pkg/sentry/kernel/futex/futex_state_autogen.go +++ b/pkg/sentry/kernel/futex/futex_state_autogen.go @@ -6,61 +6,109 @@ import ( "gvisor.dev/gvisor/pkg/state" ) +func (x *bucket) StateTypeName() string { + return "pkg/sentry/kernel/futex.bucket" +} + +func (x *bucket) StateFields() []string { + return []string{} +} + func (x *bucket) beforeSave() {} -func (x *bucket) save(m state.Map) { + +func (x *bucket) StateSave(m state.Sink) { x.beforeSave() if !state.IsZeroValue(&x.waiters) { - m.Failf("waiters is %#v, expected zero", &x.waiters) + state.Failf("waiters is %#v, expected zero", &x.waiters) } } func (x *bucket) afterLoad() {} -func (x *bucket) load(m state.Map) { + +func (x *bucket) StateLoad(m state.Source) { +} + +func (x *Manager) StateTypeName() string { + return "pkg/sentry/kernel/futex.Manager" +} + +func (x *Manager) StateFields() []string { + return []string{ + "sharedBucket", + } } func (x *Manager) beforeSave() {} -func (x *Manager) save(m state.Map) { + +func (x *Manager) StateSave(m state.Sink) { x.beforeSave() if !state.IsZeroValue(&x.privateBuckets) { - m.Failf("privateBuckets is %#v, expected zero", &x.privateBuckets) + state.Failf("privateBuckets is %#v, expected zero", &x.privateBuckets) } - m.Save("sharedBucket", &x.sharedBucket) + m.Save(0, &x.sharedBucket) } func (x *Manager) afterLoad() {} -func (x *Manager) load(m state.Map) { - m.Load("sharedBucket", &x.sharedBucket) + +func (x *Manager) StateLoad(m state.Source) { + m.Load(0, &x.sharedBucket) +} + +func (x *waiterList) StateTypeName() string { + return "pkg/sentry/kernel/futex.waiterList" +} + +func (x *waiterList) StateFields() []string { + return []string{ + "head", + "tail", + } } func (x *waiterList) beforeSave() {} -func (x *waiterList) save(m state.Map) { + +func (x *waiterList) StateSave(m state.Sink) { x.beforeSave() - m.Save("head", &x.head) - m.Save("tail", &x.tail) + m.Save(0, &x.head) + m.Save(1, &x.tail) } func (x *waiterList) afterLoad() {} -func (x *waiterList) load(m state.Map) { - m.Load("head", &x.head) - m.Load("tail", &x.tail) + +func (x *waiterList) StateLoad(m state.Source) { + m.Load(0, &x.head) + m.Load(1, &x.tail) +} + +func (x *waiterEntry) StateTypeName() string { + return "pkg/sentry/kernel/futex.waiterEntry" +} + +func (x *waiterEntry) StateFields() []string { + return []string{ + "next", + "prev", + } } func (x *waiterEntry) beforeSave() {} -func (x *waiterEntry) save(m state.Map) { + +func (x *waiterEntry) StateSave(m state.Sink) { x.beforeSave() - m.Save("next", &x.next) - m.Save("prev", &x.prev) + m.Save(0, &x.next) + m.Save(1, &x.prev) } func (x *waiterEntry) afterLoad() {} -func (x *waiterEntry) load(m state.Map) { - m.Load("next", &x.next) - m.Load("prev", &x.prev) + +func (x *waiterEntry) StateLoad(m state.Source) { + m.Load(0, &x.next) + m.Load(1, &x.prev) } func init() { - state.Register("pkg/sentry/kernel/futex.bucket", (*bucket)(nil), state.Fns{Save: (*bucket).save, Load: (*bucket).load}) - state.Register("pkg/sentry/kernel/futex.Manager", (*Manager)(nil), state.Fns{Save: (*Manager).save, Load: (*Manager).load}) - state.Register("pkg/sentry/kernel/futex.waiterList", (*waiterList)(nil), state.Fns{Save: (*waiterList).save, Load: (*waiterList).load}) - state.Register("pkg/sentry/kernel/futex.waiterEntry", (*waiterEntry)(nil), state.Fns{Save: (*waiterEntry).save, Load: (*waiterEntry).load}) + state.Register((*bucket)(nil)) + state.Register((*Manager)(nil)) + state.Register((*waiterList)(nil)) + state.Register((*waiterEntry)(nil)) } diff --git a/pkg/sentry/kernel/futex/futex_unsafe_state_autogen.go b/pkg/sentry/kernel/futex/futex_unsafe_state_autogen.go index 7fc038fce..244cdb502 100644 --- a/pkg/sentry/kernel/futex/futex_unsafe_state_autogen.go +++ b/pkg/sentry/kernel/futex/futex_unsafe_state_autogen.go @@ -6,18 +6,30 @@ import ( "gvisor.dev/gvisor/pkg/state" ) +func (x *AtomicPtrBucket) StateTypeName() string { + return "pkg/sentry/kernel/futex.AtomicPtrBucket" +} + +func (x *AtomicPtrBucket) StateFields() []string { + return []string{ + "ptr", + } +} + func (x *AtomicPtrBucket) beforeSave() {} -func (x *AtomicPtrBucket) save(m state.Map) { + +func (x *AtomicPtrBucket) StateSave(m state.Sink) { x.beforeSave() var ptr *bucket = x.savePtr() - m.SaveValue("ptr", ptr) + m.SaveValue(0, 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 *AtomicPtrBucket) StateLoad(m state.Source) { + m.LoadValue(0, new(*bucket), func(y interface{}) { x.loadPtr(y.(*bucket)) }) } func init() { - state.Register("pkg/sentry/kernel/futex.AtomicPtrBucket", (*AtomicPtrBucket)(nil), state.Fns{Save: (*AtomicPtrBucket).save, Load: (*AtomicPtrBucket).load}) + state.Register((*AtomicPtrBucket)(nil)) } diff --git a/pkg/sentry/kernel/futex/waiter_list.go b/pkg/sentry/kernel/futex/waiter_list.go index 1b7a92b62..ab6997b26 100644 --- a/pkg/sentry/kernel/futex/waiter_list.go +++ b/pkg/sentry/kernel/futex/waiter_list.go @@ -56,7 +56,7 @@ func (l *waiterList) Back() *Waiter { // // NOTE: This is an O(n) operation. func (l *waiterList) Len() (count int) { - for e := l.Front(); e != nil; e = e.Next() { + for e := l.Front(); e != nil; e = (waiterElementMapper{}.linkerFor(e)).Next() { count++ } return count @@ -148,13 +148,13 @@ func (l *waiterList) Remove(e *Waiter) { if prev != nil { waiterElementMapper{}.linkerFor(prev).SetNext(next) - } else { + } else if l.head == e { l.head = next } if next != nil { waiterElementMapper{}.linkerFor(next).SetPrev(prev) - } else { + } else if l.tail == e { l.tail = prev } |