summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/mm/address_space.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/mm/address_space.go')
-rw-r--r--pkg/sentry/mm/address_space.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/sentry/mm/address_space.go b/pkg/sentry/mm/address_space.go
index e7aa24c69..7488f7c4a 100644
--- a/pkg/sentry/mm/address_space.go
+++ b/pkg/sentry/mm/address_space.go
@@ -149,7 +149,7 @@ func (mm *MemoryManager) Deactivate() {
// for all addresses in ar should be precommitted.
//
// Preconditions: mm.activeMu must be locked. mm.as != nil. ar.Length() != 0.
-// ar must be page-aligned. pseg == mm.pmas.LowerBoundSegment(ar.Start).
+// ar must be page-aligned. pseg.Range().Contains(ar.Start).
func (mm *MemoryManager) mapASLocked(pseg pmaIterator, ar usermem.AddrRange, precommit bool) error {
// By default, map entire pmas at a time, under the assumption that there
// is no cost to mapping more of a pma than necessary.
@@ -173,9 +173,7 @@ func (mm *MemoryManager) mapASLocked(pseg pmaIterator, ar usermem.AddrRange, pre
}
}
- // Since this checks ar.End and not mapAR.End, we will never map a pma that
- // is not required.
- for pseg.Ok() && pseg.Start() < ar.End {
+ for {
pma := pseg.ValuePtr()
pmaAR := pseg.Range()
pmaMapAR := pmaAR.Intersect(mapAR)
@@ -186,9 +184,13 @@ func (mm *MemoryManager) mapASLocked(pseg pmaIterator, ar usermem.AddrRange, pre
if err := pma.file.MapInto(mm.as, pmaMapAR.Start, pseg.fileRangeOf(pmaMapAR), perms, precommit); err != nil {
return err
}
+ // Since this checks ar.End and not mapAR.End, we will never map a pma
+ // that is not required.
+ if ar.End <= pmaAR.End {
+ return nil
+ }
pseg = pseg.NextSegment()
}
- return nil
}
// unmapASLocked removes all AddressSpace mappings for addresses in ar.