diff options
Diffstat (limited to 'pkg/sentry/mm')
-rw-r--r-- | pkg/sentry/mm/mm_state_autogen.go | 710 | ||||
-rw-r--r-- | pkg/sentry/mm/pma.go | 24 | ||||
-rw-r--r-- | pkg/sentry/mm/vma.go | 10 |
3 files changed, 372 insertions, 372 deletions
diff --git a/pkg/sentry/mm/mm_state_autogen.go b/pkg/sentry/mm/mm_state_autogen.go index a4e826a4f..1636e5235 100644 --- a/pkg/sentry/mm/mm_state_autogen.go +++ b/pkg/sentry/mm/mm_state_autogen.go @@ -6,60 +6,60 @@ import ( "gvisor.dev/gvisor/pkg/state" ) -func (x *aioManager) StateTypeName() string { +func (a *aioManager) StateTypeName() string { return "pkg/sentry/mm.aioManager" } -func (x *aioManager) StateFields() []string { +func (a *aioManager) StateFields() []string { return []string{ "contexts", } } -func (x *aioManager) beforeSave() {} +func (a *aioManager) beforeSave() {} -func (x *aioManager) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.contexts) +func (a *aioManager) StateSave(stateSinkObject state.Sink) { + a.beforeSave() + stateSinkObject.Save(0, &a.contexts) } -func (x *aioManager) afterLoad() {} +func (a *aioManager) afterLoad() {} -func (x *aioManager) StateLoad(m state.Source) { - m.Load(0, &x.contexts) +func (a *aioManager) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &a.contexts) } -func (x *ioResult) StateTypeName() string { +func (i *ioResult) StateTypeName() string { return "pkg/sentry/mm.ioResult" } -func (x *ioResult) StateFields() []string { +func (i *ioResult) StateFields() []string { return []string{ "data", "ioEntry", } } -func (x *ioResult) beforeSave() {} +func (i *ioResult) beforeSave() {} -func (x *ioResult) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.data) - m.Save(1, &x.ioEntry) +func (i *ioResult) StateSave(stateSinkObject state.Sink) { + i.beforeSave() + stateSinkObject.Save(0, &i.data) + stateSinkObject.Save(1, &i.ioEntry) } -func (x *ioResult) afterLoad() {} +func (i *ioResult) afterLoad() {} -func (x *ioResult) StateLoad(m state.Source) { - m.Load(0, &x.data) - m.Load(1, &x.ioEntry) +func (i *ioResult) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &i.data) + stateSourceObject.Load(1, &i.ioEntry) } -func (x *AIOContext) StateTypeName() string { +func (a *AIOContext) StateTypeName() string { return "pkg/sentry/mm.AIOContext" } -func (x *AIOContext) StateFields() []string { +func (a *AIOContext) StateFields() []string { return []string{ "results", "maxOutstanding", @@ -67,30 +67,30 @@ func (x *AIOContext) StateFields() []string { } } -func (x *AIOContext) beforeSave() {} +func (a *AIOContext) beforeSave() {} -func (x *AIOContext) StateSave(m state.Sink) { - x.beforeSave() - if !state.IsZeroValue(&x.dead) { - state.Failf("dead is %#v, expected zero", &x.dead) +func (a *AIOContext) StateSave(stateSinkObject state.Sink) { + a.beforeSave() + if !state.IsZeroValue(&a.dead) { + state.Failf("dead is %#v, expected zero", &a.dead) } - m.Save(0, &x.results) - m.Save(1, &x.maxOutstanding) - m.Save(2, &x.outstanding) + stateSinkObject.Save(0, &a.results) + stateSinkObject.Save(1, &a.maxOutstanding) + stateSinkObject.Save(2, &a.outstanding) } -func (x *AIOContext) StateLoad(m state.Source) { - m.Load(0, &x.results) - m.Load(1, &x.maxOutstanding) - m.Load(2, &x.outstanding) - m.AfterLoad(x.afterLoad) +func (a *AIOContext) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &a.results) + stateSourceObject.Load(1, &a.maxOutstanding) + stateSourceObject.Load(2, &a.outstanding) + stateSourceObject.AfterLoad(a.afterLoad) } -func (x *aioMappable) StateTypeName() string { +func (a *aioMappable) StateTypeName() string { return "pkg/sentry/mm.aioMappable" } -func (x *aioMappable) StateFields() []string { +func (a *aioMappable) StateFields() []string { return []string{ "aioMappableRefs", "mfp", @@ -98,75 +98,75 @@ func (x *aioMappable) StateFields() []string { } } -func (x *aioMappable) beforeSave() {} +func (a *aioMappable) beforeSave() {} -func (x *aioMappable) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.aioMappableRefs) - m.Save(1, &x.mfp) - m.Save(2, &x.fr) +func (a *aioMappable) StateSave(stateSinkObject state.Sink) { + a.beforeSave() + stateSinkObject.Save(0, &a.aioMappableRefs) + stateSinkObject.Save(1, &a.mfp) + stateSinkObject.Save(2, &a.fr) } -func (x *aioMappable) afterLoad() {} +func (a *aioMappable) afterLoad() {} -func (x *aioMappable) StateLoad(m state.Source) { - m.Load(0, &x.aioMappableRefs) - m.Load(1, &x.mfp) - m.Load(2, &x.fr) +func (a *aioMappable) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &a.aioMappableRefs) + stateSourceObject.Load(1, &a.mfp) + stateSourceObject.Load(2, &a.fr) } -func (x *aioMappableRefs) StateTypeName() string { +func (a *aioMappableRefs) StateTypeName() string { return "pkg/sentry/mm.aioMappableRefs" } -func (x *aioMappableRefs) StateFields() []string { +func (a *aioMappableRefs) StateFields() []string { return []string{ "refCount", } } -func (x *aioMappableRefs) beforeSave() {} +func (a *aioMappableRefs) beforeSave() {} -func (x *aioMappableRefs) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.refCount) +func (a *aioMappableRefs) StateSave(stateSinkObject state.Sink) { + a.beforeSave() + stateSinkObject.Save(0, &a.refCount) } -func (x *aioMappableRefs) afterLoad() {} +func (a *aioMappableRefs) afterLoad() {} -func (x *aioMappableRefs) StateLoad(m state.Source) { - m.Load(0, &x.refCount) +func (a *aioMappableRefs) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &a.refCount) } -func (x *fileRefcountSet) StateTypeName() string { +func (f *fileRefcountSet) StateTypeName() string { return "pkg/sentry/mm.fileRefcountSet" } -func (x *fileRefcountSet) StateFields() []string { +func (f *fileRefcountSet) StateFields() []string { return []string{ "root", } } -func (x *fileRefcountSet) beforeSave() {} +func (f *fileRefcountSet) beforeSave() {} -func (x *fileRefcountSet) StateSave(m state.Sink) { - x.beforeSave() - var root *fileRefcountSegmentDataSlices = x.saveRoot() - m.SaveValue(0, root) +func (f *fileRefcountSet) StateSave(stateSinkObject state.Sink) { + f.beforeSave() + var rootValue *fileRefcountSegmentDataSlices = f.saveRoot() + stateSinkObject.SaveValue(0, rootValue) } -func (x *fileRefcountSet) afterLoad() {} +func (f *fileRefcountSet) afterLoad() {} -func (x *fileRefcountSet) StateLoad(m state.Source) { - m.LoadValue(0, new(*fileRefcountSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*fileRefcountSegmentDataSlices)) }) +func (f *fileRefcountSet) StateLoad(stateSourceObject state.Source) { + stateSourceObject.LoadValue(0, new(*fileRefcountSegmentDataSlices), func(y interface{}) { f.loadRoot(y.(*fileRefcountSegmentDataSlices)) }) } -func (x *fileRefcountnode) StateTypeName() string { +func (f *fileRefcountnode) StateTypeName() string { return "pkg/sentry/mm.fileRefcountnode" } -func (x *fileRefcountnode) StateFields() []string { +func (f *fileRefcountnode) StateFields() []string { return []string{ "nrSegments", "parent", @@ -179,38 +179,38 @@ func (x *fileRefcountnode) StateFields() []string { } } -func (x *fileRefcountnode) beforeSave() {} +func (f *fileRefcountnode) beforeSave() {} -func (x *fileRefcountnode) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.nrSegments) - m.Save(1, &x.parent) - m.Save(2, &x.parentIndex) - m.Save(3, &x.hasChildren) - m.Save(4, &x.maxGap) - m.Save(5, &x.keys) - m.Save(6, &x.values) - m.Save(7, &x.children) +func (f *fileRefcountnode) StateSave(stateSinkObject state.Sink) { + f.beforeSave() + stateSinkObject.Save(0, &f.nrSegments) + stateSinkObject.Save(1, &f.parent) + stateSinkObject.Save(2, &f.parentIndex) + stateSinkObject.Save(3, &f.hasChildren) + stateSinkObject.Save(4, &f.maxGap) + stateSinkObject.Save(5, &f.keys) + stateSinkObject.Save(6, &f.values) + stateSinkObject.Save(7, &f.children) } -func (x *fileRefcountnode) afterLoad() {} +func (f *fileRefcountnode) afterLoad() {} -func (x *fileRefcountnode) StateLoad(m state.Source) { - m.Load(0, &x.nrSegments) - m.Load(1, &x.parent) - m.Load(2, &x.parentIndex) - m.Load(3, &x.hasChildren) - m.Load(4, &x.maxGap) - m.Load(5, &x.keys) - m.Load(6, &x.values) - m.Load(7, &x.children) +func (f *fileRefcountnode) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &f.nrSegments) + stateSourceObject.Load(1, &f.parent) + stateSourceObject.Load(2, &f.parentIndex) + stateSourceObject.Load(3, &f.hasChildren) + stateSourceObject.Load(4, &f.maxGap) + stateSourceObject.Load(5, &f.keys) + stateSourceObject.Load(6, &f.values) + stateSourceObject.Load(7, &f.children) } -func (x *fileRefcountSegmentDataSlices) StateTypeName() string { +func (f *fileRefcountSegmentDataSlices) StateTypeName() string { return "pkg/sentry/mm.fileRefcountSegmentDataSlices" } -func (x *fileRefcountSegmentDataSlices) StateFields() []string { +func (f *fileRefcountSegmentDataSlices) StateFields() []string { return []string{ "Start", "End", @@ -218,80 +218,80 @@ func (x *fileRefcountSegmentDataSlices) StateFields() []string { } } -func (x *fileRefcountSegmentDataSlices) beforeSave() {} +func (f *fileRefcountSegmentDataSlices) beforeSave() {} -func (x *fileRefcountSegmentDataSlices) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.Start) - m.Save(1, &x.End) - m.Save(2, &x.Values) +func (f *fileRefcountSegmentDataSlices) StateSave(stateSinkObject state.Sink) { + f.beforeSave() + stateSinkObject.Save(0, &f.Start) + stateSinkObject.Save(1, &f.End) + stateSinkObject.Save(2, &f.Values) } -func (x *fileRefcountSegmentDataSlices) afterLoad() {} +func (f *fileRefcountSegmentDataSlices) afterLoad() {} -func (x *fileRefcountSegmentDataSlices) StateLoad(m state.Source) { - m.Load(0, &x.Start) - m.Load(1, &x.End) - m.Load(2, &x.Values) +func (f *fileRefcountSegmentDataSlices) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &f.Start) + stateSourceObject.Load(1, &f.End) + stateSourceObject.Load(2, &f.Values) } -func (x *ioList) StateTypeName() string { +func (i *ioList) StateTypeName() string { return "pkg/sentry/mm.ioList" } -func (x *ioList) StateFields() []string { +func (i *ioList) StateFields() []string { return []string{ "head", "tail", } } -func (x *ioList) beforeSave() {} +func (i *ioList) beforeSave() {} -func (x *ioList) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.head) - m.Save(1, &x.tail) +func (i *ioList) StateSave(stateSinkObject state.Sink) { + i.beforeSave() + stateSinkObject.Save(0, &i.head) + stateSinkObject.Save(1, &i.tail) } -func (x *ioList) afterLoad() {} +func (i *ioList) afterLoad() {} -func (x *ioList) StateLoad(m state.Source) { - m.Load(0, &x.head) - m.Load(1, &x.tail) +func (i *ioList) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &i.head) + stateSourceObject.Load(1, &i.tail) } -func (x *ioEntry) StateTypeName() string { +func (i *ioEntry) StateTypeName() string { return "pkg/sentry/mm.ioEntry" } -func (x *ioEntry) StateFields() []string { +func (i *ioEntry) StateFields() []string { return []string{ "next", "prev", } } -func (x *ioEntry) beforeSave() {} +func (i *ioEntry) beforeSave() {} -func (x *ioEntry) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.next) - m.Save(1, &x.prev) +func (i *ioEntry) StateSave(stateSinkObject state.Sink) { + i.beforeSave() + stateSinkObject.Save(0, &i.next) + stateSinkObject.Save(1, &i.prev) } -func (x *ioEntry) afterLoad() {} +func (i *ioEntry) afterLoad() {} -func (x *ioEntry) StateLoad(m state.Source) { - m.Load(0, &x.next) - m.Load(1, &x.prev) +func (i *ioEntry) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &i.next) + stateSourceObject.Load(1, &i.prev) } -func (x *MemoryManager) StateTypeName() string { +func (m *MemoryManager) StateTypeName() string { return "pkg/sentry/mm.MemoryManager" } -func (x *MemoryManager) StateFields() []string { +func (m *MemoryManager) StateFields() []string { return []string{ "p", "mfp", @@ -319,71 +319,71 @@ func (x *MemoryManager) StateFields() []string { } } -func (x *MemoryManager) StateSave(m state.Sink) { - x.beforeSave() - if !state.IsZeroValue(&x.active) { - state.Failf("active is %#v, expected zero", &x.active) +func (m *MemoryManager) StateSave(stateSinkObject state.Sink) { + m.beforeSave() + if !state.IsZeroValue(&m.active) { + state.Failf("active is %#v, expected zero", &m.active) } - if !state.IsZeroValue(&x.captureInvalidations) { - state.Failf("captureInvalidations is %#v, expected zero", &x.captureInvalidations) + if !state.IsZeroValue(&m.captureInvalidations) { + state.Failf("captureInvalidations is %#v, expected zero", &m.captureInvalidations) } - m.Save(0, &x.p) - m.Save(1, &x.mfp) - m.Save(2, &x.layout) - m.Save(3, &x.privateRefs) - m.Save(4, &x.users) - m.Save(5, &x.vmas) - m.Save(6, &x.brk) - m.Save(7, &x.usageAS) - m.Save(8, &x.lockedAS) - m.Save(9, &x.dataAS) - m.Save(10, &x.defMLockMode) - m.Save(11, &x.pmas) - m.Save(12, &x.curRSS) - m.Save(13, &x.maxRSS) - m.Save(14, &x.argv) - m.Save(15, &x.envv) - m.Save(16, &x.auxv) - m.Save(17, &x.executable) - m.Save(18, &x.dumpability) - m.Save(19, &x.aioManager) - m.Save(20, &x.sleepForActivation) - m.Save(21, &x.vdsoSigReturnAddr) - m.Save(22, &x.membarrierPrivateEnabled) -} - -func (x *MemoryManager) StateLoad(m state.Source) { - m.Load(0, &x.p) - m.Load(1, &x.mfp) - m.Load(2, &x.layout) - m.Load(3, &x.privateRefs) - m.Load(4, &x.users) - m.Load(5, &x.vmas) - m.Load(6, &x.brk) - m.Load(7, &x.usageAS) - m.Load(8, &x.lockedAS) - m.Load(9, &x.dataAS) - m.Load(10, &x.defMLockMode) - m.Load(11, &x.pmas) - m.Load(12, &x.curRSS) - m.Load(13, &x.maxRSS) - m.Load(14, &x.argv) - m.Load(15, &x.envv) - m.Load(16, &x.auxv) - m.Load(17, &x.executable) - m.Load(18, &x.dumpability) - m.Load(19, &x.aioManager) - m.Load(20, &x.sleepForActivation) - m.Load(21, &x.vdsoSigReturnAddr) - m.Load(22, &x.membarrierPrivateEnabled) - m.AfterLoad(x.afterLoad) -} - -func (x *vma) StateTypeName() string { + stateSinkObject.Save(0, &m.p) + stateSinkObject.Save(1, &m.mfp) + stateSinkObject.Save(2, &m.layout) + stateSinkObject.Save(3, &m.privateRefs) + stateSinkObject.Save(4, &m.users) + stateSinkObject.Save(5, &m.vmas) + stateSinkObject.Save(6, &m.brk) + stateSinkObject.Save(7, &m.usageAS) + stateSinkObject.Save(8, &m.lockedAS) + stateSinkObject.Save(9, &m.dataAS) + stateSinkObject.Save(10, &m.defMLockMode) + stateSinkObject.Save(11, &m.pmas) + stateSinkObject.Save(12, &m.curRSS) + stateSinkObject.Save(13, &m.maxRSS) + stateSinkObject.Save(14, &m.argv) + stateSinkObject.Save(15, &m.envv) + stateSinkObject.Save(16, &m.auxv) + stateSinkObject.Save(17, &m.executable) + stateSinkObject.Save(18, &m.dumpability) + stateSinkObject.Save(19, &m.aioManager) + stateSinkObject.Save(20, &m.sleepForActivation) + stateSinkObject.Save(21, &m.vdsoSigReturnAddr) + stateSinkObject.Save(22, &m.membarrierPrivateEnabled) +} + +func (m *MemoryManager) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &m.p) + stateSourceObject.Load(1, &m.mfp) + stateSourceObject.Load(2, &m.layout) + stateSourceObject.Load(3, &m.privateRefs) + stateSourceObject.Load(4, &m.users) + stateSourceObject.Load(5, &m.vmas) + stateSourceObject.Load(6, &m.brk) + stateSourceObject.Load(7, &m.usageAS) + stateSourceObject.Load(8, &m.lockedAS) + stateSourceObject.Load(9, &m.dataAS) + stateSourceObject.Load(10, &m.defMLockMode) + stateSourceObject.Load(11, &m.pmas) + stateSourceObject.Load(12, &m.curRSS) + stateSourceObject.Load(13, &m.maxRSS) + stateSourceObject.Load(14, &m.argv) + stateSourceObject.Load(15, &m.envv) + stateSourceObject.Load(16, &m.auxv) + stateSourceObject.Load(17, &m.executable) + stateSourceObject.Load(18, &m.dumpability) + stateSourceObject.Load(19, &m.aioManager) + stateSourceObject.Load(20, &m.sleepForActivation) + stateSourceObject.Load(21, &m.vdsoSigReturnAddr) + stateSourceObject.Load(22, &m.membarrierPrivateEnabled) + stateSourceObject.AfterLoad(m.afterLoad) +} + +func (v *vma) StateTypeName() string { return "pkg/sentry/mm.vma" } -func (x *vma) StateFields() []string { +func (v *vma) StateFields() []string { return []string{ "mappable", "off", @@ -397,41 +397,41 @@ func (x *vma) StateFields() []string { } } -func (x *vma) beforeSave() {} +func (v *vma) beforeSave() {} -func (x *vma) StateSave(m state.Sink) { - x.beforeSave() - var realPerms int = x.saveRealPerms() - m.SaveValue(2, realPerms) - m.Save(0, &x.mappable) - m.Save(1, &x.off) - m.Save(3, &x.dontfork) - m.Save(4, &x.mlockMode) - m.Save(5, &x.numaPolicy) - m.Save(6, &x.numaNodemask) - m.Save(7, &x.id) - m.Save(8, &x.hint) +func (v *vma) StateSave(stateSinkObject state.Sink) { + v.beforeSave() + var realPermsValue int = v.saveRealPerms() + stateSinkObject.SaveValue(2, realPermsValue) + stateSinkObject.Save(0, &v.mappable) + stateSinkObject.Save(1, &v.off) + stateSinkObject.Save(3, &v.dontfork) + stateSinkObject.Save(4, &v.mlockMode) + stateSinkObject.Save(5, &v.numaPolicy) + stateSinkObject.Save(6, &v.numaNodemask) + stateSinkObject.Save(7, &v.id) + stateSinkObject.Save(8, &v.hint) } -func (x *vma) afterLoad() {} +func (v *vma) afterLoad() {} -func (x *vma) StateLoad(m state.Source) { - m.Load(0, &x.mappable) - m.Load(1, &x.off) - m.Load(3, &x.dontfork) - m.Load(4, &x.mlockMode) - m.Load(5, &x.numaPolicy) - m.Load(6, &x.numaNodemask) - m.Load(7, &x.id) - m.Load(8, &x.hint) - m.LoadValue(2, new(int), func(y interface{}) { x.loadRealPerms(y.(int)) }) +func (v *vma) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &v.mappable) + stateSourceObject.Load(1, &v.off) + stateSourceObject.Load(3, &v.dontfork) + stateSourceObject.Load(4, &v.mlockMode) + stateSourceObject.Load(5, &v.numaPolicy) + stateSourceObject.Load(6, &v.numaNodemask) + stateSourceObject.Load(7, &v.id) + stateSourceObject.Load(8, &v.hint) + stateSourceObject.LoadValue(2, new(int), func(y interface{}) { v.loadRealPerms(y.(int)) }) } -func (x *pma) StateTypeName() string { +func (p *pma) StateTypeName() string { return "pkg/sentry/mm.pma" } -func (x *pma) StateFields() []string { +func (p *pma) StateFields() []string { return []string{ "off", "translatePerms", @@ -442,81 +442,81 @@ func (x *pma) StateFields() []string { } } -func (x *pma) beforeSave() {} +func (p *pma) beforeSave() {} -func (x *pma) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.off) - m.Save(1, &x.translatePerms) - m.Save(2, &x.effectivePerms) - m.Save(3, &x.maxPerms) - m.Save(4, &x.needCOW) - m.Save(5, &x.private) +func (p *pma) StateSave(stateSinkObject state.Sink) { + p.beforeSave() + stateSinkObject.Save(0, &p.off) + stateSinkObject.Save(1, &p.translatePerms) + stateSinkObject.Save(2, &p.effectivePerms) + stateSinkObject.Save(3, &p.maxPerms) + stateSinkObject.Save(4, &p.needCOW) + stateSinkObject.Save(5, &p.private) } -func (x *pma) afterLoad() {} +func (p *pma) afterLoad() {} -func (x *pma) StateLoad(m state.Source) { - m.Load(0, &x.off) - m.Load(1, &x.translatePerms) - m.Load(2, &x.effectivePerms) - m.Load(3, &x.maxPerms) - m.Load(4, &x.needCOW) - m.Load(5, &x.private) +func (p *pma) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &p.off) + stateSourceObject.Load(1, &p.translatePerms) + stateSourceObject.Load(2, &p.effectivePerms) + stateSourceObject.Load(3, &p.maxPerms) + stateSourceObject.Load(4, &p.needCOW) + stateSourceObject.Load(5, &p.private) } -func (x *privateRefs) StateTypeName() string { +func (p *privateRefs) StateTypeName() string { return "pkg/sentry/mm.privateRefs" } -func (x *privateRefs) StateFields() []string { +func (p *privateRefs) StateFields() []string { return []string{ "refs", } } -func (x *privateRefs) beforeSave() {} +func (p *privateRefs) beforeSave() {} -func (x *privateRefs) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.refs) +func (p *privateRefs) StateSave(stateSinkObject state.Sink) { + p.beforeSave() + stateSinkObject.Save(0, &p.refs) } -func (x *privateRefs) afterLoad() {} +func (p *privateRefs) afterLoad() {} -func (x *privateRefs) StateLoad(m state.Source) { - m.Load(0, &x.refs) +func (p *privateRefs) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &p.refs) } -func (x *pmaSet) StateTypeName() string { +func (p *pmaSet) StateTypeName() string { return "pkg/sentry/mm.pmaSet" } -func (x *pmaSet) StateFields() []string { +func (p *pmaSet) StateFields() []string { return []string{ "root", } } -func (x *pmaSet) beforeSave() {} +func (p *pmaSet) beforeSave() {} -func (x *pmaSet) StateSave(m state.Sink) { - x.beforeSave() - var root *pmaSegmentDataSlices = x.saveRoot() - m.SaveValue(0, root) +func (p *pmaSet) StateSave(stateSinkObject state.Sink) { + p.beforeSave() + var rootValue *pmaSegmentDataSlices = p.saveRoot() + stateSinkObject.SaveValue(0, rootValue) } -func (x *pmaSet) afterLoad() {} +func (p *pmaSet) afterLoad() {} -func (x *pmaSet) StateLoad(m state.Source) { - m.LoadValue(0, new(*pmaSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*pmaSegmentDataSlices)) }) +func (p *pmaSet) StateLoad(stateSourceObject state.Source) { + stateSourceObject.LoadValue(0, new(*pmaSegmentDataSlices), func(y interface{}) { p.loadRoot(y.(*pmaSegmentDataSlices)) }) } -func (x *pmanode) StateTypeName() string { +func (p *pmanode) StateTypeName() string { return "pkg/sentry/mm.pmanode" } -func (x *pmanode) StateFields() []string { +func (p *pmanode) StateFields() []string { return []string{ "nrSegments", "parent", @@ -529,38 +529,38 @@ func (x *pmanode) StateFields() []string { } } -func (x *pmanode) beforeSave() {} +func (p *pmanode) beforeSave() {} -func (x *pmanode) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.nrSegments) - m.Save(1, &x.parent) - m.Save(2, &x.parentIndex) - m.Save(3, &x.hasChildren) - m.Save(4, &x.maxGap) - m.Save(5, &x.keys) - m.Save(6, &x.values) - m.Save(7, &x.children) +func (p *pmanode) StateSave(stateSinkObject state.Sink) { + p.beforeSave() + stateSinkObject.Save(0, &p.nrSegments) + stateSinkObject.Save(1, &p.parent) + stateSinkObject.Save(2, &p.parentIndex) + stateSinkObject.Save(3, &p.hasChildren) + stateSinkObject.Save(4, &p.maxGap) + stateSinkObject.Save(5, &p.keys) + stateSinkObject.Save(6, &p.values) + stateSinkObject.Save(7, &p.children) } -func (x *pmanode) afterLoad() {} +func (p *pmanode) afterLoad() {} -func (x *pmanode) StateLoad(m state.Source) { - m.Load(0, &x.nrSegments) - m.Load(1, &x.parent) - m.Load(2, &x.parentIndex) - m.Load(3, &x.hasChildren) - m.Load(4, &x.maxGap) - m.Load(5, &x.keys) - m.Load(6, &x.values) - m.Load(7, &x.children) +func (p *pmanode) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &p.nrSegments) + stateSourceObject.Load(1, &p.parent) + stateSourceObject.Load(2, &p.parentIndex) + stateSourceObject.Load(3, &p.hasChildren) + stateSourceObject.Load(4, &p.maxGap) + stateSourceObject.Load(5, &p.keys) + stateSourceObject.Load(6, &p.values) + stateSourceObject.Load(7, &p.children) } -func (x *pmaSegmentDataSlices) StateTypeName() string { +func (p *pmaSegmentDataSlices) StateTypeName() string { return "pkg/sentry/mm.pmaSegmentDataSlices" } -func (x *pmaSegmentDataSlices) StateFields() []string { +func (p *pmaSegmentDataSlices) StateFields() []string { return []string{ "Start", "End", @@ -568,28 +568,28 @@ func (x *pmaSegmentDataSlices) StateFields() []string { } } -func (x *pmaSegmentDataSlices) beforeSave() {} +func (p *pmaSegmentDataSlices) beforeSave() {} -func (x *pmaSegmentDataSlices) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.Start) - m.Save(1, &x.End) - m.Save(2, &x.Values) +func (p *pmaSegmentDataSlices) StateSave(stateSinkObject state.Sink) { + p.beforeSave() + stateSinkObject.Save(0, &p.Start) + stateSinkObject.Save(1, &p.End) + stateSinkObject.Save(2, &p.Values) } -func (x *pmaSegmentDataSlices) afterLoad() {} +func (p *pmaSegmentDataSlices) afterLoad() {} -func (x *pmaSegmentDataSlices) StateLoad(m state.Source) { - m.Load(0, &x.Start) - m.Load(1, &x.End) - m.Load(2, &x.Values) +func (p *pmaSegmentDataSlices) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &p.Start) + stateSourceObject.Load(1, &p.End) + stateSourceObject.Load(2, &p.Values) } -func (x *SpecialMappable) StateTypeName() string { +func (s *SpecialMappable) StateTypeName() string { return "pkg/sentry/mm.SpecialMappable" } -func (x *SpecialMappable) StateFields() []string { +func (s *SpecialMappable) StateFields() []string { return []string{ "SpecialMappableRefs", "mfp", @@ -598,77 +598,77 @@ func (x *SpecialMappable) StateFields() []string { } } -func (x *SpecialMappable) beforeSave() {} +func (s *SpecialMappable) beforeSave() {} -func (x *SpecialMappable) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.SpecialMappableRefs) - m.Save(1, &x.mfp) - m.Save(2, &x.fr) - m.Save(3, &x.name) +func (s *SpecialMappable) StateSave(stateSinkObject state.Sink) { + s.beforeSave() + stateSinkObject.Save(0, &s.SpecialMappableRefs) + stateSinkObject.Save(1, &s.mfp) + stateSinkObject.Save(2, &s.fr) + stateSinkObject.Save(3, &s.name) } -func (x *SpecialMappable) afterLoad() {} +func (s *SpecialMappable) afterLoad() {} -func (x *SpecialMappable) StateLoad(m state.Source) { - m.Load(0, &x.SpecialMappableRefs) - m.Load(1, &x.mfp) - m.Load(2, &x.fr) - m.Load(3, &x.name) +func (s *SpecialMappable) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &s.SpecialMappableRefs) + stateSourceObject.Load(1, &s.mfp) + stateSourceObject.Load(2, &s.fr) + stateSourceObject.Load(3, &s.name) } -func (x *SpecialMappableRefs) StateTypeName() string { +func (s *SpecialMappableRefs) StateTypeName() string { return "pkg/sentry/mm.SpecialMappableRefs" } -func (x *SpecialMappableRefs) StateFields() []string { +func (s *SpecialMappableRefs) StateFields() []string { return []string{ "refCount", } } -func (x *SpecialMappableRefs) beforeSave() {} +func (s *SpecialMappableRefs) beforeSave() {} -func (x *SpecialMappableRefs) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.refCount) +func (s *SpecialMappableRefs) StateSave(stateSinkObject state.Sink) { + s.beforeSave() + stateSinkObject.Save(0, &s.refCount) } -func (x *SpecialMappableRefs) afterLoad() {} +func (s *SpecialMappableRefs) afterLoad() {} -func (x *SpecialMappableRefs) StateLoad(m state.Source) { - m.Load(0, &x.refCount) +func (s *SpecialMappableRefs) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &s.refCount) } -func (x *vmaSet) StateTypeName() string { +func (v *vmaSet) StateTypeName() string { return "pkg/sentry/mm.vmaSet" } -func (x *vmaSet) StateFields() []string { +func (v *vmaSet) StateFields() []string { return []string{ "root", } } -func (x *vmaSet) beforeSave() {} +func (v *vmaSet) beforeSave() {} -func (x *vmaSet) StateSave(m state.Sink) { - x.beforeSave() - var root *vmaSegmentDataSlices = x.saveRoot() - m.SaveValue(0, root) +func (v *vmaSet) StateSave(stateSinkObject state.Sink) { + v.beforeSave() + var rootValue *vmaSegmentDataSlices = v.saveRoot() + stateSinkObject.SaveValue(0, rootValue) } -func (x *vmaSet) afterLoad() {} +func (v *vmaSet) afterLoad() {} -func (x *vmaSet) StateLoad(m state.Source) { - m.LoadValue(0, new(*vmaSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*vmaSegmentDataSlices)) }) +func (v *vmaSet) StateLoad(stateSourceObject state.Source) { + stateSourceObject.LoadValue(0, new(*vmaSegmentDataSlices), func(y interface{}) { v.loadRoot(y.(*vmaSegmentDataSlices)) }) } -func (x *vmanode) StateTypeName() string { +func (v *vmanode) StateTypeName() string { return "pkg/sentry/mm.vmanode" } -func (x *vmanode) StateFields() []string { +func (v *vmanode) StateFields() []string { return []string{ "nrSegments", "parent", @@ -681,38 +681,38 @@ func (x *vmanode) StateFields() []string { } } -func (x *vmanode) beforeSave() {} +func (v *vmanode) beforeSave() {} -func (x *vmanode) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.nrSegments) - m.Save(1, &x.parent) - m.Save(2, &x.parentIndex) - m.Save(3, &x.hasChildren) - m.Save(4, &x.maxGap) - m.Save(5, &x.keys) - m.Save(6, &x.values) - m.Save(7, &x.children) +func (v *vmanode) StateSave(stateSinkObject state.Sink) { + v.beforeSave() + stateSinkObject.Save(0, &v.nrSegments) + stateSinkObject.Save(1, &v.parent) + stateSinkObject.Save(2, &v.parentIndex) + stateSinkObject.Save(3, &v.hasChildren) + stateSinkObject.Save(4, &v.maxGap) + stateSinkObject.Save(5, &v.keys) + stateSinkObject.Save(6, &v.values) + stateSinkObject.Save(7, &v.children) } -func (x *vmanode) afterLoad() {} +func (v *vmanode) afterLoad() {} -func (x *vmanode) StateLoad(m state.Source) { - m.Load(0, &x.nrSegments) - m.Load(1, &x.parent) - m.Load(2, &x.parentIndex) - m.Load(3, &x.hasChildren) - m.Load(4, &x.maxGap) - m.Load(5, &x.keys) - m.Load(6, &x.values) - m.Load(7, &x.children) +func (v *vmanode) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &v.nrSegments) + stateSourceObject.Load(1, &v.parent) + stateSourceObject.Load(2, &v.parentIndex) + stateSourceObject.Load(3, &v.hasChildren) + stateSourceObject.Load(4, &v.maxGap) + stateSourceObject.Load(5, &v.keys) + stateSourceObject.Load(6, &v.values) + stateSourceObject.Load(7, &v.children) } -func (x *vmaSegmentDataSlices) StateTypeName() string { +func (v *vmaSegmentDataSlices) StateTypeName() string { return "pkg/sentry/mm.vmaSegmentDataSlices" } -func (x *vmaSegmentDataSlices) StateFields() []string { +func (v *vmaSegmentDataSlices) StateFields() []string { return []string{ "Start", "End", @@ -720,21 +720,21 @@ func (x *vmaSegmentDataSlices) StateFields() []string { } } -func (x *vmaSegmentDataSlices) beforeSave() {} +func (v *vmaSegmentDataSlices) beforeSave() {} -func (x *vmaSegmentDataSlices) StateSave(m state.Sink) { - x.beforeSave() - m.Save(0, &x.Start) - m.Save(1, &x.End) - m.Save(2, &x.Values) +func (v *vmaSegmentDataSlices) StateSave(stateSinkObject state.Sink) { + v.beforeSave() + stateSinkObject.Save(0, &v.Start) + stateSinkObject.Save(1, &v.End) + stateSinkObject.Save(2, &v.Values) } -func (x *vmaSegmentDataSlices) afterLoad() {} +func (v *vmaSegmentDataSlices) afterLoad() {} -func (x *vmaSegmentDataSlices) StateLoad(m state.Source) { - m.Load(0, &x.Start) - m.Load(1, &x.End) - m.Load(2, &x.Values) +func (v *vmaSegmentDataSlices) StateLoad(stateSourceObject state.Source) { + stateSourceObject.Load(0, &v.Start) + stateSourceObject.Load(1, &v.End) + stateSourceObject.Load(2, &v.Values) } func init() { diff --git a/pkg/sentry/mm/pma.go b/pkg/sentry/mm/pma.go index 30facebf7..7e5f7de64 100644 --- a/pkg/sentry/mm/pma.go +++ b/pkg/sentry/mm/pma.go @@ -36,7 +36,7 @@ import ( // * ar.Length() != 0. func (mm *MemoryManager) existingPMAsLocked(ar usermem.AddrRange, at usermem.AccessType, ignorePermissions bool, needInternalMappings bool) pmaIterator { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -100,7 +100,7 @@ func (mm *MemoryManager) existingVecPMAsLocked(ars usermem.AddrRangeSeq, at user // (i.e. permission checks must have been performed against vmas). func (mm *MemoryManager) getPMAsLocked(ctx context.Context, vseg vmaIterator, ar usermem.AddrRange, at usermem.AccessType) (pmaIterator, pmaGapIterator, error) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } if !vseg.Ok() { @@ -193,7 +193,7 @@ func (mm *MemoryManager) getVecPMAsLocked(ctx context.Context, ars usermem.AddrR // getVecPMAsLocked; other clients should call one of those instead. func (mm *MemoryManager) getPMAsInternalLocked(ctx context.Context, vseg vmaIterator, ar usermem.AddrRange, at usermem.AccessType) (pmaIterator, pmaGapIterator, error) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 || !ar.IsPageAligned() { + if !ar.WellFormed() || ar.Length() == 0 || !ar.IsPageAligned() { panic(fmt.Sprintf("invalid ar: %v", ar)) } if !vseg.Ok() { @@ -223,7 +223,7 @@ func (mm *MemoryManager) getPMAsInternalLocked(ctx context.Context, vseg vmaIter // Need a pma here. optAR := vseg.Range().Intersect(pgap.Range()) if checkInvariants { - if optAR.Length() <= 0 { + if optAR.Length() == 0 { panic(fmt.Sprintf("vseg %v and pgap %v do not overlap", vseg, pgap)) } } @@ -560,7 +560,7 @@ func (mm *MemoryManager) isPMACopyOnWriteLocked(vseg vmaIterator, pseg pmaIterat // Invalidate implements memmap.MappingSpace.Invalidate. func (mm *MemoryManager) Invalidate(ar usermem.AddrRange, opts memmap.InvalidateOpts) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 || !ar.IsPageAligned() { + if !ar.WellFormed() || ar.Length() == 0 || !ar.IsPageAligned() { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -583,7 +583,7 @@ func (mm *MemoryManager) Invalidate(ar usermem.AddrRange, opts memmap.Invalidate // * ar must be page-aligned. func (mm *MemoryManager) invalidateLocked(ar usermem.AddrRange, invalidatePrivate, invalidateShared bool) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 || !ar.IsPageAligned() { + if !ar.WellFormed() || ar.Length() == 0 || !ar.IsPageAligned() { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -629,7 +629,7 @@ func (mm *MemoryManager) invalidateLocked(ar usermem.AddrRange, invalidatePrivat // * ar must be page-aligned. func (mm *MemoryManager) Pin(ctx context.Context, ar usermem.AddrRange, at usermem.AccessType, ignorePermissions bool) ([]PinnedRange, error) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 || !ar.IsPageAligned() { + if !ar.WellFormed() || ar.Length() == 0 || !ar.IsPageAligned() { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -715,10 +715,10 @@ func Unpin(prs []PinnedRange) { // * oldAR and newAR must be page-aligned. func (mm *MemoryManager) movePMAsLocked(oldAR, newAR usermem.AddrRange) { if checkInvariants { - if !oldAR.WellFormed() || oldAR.Length() <= 0 || !oldAR.IsPageAligned() { + if !oldAR.WellFormed() || oldAR.Length() == 0 || !oldAR.IsPageAligned() { panic(fmt.Sprintf("invalid oldAR: %v", oldAR)) } - if !newAR.WellFormed() || newAR.Length() <= 0 || !newAR.IsPageAligned() { + if !newAR.WellFormed() || newAR.Length() == 0 || !newAR.IsPageAligned() { panic(fmt.Sprintf("invalid newAR: %v", newAR)) } if oldAR.Length() > newAR.Length() { @@ -778,7 +778,7 @@ func (mm *MemoryManager) movePMAsLocked(oldAR, newAR usermem.AddrRange) { // into mm.pmas. func (mm *MemoryManager) getPMAInternalMappingsLocked(pseg pmaIterator, ar usermem.AddrRange) (pmaGapIterator, error) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } if !pseg.Range().Contains(ar.Start) { @@ -831,7 +831,7 @@ func (mm *MemoryManager) getVecPMAInternalMappingsLocked(ars usermem.AddrRangeSe // * pseg.Range().Contains(ar.Start). func (mm *MemoryManager) internalMappingsLocked(pseg pmaIterator, ar usermem.AddrRange) safemem.BlockSeq { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } if !pseg.Range().Contains(ar.Start) { @@ -1050,7 +1050,7 @@ func (pseg pmaIterator) fileRangeOf(ar usermem.AddrRange) memmap.FileRange { if !pseg.Ok() { panic("terminal pma iterator") } - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } if !pseg.Range().IsSupersetOf(ar) { diff --git a/pkg/sentry/mm/vma.go b/pkg/sentry/mm/vma.go index f769d8294..b8df72813 100644 --- a/pkg/sentry/mm/vma.go +++ b/pkg/sentry/mm/vma.go @@ -266,7 +266,7 @@ func (mm *MemoryManager) mlockedBytesRangeLocked(ar usermem.AddrRange) uint64 { // * ar.Length() != 0. func (mm *MemoryManager) getVMAsLocked(ctx context.Context, ar usermem.AddrRange, at usermem.AccessType, ignorePermissions bool) (vmaIterator, vmaGapIterator, error) { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -350,7 +350,7 @@ const guardBytes = 256 * usermem.PageSize // * ar must be page-aligned. func (mm *MemoryManager) unmapLocked(ctx context.Context, ar usermem.AddrRange) vmaGapIterator { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 || !ar.IsPageAligned() { + if !ar.WellFormed() || ar.Length() == 0 || !ar.IsPageAligned() { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -371,7 +371,7 @@ func (mm *MemoryManager) unmapLocked(ctx context.Context, ar usermem.AddrRange) // * ar must be page-aligned. func (mm *MemoryManager) removeVMAsLocked(ctx context.Context, ar usermem.AddrRange) vmaGapIterator { if checkInvariants { - if !ar.WellFormed() || ar.Length() <= 0 || !ar.IsPageAligned() { + if !ar.WellFormed() || ar.Length() == 0 || !ar.IsPageAligned() { panic(fmt.Sprintf("invalid ar: %v", ar)) } } @@ -511,7 +511,7 @@ func (vseg vmaIterator) mappableRangeOf(ar usermem.AddrRange) memmap.MappableRan if vseg.ValuePtr().mappable == nil { panic("MappableRange is meaningless for anonymous vma") } - if !ar.WellFormed() || ar.Length() <= 0 { + if !ar.WellFormed() || ar.Length() == 0 { panic(fmt.Sprintf("invalid ar: %v", ar)) } if !vseg.Range().IsSupersetOf(ar) { @@ -536,7 +536,7 @@ func (vseg vmaIterator) addrRangeOf(mr memmap.MappableRange) usermem.AddrRange { if vseg.ValuePtr().mappable == nil { panic("MappableRange is meaningless for anonymous vma") } - if !mr.WellFormed() || mr.Length() <= 0 { + if !mr.WellFormed() || mr.Length() == 0 { panic(fmt.Sprintf("invalid mr: %v", mr)) } if !vseg.mappableRange().IsSupersetOf(mr) { |