summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-11-21 19:43:52 +0000
committergVisor bot <gvisor-bot@google.com>2019-11-21 19:43:52 +0000
commitb3f49ebd74ff30ad50b495ddd563ee5aa9cd2bca (patch)
treead383037abfddbfeb8a11229eb1637909b25002e
parent158f38053d931caf57b90bb0b496cf7d2ec4d42b (diff)
parentc0f89eba6ebdec08460bd796fc62d6aef674d141 (diff)
Merge release-20191114.0-18-gc0f89eb (automated)
-rwxr-xr-xpkg/flipcall/flipcall_unsafe.go10
-rw-r--r--pkg/sentry/fs/overlay.go4
-rwxr-xr-xpkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go20
-rw-r--r--pkg/sentry/kernel/task.go4
-rw-r--r--pkg/sentry/mm/mm.go6
-rwxr-xr-xpkg/sentry/time/seqatomic_parameters_unsafe.go20
-rwxr-xr-xpkg/sentry/vfs/mount_unsafe.go4
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/downgradable_rwmutex_1_12_unsafe.go (renamed from third_party/gvsync/downgradable_rwmutex_1_12_unsafe.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/downgradable_rwmutex_1_13_unsafe.go (renamed from third_party/gvsync/downgradable_rwmutex_1_13_unsafe.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/downgradable_rwmutex_unsafe.go (renamed from third_party/gvsync/downgradable_rwmutex_unsafe.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/memmove_unsafe.go (renamed from third_party/gvsync/memmove_unsafe.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/norace_unsafe.go (renamed from third_party/gvsync/norace_unsafe.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/race_unsafe.go (renamed from third_party/gvsync/race_unsafe.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/seqcount.go (renamed from third_party/gvsync/seqcount.go)2
-rwxr-xr-x[-rw-r--r--]pkg/syncutil/syncutil.go (renamed from third_party/gvsync/gvsync.go)4
-rwxr-xr-xpkg/syncutil/syncutil_state_autogen.go4
16 files changed, 47 insertions, 43 deletions
diff --git a/pkg/flipcall/flipcall_unsafe.go b/pkg/flipcall/flipcall_unsafe.go
index a37952637..27b8939fc 100755
--- a/pkg/flipcall/flipcall_unsafe.go
+++ b/pkg/flipcall/flipcall_unsafe.go
@@ -18,7 +18,7 @@ import (
"reflect"
"unsafe"
- "gvisor.dev/gvisor/third_party/gvsync"
+ "gvisor.dev/gvisor/pkg/syncutil"
)
// Packets consist of a 16-byte header followed by an arbitrarily-sized
@@ -75,13 +75,13 @@ func (ep *Endpoint) Data() []byte {
var ioSync int64
func raceBecomeActive() {
- if gvsync.RaceEnabled {
- gvsync.RaceAcquire((unsafe.Pointer)(&ioSync))
+ if syncutil.RaceEnabled {
+ syncutil.RaceAcquire((unsafe.Pointer)(&ioSync))
}
}
func raceBecomeInactive() {
- if gvsync.RaceEnabled {
- gvsync.RaceReleaseMerge((unsafe.Pointer)(&ioSync))
+ if syncutil.RaceEnabled {
+ syncutil.RaceReleaseMerge((unsafe.Pointer)(&ioSync))
}
}
diff --git a/pkg/sentry/fs/overlay.go b/pkg/sentry/fs/overlay.go
index 1d3ff39e0..25573e986 100644
--- a/pkg/sentry/fs/overlay.go
+++ b/pkg/sentry/fs/overlay.go
@@ -23,8 +23,8 @@ import (
"gvisor.dev/gvisor/pkg/sentry/context"
"gvisor.dev/gvisor/pkg/sentry/memmap"
"gvisor.dev/gvisor/pkg/sentry/usermem"
+ "gvisor.dev/gvisor/pkg/syncutil"
"gvisor.dev/gvisor/pkg/syserror"
- "gvisor.dev/gvisor/third_party/gvsync"
)
// The virtual filesystem implements an overlay configuration. For a high-level
@@ -199,7 +199,7 @@ type overlayEntry struct {
upper *Inode
// dirCacheMu protects dirCache.
- dirCacheMu gvsync.DowngradableRWMutex `state:"nosave"`
+ dirCacheMu syncutil.DowngradableRWMutex `state:"nosave"`
// dirCache is cache of DentAttrs from upper and lower Inodes.
dirCache *SortedDentryMap
diff --git a/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go b/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go
index 25ad17a4e..11e820656 100755
--- a/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go
+++ b/pkg/sentry/kernel/seqatomic_taskgoroutineschedinfo_unsafe.go
@@ -1,25 +1,25 @@
package kernel
import (
- "fmt"
- "reflect"
"strings"
"unsafe"
- "gvisor.dev/gvisor/third_party/gvsync"
+ "fmt"
+ "gvisor.dev/gvisor/pkg/syncutil"
+ "reflect"
)
// SeqAtomicLoad returns a copy of *ptr, ensuring that the read does not race
// with any writer critical sections in sc.
-func SeqAtomicLoadTaskGoroutineSchedInfo(sc *gvsync.SeqCount, ptr *TaskGoroutineSchedInfo) TaskGoroutineSchedInfo {
+func SeqAtomicLoadTaskGoroutineSchedInfo(sc *syncutil.SeqCount, ptr *TaskGoroutineSchedInfo) TaskGoroutineSchedInfo {
// This function doesn't use SeqAtomicTryLoad because doing so is
// measurably, significantly (~20%) slower; Go is awful at inlining.
var val TaskGoroutineSchedInfo
for {
epoch := sc.BeginRead()
- if gvsync.RaceEnabled {
+ if syncutil.RaceEnabled {
- gvsync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ syncutil.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
val = *ptr
@@ -35,10 +35,10 @@ func SeqAtomicLoadTaskGoroutineSchedInfo(sc *gvsync.SeqCount, ptr *TaskGoroutine
// in sc initiated by a call to sc.BeginRead() that returned epoch. If the read
// would race with a writer critical section, SeqAtomicTryLoad returns
// (unspecified, false).
-func SeqAtomicTryLoadTaskGoroutineSchedInfo(sc *gvsync.SeqCount, epoch gvsync.SeqCountEpoch, ptr *TaskGoroutineSchedInfo) (TaskGoroutineSchedInfo, bool) {
+func SeqAtomicTryLoadTaskGoroutineSchedInfo(sc *syncutil.SeqCount, epoch syncutil.SeqCountEpoch, ptr *TaskGoroutineSchedInfo) (TaskGoroutineSchedInfo, bool) {
var val TaskGoroutineSchedInfo
- if gvsync.RaceEnabled {
- gvsync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ if syncutil.RaceEnabled {
+ syncutil.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
val = *ptr
}
@@ -49,7 +49,7 @@ func initTaskGoroutineSchedInfo() {
var val TaskGoroutineSchedInfo
typ := reflect.TypeOf(val)
name := typ.Name()
- if ptrs := gvsync.PointersInType(typ, name); len(ptrs) != 0 {
+ if ptrs := syncutil.PointersInType(typ, name); len(ptrs) != 0 {
panic(fmt.Sprintf("SeqAtomicLoad<%s> is invalid since values %s of type %s contain pointers:\n%s", typ, name, typ, strings.Join(ptrs, "\n")))
}
}
diff --git a/pkg/sentry/kernel/task.go b/pkg/sentry/kernel/task.go
index 9be3dae3c..80c8e5464 100644
--- a/pkg/sentry/kernel/task.go
+++ b/pkg/sentry/kernel/task.go
@@ -35,8 +35,8 @@ import (
"gvisor.dev/gvisor/pkg/sentry/uniqueid"
"gvisor.dev/gvisor/pkg/sentry/usage"
"gvisor.dev/gvisor/pkg/sentry/usermem"
+ "gvisor.dev/gvisor/pkg/syncutil"
"gvisor.dev/gvisor/pkg/waiter"
- "gvisor.dev/gvisor/third_party/gvsync"
)
// Task represents a thread of execution in the untrusted app. It
@@ -83,7 +83,7 @@ type Task struct {
//
// gosched is protected by goschedSeq. gosched is owned by the task
// goroutine.
- goschedSeq gvsync.SeqCount `state:"nosave"`
+ goschedSeq syncutil.SeqCount `state:"nosave"`
gosched TaskGoroutineSchedInfo
// yieldCount is the number of times the task goroutine has called
diff --git a/pkg/sentry/mm/mm.go b/pkg/sentry/mm/mm.go
index f350e0109..58a5c186d 100644
--- a/pkg/sentry/mm/mm.go
+++ b/pkg/sentry/mm/mm.go
@@ -44,7 +44,7 @@ import (
"gvisor.dev/gvisor/pkg/sentry/platform"
"gvisor.dev/gvisor/pkg/sentry/safemem"
"gvisor.dev/gvisor/pkg/sentry/usermem"
- "gvisor.dev/gvisor/third_party/gvsync"
+ "gvisor.dev/gvisor/pkg/syncutil"
)
// MemoryManager implements a virtual address space.
@@ -82,7 +82,7 @@ type MemoryManager struct {
users int32
// mappingMu is analogous to Linux's struct mm_struct::mmap_sem.
- mappingMu gvsync.DowngradableRWMutex `state:"nosave"`
+ mappingMu syncutil.DowngradableRWMutex `state:"nosave"`
// vmas stores virtual memory areas. Since vmas are stored by value,
// clients should usually use vmaIterator.ValuePtr() instead of
@@ -125,7 +125,7 @@ type MemoryManager struct {
// activeMu is loosely analogous to Linux's struct
// mm_struct::page_table_lock.
- activeMu gvsync.DowngradableRWMutex `state:"nosave"`
+ activeMu syncutil.DowngradableRWMutex `state:"nosave"`
// pmas stores platform mapping areas used to implement vmas. Since pmas
// are stored by value, clients should usually use pmaIterator.ValuePtr()
diff --git a/pkg/sentry/time/seqatomic_parameters_unsafe.go b/pkg/sentry/time/seqatomic_parameters_unsafe.go
index 89792c56d..e3c134e49 100755
--- a/pkg/sentry/time/seqatomic_parameters_unsafe.go
+++ b/pkg/sentry/time/seqatomic_parameters_unsafe.go
@@ -1,25 +1,25 @@
package time
import (
- "fmt"
- "reflect"
"strings"
"unsafe"
- "gvisor.dev/gvisor/third_party/gvsync"
+ "fmt"
+ "gvisor.dev/gvisor/pkg/syncutil"
+ "reflect"
)
// SeqAtomicLoad returns a copy of *ptr, ensuring that the read does not race
// with any writer critical sections in sc.
-func SeqAtomicLoadParameters(sc *gvsync.SeqCount, ptr *Parameters) Parameters {
+func SeqAtomicLoadParameters(sc *syncutil.SeqCount, ptr *Parameters) Parameters {
// This function doesn't use SeqAtomicTryLoad because doing so is
// measurably, significantly (~20%) slower; Go is awful at inlining.
var val Parameters
for {
epoch := sc.BeginRead()
- if gvsync.RaceEnabled {
+ if syncutil.RaceEnabled {
- gvsync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ syncutil.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
val = *ptr
@@ -35,10 +35,10 @@ func SeqAtomicLoadParameters(sc *gvsync.SeqCount, ptr *Parameters) Parameters {
// in sc initiated by a call to sc.BeginRead() that returned epoch. If the read
// would race with a writer critical section, SeqAtomicTryLoad returns
// (unspecified, false).
-func SeqAtomicTryLoadParameters(sc *gvsync.SeqCount, epoch gvsync.SeqCountEpoch, ptr *Parameters) (Parameters, bool) {
+func SeqAtomicTryLoadParameters(sc *syncutil.SeqCount, epoch syncutil.SeqCountEpoch, ptr *Parameters) (Parameters, bool) {
var val Parameters
- if gvsync.RaceEnabled {
- gvsync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
+ if syncutil.RaceEnabled {
+ syncutil.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val))
} else {
val = *ptr
}
@@ -49,7 +49,7 @@ func initParameters() {
var val Parameters
typ := reflect.TypeOf(val)
name := typ.Name()
- if ptrs := gvsync.PointersInType(typ, name); len(ptrs) != 0 {
+ if ptrs := syncutil.PointersInType(typ, name); len(ptrs) != 0 {
panic(fmt.Sprintf("SeqAtomicLoad<%s> is invalid since values %s of type %s contain pointers:\n%s", typ, name, typ, strings.Join(ptrs, "\n")))
}
}
diff --git a/pkg/sentry/vfs/mount_unsafe.go b/pkg/sentry/vfs/mount_unsafe.go
index 75e6c7dfa..c98b42f91 100755
--- a/pkg/sentry/vfs/mount_unsafe.go
+++ b/pkg/sentry/vfs/mount_unsafe.go
@@ -26,7 +26,7 @@ import (
"sync/atomic"
"unsafe"
- "gvisor.dev/gvisor/third_party/gvsync"
+ "gvisor.dev/gvisor/pkg/syncutil"
)
// mountKey represents the location at which a Mount is mounted. It is
@@ -72,7 +72,7 @@ type mountTable struct {
// intrinsics and inline assembly, limiting the performance of this
// approach.)
- seq gvsync.SeqCount
+ seq syncutil.SeqCount
seed uint32 // for hashing keys
// size holds both length (number of elements) and capacity (number of
diff --git a/third_party/gvsync/downgradable_rwmutex_1_12_unsafe.go b/pkg/syncutil/downgradable_rwmutex_1_12_unsafe.go
index 855b2a2b1..7c6336e62 100644..100755
--- a/third_party/gvsync/downgradable_rwmutex_1_12_unsafe.go
+++ b/pkg/syncutil/downgradable_rwmutex_1_12_unsafe.go
@@ -8,7 +8,7 @@
// TODO(b/133868570): Delete once Go 1.12 is no longer supported.
-package gvsync
+package syncutil
import _ "unsafe"
diff --git a/third_party/gvsync/downgradable_rwmutex_1_13_unsafe.go b/pkg/syncutil/downgradable_rwmutex_1_13_unsafe.go
index 3b9346843..3c3673119 100644..100755
--- a/third_party/gvsync/downgradable_rwmutex_1_13_unsafe.go
+++ b/pkg/syncutil/downgradable_rwmutex_1_13_unsafe.go
@@ -8,7 +8,7 @@
// Check go:linkname function signatures when updating Go version.
-package gvsync
+package syncutil
import _ "unsafe"
diff --git a/third_party/gvsync/downgradable_rwmutex_unsafe.go b/pkg/syncutil/downgradable_rwmutex_unsafe.go
index b7862d185..07feca402 100644..100755
--- a/third_party/gvsync/downgradable_rwmutex_unsafe.go
+++ b/pkg/syncutil/downgradable_rwmutex_unsafe.go
@@ -16,7 +16,7 @@
// - RUnlock -> Lock (via writerSem)
// - DowngradeLock -> RLock (via readerSem)
-package gvsync
+package syncutil
import (
"sync"
diff --git a/third_party/gvsync/memmove_unsafe.go b/pkg/syncutil/memmove_unsafe.go
index 9dd1d6142..348675baa 100644..100755
--- a/third_party/gvsync/memmove_unsafe.go
+++ b/pkg/syncutil/memmove_unsafe.go
@@ -8,7 +8,7 @@
// Check go:linkname function signatures when updating Go version.
-package gvsync
+package syncutil
import (
"unsafe"
diff --git a/third_party/gvsync/norace_unsafe.go b/pkg/syncutil/norace_unsafe.go
index e3852db8c..0a0a9deda 100644..100755
--- a/third_party/gvsync/norace_unsafe.go
+++ b/pkg/syncutil/norace_unsafe.go
@@ -5,7 +5,7 @@
// +build !race
-package gvsync
+package syncutil
import (
"unsafe"
diff --git a/third_party/gvsync/race_unsafe.go b/pkg/syncutil/race_unsafe.go
index 13c02a830..206067ec1 100644..100755
--- a/third_party/gvsync/race_unsafe.go
+++ b/pkg/syncutil/race_unsafe.go
@@ -5,7 +5,7 @@
// +build race
-package gvsync
+package syncutil
import (
"runtime"
diff --git a/third_party/gvsync/seqcount.go b/pkg/syncutil/seqcount.go
index 2c9c2c3d6..11d8dbfaa 100644..100755
--- a/third_party/gvsync/seqcount.go
+++ b/pkg/syncutil/seqcount.go
@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package gvsync
+package syncutil
import (
"fmt"
diff --git a/third_party/gvsync/gvsync.go b/pkg/syncutil/syncutil.go
index 3bbef13c3..66e750d06 100644..100755
--- a/third_party/gvsync/gvsync.go
+++ b/pkg/syncutil/syncutil.go
@@ -3,5 +3,5 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package gvsync provides synchronization primitives.
-package gvsync
+// Package syncutil provides synchronization primitives.
+package syncutil
diff --git a/pkg/syncutil/syncutil_state_autogen.go b/pkg/syncutil/syncutil_state_autogen.go
new file mode 100755
index 000000000..f46e00edf
--- /dev/null
+++ b/pkg/syncutil/syncutil_state_autogen.go
@@ -0,0 +1,4 @@
+// automatically generated by stateify.
+
+package syncutil
+