7 Commits
Author SHA1 Message Date
Jamie LiuandgVisor bot b01944883b Add memmap.File.MemoryType()
This has no effect (outside of debug logging) until cl/723723715.

Updates #11436

PiperOrigin-RevId: 736686635
2025-03-13 17:08:52 -07:00
Jamie LiuandgVisor bot a5459a26cb Add memmap.MMapOpts.RequirePlatformEffect and use where appropriate.
Per the comment for vfs.GenericProxyDeviceConfigureMMap(), this ensures that if
invalid arguments are provided to application mmap() for a proxy device file,
then an error is returned immediately (from host mmap()) rather than when
demand paging causes host mmap() to be invoked.

PiperOrigin-RevId: 680733678
2024-09-30 15:13:16 -07:00
Jamie LiuandgVisor bot 86ceb5c26a Fix memmap.Translation.Perms returns.
memmap.Mappable.Translate() is passed a hostarch.AccessType indicating what
permissions are *immediately* required; it returns permissions in
memmap.Translation.Perms that are granted *to MM* until invalidation. MM
ensures that the permissions granted to the application are the intersection of
those granted by Translate, and those granted by VMA permissions; see
determination of pma.effectivePerms in
mm.MemoryManager.getPMAsInternalLocked(). This mechanism is used to avoid
marking pages dirty in the sentry's page cache for gofer-backed files until
PROT_WRITE pages are actually written to; see gofer.dentry.Translate(). In most
other cases, granting all supported permissions (to MM) up-front avoids a
redundant page fault for pages that are touched first for reading, and later
for writing.

Also:

- Prevent PROT_WRITE mappings of erofs files at mmap()/mprotect() time, rather
  than raising SIGBUS when writing to such mappings.

- Map nvproxy.frontendFD with PlatformEffectPopulate. This is the original goal
  of this CL; however, before this rest of this CL, MM.MMap() =>
  MM.populateVMAAndUnlock() => MM.getPMAsLocked(at=hostarch.NoAccess) =>
  MM.getPMAsInternalLocked(at=hostarch.NoAccess) =>
  nvproxy.frontendFD.Translate(at=hostarch.NoAccess) returns Translations with
  no permissions, causing MM.mapASLocked() to no-op.

PiperOrigin-RevId: 679360594
2024-09-26 17:59:37 -07:00
Jamie LiuandgVisor bot a50fb5ded0 Add memmap.File.DataFD().
This is used in cl/674746696 to ensure that users of MemoryFile data wait until
that data has been loaded.

PiperOrigin-RevId: 679255898
2024-09-26 12:51:20 -07:00
Jamie LiuandgVisor bot 8425e278c5 segment: add Set.Remove[Full]RangeWith()
These support the relatively common use case of removing all segments in a
given range (unconditionally) but doing something with them before they're
removed. This is always more compact, and may be slightly faster in some cases
(every replaced loop calls Isolate per iteration, while RemoveRangeWith avoids
redundant split checks between segments), at the cost of a direct function
call.

Also slightly optimize Set.LowerBoundSegmentSplitBefore() and
Set.UpperBoundSegmentSplitAfter() by inlining LowerBoundSegment and
UpperBoundSegment respectively; in the cases where Find() returns a
GapIterator, the segment that is returned doesn't need to be split since it
doesn't contain min/max respectively.

PiperOrigin-RevId: 675824581
2024-09-17 21:21:20 -07:00
Lucas ManningandgVisor bot 290789bab8 Refactor tpu chroot operations.
Ubuntu TPU images do not have the vfio-dev directories that COS images do,
so we need a more robust way of setting up the sandbox chroot to handle this
case. This change implements a way to get devices and minor numbers into the
sandbox with minimal support from the host filesystem and cleans up a few
methods to reflect their current usage.

Addresses #10795

PiperOrigin-RevId: 674363342
2024-09-13 11:15:28 -07:00
Lucas ManningandgVisor bot e29e270730 Reorganize tpuproxy code.
Now there is a main tpuproxy directory and two subdirs for each of the
different proxy implementations.

PiperOrigin-RevId: 667688748
2024-08-26 13:17:41 -07:00