diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-10-06 20:58:25 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-10-06 20:58:25 +0000 |
commit | 2eb23dc26e781a4257c3b2e15d379f19ee564bc4 (patch) | |
tree | c421bae79411ba0d375617f1f33ff0241c466428 /pkg/sentry/mm | |
parent | d4b4f987ea7705c819cd9da8ca9529784a30d745 (diff) | |
parent | 1336af78d5dc2a6bc54d22ed45f4dd4793c2f964 (diff) |
Merge release-20200928.0-55-g1336af78d (automated)
Diffstat (limited to 'pkg/sentry/mm')
-rw-r--r-- | pkg/sentry/mm/mm.go | 8 | ||||
-rw-r--r-- | pkg/sentry/mm/mm_state_autogen.go | 3 | ||||
-rw-r--r-- | pkg/sentry/mm/syscalls.go | 13 |
3 files changed, 24 insertions, 0 deletions
diff --git a/pkg/sentry/mm/mm.go b/pkg/sentry/mm/mm.go index 8c9f11cce..43567b92c 100644 --- a/pkg/sentry/mm/mm.go +++ b/pkg/sentry/mm/mm.go @@ -235,6 +235,14 @@ type MemoryManager struct { // vdsoSigReturnAddr is the address of 'vdso_sigreturn'. vdsoSigReturnAddr uint64 + + // membarrierPrivateEnabled is non-zero if EnableMembarrierPrivate has + // previously been called. Since, as of this writing, + // MEMBARRIER_CMD_PRIVATE_EXPEDITED is implemented as a global memory + // barrier, membarrierPrivateEnabled has no other effect. + // + // membarrierPrivateEnabled is accessed using atomic memory operations. + membarrierPrivateEnabled uint32 } // vma represents a virtual memory area. diff --git a/pkg/sentry/mm/mm_state_autogen.go b/pkg/sentry/mm/mm_state_autogen.go index 8ab51450c..a4e826a4f 100644 --- a/pkg/sentry/mm/mm_state_autogen.go +++ b/pkg/sentry/mm/mm_state_autogen.go @@ -315,6 +315,7 @@ func (x *MemoryManager) StateFields() []string { "aioManager", "sleepForActivation", "vdsoSigReturnAddr", + "membarrierPrivateEnabled", } } @@ -348,6 +349,7 @@ func (x *MemoryManager) StateSave(m state.Sink) { 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) { @@ -373,6 +375,7 @@ func (x *MemoryManager) StateLoad(m state.Source) { m.Load(19, &x.aioManager) m.Load(20, &x.sleepForActivation) m.Load(21, &x.vdsoSigReturnAddr) + m.Load(22, &x.membarrierPrivateEnabled) m.AfterLoad(x.afterLoad) } diff --git a/pkg/sentry/mm/syscalls.go b/pkg/sentry/mm/syscalls.go index a2555ba1a..0a66b1cdd 100644 --- a/pkg/sentry/mm/syscalls.go +++ b/pkg/sentry/mm/syscalls.go @@ -17,6 +17,7 @@ package mm import ( "fmt" mrand "math/rand" + "sync/atomic" "gvisor.dev/gvisor/pkg/abi/linux" "gvisor.dev/gvisor/pkg/context" @@ -1274,3 +1275,15 @@ func (mm *MemoryManager) VirtualDataSize() uint64 { defer mm.mappingMu.RUnlock() return mm.dataAS } + +// EnableMembarrierPrivate causes future calls to IsMembarrierPrivateEnabled to +// return true. +func (mm *MemoryManager) EnableMembarrierPrivate() { + atomic.StoreUint32(&mm.membarrierPrivateEnabled, 1) +} + +// IsMembarrierPrivateEnabled returns true if mm.EnableMembarrierPrivate() has +// previously been called. +func (mm *MemoryManager) IsMembarrierPrivateEnabled() bool { + return atomic.LoadUint32(&mm.membarrierPrivateEnabled) != 0 +} |