summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-05-05 17:57:22 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-05 17:58:47 -0700
commit8416da33d25bf28cfcfdcbe658f696d6883eebcd (patch)
tree0d025395f1958daa40259b8394b1db1289628cb0 /pkg/sentry
parent9509c0b3886f29b488a62d0cc8edde9ccdefa335 (diff)
Internal change.
PiperOrigin-RevId: 310057834
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/pgalloc/pgalloc.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/sentry/pgalloc/pgalloc.go b/pkg/sentry/pgalloc/pgalloc.go
index 577e9306a..2b11ea4ae 100644
--- a/pkg/sentry/pgalloc/pgalloc.go
+++ b/pkg/sentry/pgalloc/pgalloc.go
@@ -180,6 +180,11 @@ type MemoryFileOpts struct {
// notifications to determine when eviction is necessary. This option has
// no effect unless DelayedEviction is DelayedEvictionEnabled.
UseHostMemcgPressure bool
+
+ // If ManualZeroing is true, MemoryFile must not assume that new pages
+ // obtained from the host are zero-filled, such that MemoryFile must manually
+ // zero newly-allocated pages.
+ ManualZeroing bool
}
// DelayedEvictionType is the type of MemoryFileOpts.DelayedEviction.
@@ -432,6 +437,15 @@ func (f *MemoryFile) Allocate(length uint64, kind usage.MemoryKind) (platform.Fi
// Mark selected pages as in use.
fr := platform.FileRange{start, end}
+ if f.opts.ManualZeroing {
+ if err := f.forEachMappingSlice(fr, func(bs []byte) {
+ for i := range bs {
+ bs[i] = 0
+ }
+ }); err != nil {
+ return platform.FileRange{}, err
+ }
+ }
if !f.usage.Add(fr, usageInfo{
kind: kind,
refs: 1,