summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-05-11 12:23:25 -0700
committerShentubot <shentubot@google.com>2018-05-11 12:24:15 -0700
commit8deabbaae1fc45b042d551891080deef866dc0f8 (patch)
tree23aff1527fcb4f352a639159b693264d1ddd0c4b /pkg
parent12c161f27865d0e389cd593c669bd740d7f24692 (diff)
Remove error return from AddressSpace.Release()
PiperOrigin-RevId: 196291289 Change-Id: Ie3487be029850b0b410b82416750853a6c4a2b00
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/kernel/task_usermem.go4
-rw-r--r--pkg/sentry/mm/address_space.go17
-rw-r--r--pkg/sentry/platform/kvm/address_space.go3
-rw-r--r--pkg/sentry/platform/platform.go2
-rw-r--r--pkg/sentry/platform/ptrace/subprocess.go3
5 files changed, 10 insertions, 19 deletions
diff --git a/pkg/sentry/kernel/task_usermem.go b/pkg/sentry/kernel/task_usermem.go
index 7a62ab674..54964dd0d 100644
--- a/pkg/sentry/kernel/task_usermem.go
+++ b/pkg/sentry/kernel/task_usermem.go
@@ -39,9 +39,7 @@ func (t *Task) Activate() {
// Deactivate relinquishes the task's active address space.
func (t *Task) Deactivate() {
if mm := t.MemoryManager(); mm != nil {
- if err := mm.Deactivate(); err != nil {
- panic("unable to deactivate mm: " + err.Error())
- }
+ mm.Deactivate()
}
}
diff --git a/pkg/sentry/mm/address_space.go b/pkg/sentry/mm/address_space.go
index 4dd67b1ea..27554f163 100644
--- a/pkg/sentry/mm/address_space.go
+++ b/pkg/sentry/mm/address_space.go
@@ -114,12 +114,12 @@ func (mm *MemoryManager) Activate() error {
}
}
-// Deactivate releases a release to the MemoryManager.
-func (mm *MemoryManager) Deactivate() error {
+// Deactivate releases a reference to the MemoryManager.
+func (mm *MemoryManager) Deactivate() {
// Fast path: this is not the last goroutine to deactivate the
// MemoryManager.
if atomicbitops.DecUnlessOneInt32(&mm.active) {
- return nil
+ return
}
mm.activeMu.Lock()
@@ -128,26 +128,21 @@ func (mm *MemoryManager) Deactivate() error {
// Still active?
if atomic.AddInt32(&mm.active, -1) > 0 {
mm.activeMu.Unlock()
- return nil
+ return
}
// Can we hold on to the address space?
if !mm.p.CooperativelySchedulesAddressSpace() {
mm.activeMu.Unlock()
- return nil
+ return
}
// Release the address space.
- if err := mm.as.Release(); err != nil {
- atomic.StoreInt32(&mm.active, 1)
- mm.activeMu.Unlock()
- return err
- }
+ mm.as.Release()
// Lost it.
mm.as = nil
mm.activeMu.Unlock()
- return nil
}
// mapASLocked maps addresses in ar into mm.as. If precommit is true, mappings
diff --git a/pkg/sentry/platform/kvm/address_space.go b/pkg/sentry/platform/kvm/address_space.go
index a4b9198cc..173885867 100644
--- a/pkg/sentry/platform/kvm/address_space.go
+++ b/pkg/sentry/platform/kvm/address_space.go
@@ -200,8 +200,7 @@ func (as *addressSpace) Unmap(addr usermem.Addr, length uint64) {
}
// Release releases the page tables.
-func (as *addressSpace) Release() error {
+func (as *addressSpace) Release() {
as.Unmap(0, ^uint64(0))
as.pageTables.Release()
- return nil
}
diff --git a/pkg/sentry/platform/platform.go b/pkg/sentry/platform/platform.go
index 6219dada7..1c385bc5a 100644
--- a/pkg/sentry/platform/platform.go
+++ b/pkg/sentry/platform/platform.go
@@ -205,7 +205,7 @@ type AddressSpace interface {
// Release releases this address space. After releasing, a new AddressSpace
// must be acquired via platform.NewAddressSpace().
- Release() error
+ Release()
// AddressSpaceIO methods are supported iff the associated platform's
// Platform.SupportsAddressSpaceIO() == true. AddressSpaces for which this
diff --git a/pkg/sentry/platform/ptrace/subprocess.go b/pkg/sentry/platform/ptrace/subprocess.go
index 0d6a38f15..035ebc332 100644
--- a/pkg/sentry/platform/ptrace/subprocess.go
+++ b/pkg/sentry/platform/ptrace/subprocess.go
@@ -242,14 +242,13 @@ func (s *subprocess) unmap() {
// Therefore we simply unmap everything in the subprocess and return it to the
// globalPool. This has the added benefit of reducing creation time for new
// subprocesses.
-func (s *subprocess) Release() error {
+func (s *subprocess) Release() {
go func() { // S/R-SAFE: Platform.
s.unmap()
globalPool.mu.Lock()
globalPool.available = append(globalPool.available, s)
globalPool.mu.Unlock()
}()
- return nil
}
// newThread creates a new traced thread.