diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/fs/lock/lock_range.go | 14 | ||||
-rw-r--r-- | pkg/sentry/kernel/auth/id_map_range.go | 14 | ||||
-rw-r--r-- | pkg/sentry/memmap/file_range.go | 14 | ||||
-rw-r--r-- | pkg/sentry/memmap/mappable_range.go | 14 | ||||
-rw-r--r-- | pkg/sentry/pgalloc/evictable_range.go | 14 | ||||
-rw-r--r-- | pkg/state/addr_range.go | 14 | ||||
-rw-r--r-- | pkg/usermem/addr_range.go | 14 |
7 files changed, 98 insertions, 0 deletions
diff --git a/pkg/sentry/fs/lock/lock_range.go b/pkg/sentry/fs/lock/lock_range.go index 7a6f77640..13a2cce6e 100644 --- a/pkg/sentry/fs/lock/lock_range.go +++ b/pkg/sentry/fs/lock/lock_range.go @@ -13,27 +13,37 @@ type LockRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r LockRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r LockRange) Length() uint64 { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r LockRange) Contains(x uint64) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r LockRange) Overlaps(r2 LockRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r LockRange) IsSupersetOf(r2 LockRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r LockRange) IsSupersetOf(r2 LockRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r LockRange) Intersect(r2 LockRange) LockRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r LockRange) Intersect(r2 LockRange) LockRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r LockRange) CanSplitAt(x uint64) bool { return r.Contains(x) && r.Start < x } diff --git a/pkg/sentry/kernel/auth/id_map_range.go b/pkg/sentry/kernel/auth/id_map_range.go index 833fa3518..19d542716 100644 --- a/pkg/sentry/kernel/auth/id_map_range.go +++ b/pkg/sentry/kernel/auth/id_map_range.go @@ -13,27 +13,37 @@ type idMapRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r idMapRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r idMapRange) Length() uint32 { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r idMapRange) Contains(x uint32) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r idMapRange) Overlaps(r2 idMapRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r idMapRange) IsSupersetOf(r2 idMapRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r idMapRange) IsSupersetOf(r2 idMapRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r idMapRange) Intersect(r2 idMapRange) idMapRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r idMapRange) Intersect(r2 idMapRange) idMapRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r idMapRange) CanSplitAt(x uint32) bool { return r.Contains(x) && r.Start < x } diff --git a/pkg/sentry/memmap/file_range.go b/pkg/sentry/memmap/file_range.go index e4c852a66..6f0b4bde4 100644 --- a/pkg/sentry/memmap/file_range.go +++ b/pkg/sentry/memmap/file_range.go @@ -13,27 +13,37 @@ type FileRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r FileRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r FileRange) Length() uint64 { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r FileRange) Contains(x uint64) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r FileRange) Overlaps(r2 FileRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r FileRange) IsSupersetOf(r2 FileRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r FileRange) IsSupersetOf(r2 FileRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r FileRange) Intersect(r2 FileRange) FileRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r FileRange) Intersect(r2 FileRange) FileRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r FileRange) CanSplitAt(x uint64) bool { return r.Contains(x) && r.Start < x } diff --git a/pkg/sentry/memmap/mappable_range.go b/pkg/sentry/memmap/mappable_range.go index 6b6c2c685..7b7312cb6 100644 --- a/pkg/sentry/memmap/mappable_range.go +++ b/pkg/sentry/memmap/mappable_range.go @@ -13,27 +13,37 @@ type MappableRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r MappableRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r MappableRange) Length() uint64 { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r MappableRange) Contains(x uint64) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r MappableRange) Overlaps(r2 MappableRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r MappableRange) IsSupersetOf(r2 MappableRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r MappableRange) IsSupersetOf(r2 MappableRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r MappableRange) Intersect(r2 MappableRange) MappableRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r MappableRange) Intersect(r2 MappableRange) MappableRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r MappableRange) CanSplitAt(x uint64) bool { return r.Contains(x) && r.Start < x } diff --git a/pkg/sentry/pgalloc/evictable_range.go b/pkg/sentry/pgalloc/evictable_range.go index 10ce2ff44..79f513ac2 100644 --- a/pkg/sentry/pgalloc/evictable_range.go +++ b/pkg/sentry/pgalloc/evictable_range.go @@ -13,27 +13,37 @@ type EvictableRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r EvictableRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r EvictableRange) Length() uint64 { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r EvictableRange) Contains(x uint64) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r EvictableRange) Overlaps(r2 EvictableRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r EvictableRange) IsSupersetOf(r2 EvictableRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r EvictableRange) IsSupersetOf(r2 EvictableRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r EvictableRange) Intersect(r2 EvictableRange) EvictableRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r EvictableRange) Intersect(r2 EvictableRange) EvictableRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r EvictableRange) CanSplitAt(x uint64) bool { return r.Contains(x) && r.Start < x } diff --git a/pkg/state/addr_range.go b/pkg/state/addr_range.go index 45720c643..0b7346e47 100644 --- a/pkg/state/addr_range.go +++ b/pkg/state/addr_range.go @@ -13,27 +13,37 @@ type addrRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r addrRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r addrRange) Length() uintptr { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r addrRange) Contains(x uintptr) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r addrRange) Overlaps(r2 addrRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r addrRange) IsSupersetOf(r2 addrRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r addrRange) IsSupersetOf(r2 addrRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r addrRange) Intersect(r2 addrRange) addrRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r addrRange) Intersect(r2 addrRange) addrRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r addrRange) CanSplitAt(x uintptr) bool { return r.Contains(x) && r.Start < x } diff --git a/pkg/usermem/addr_range.go b/pkg/usermem/addr_range.go index 152ed1434..6e030127b 100644 --- a/pkg/usermem/addr_range.go +++ b/pkg/usermem/addr_range.go @@ -13,27 +13,37 @@ type AddrRange struct { // WellFormed returns true if r.Start <= r.End. All other methods on a Range // require that the Range is well-formed. +// +//go:nosplit func (r AddrRange) WellFormed() bool { return r.Start <= r.End } // Length returns the length of the range. +// +//go:nosplit func (r AddrRange) Length() Addr { return r.End - r.Start } // Contains returns true if r contains x. +// +//go:nosplit func (r AddrRange) Contains(x Addr) bool { return r.Start <= x && x < r.End } // Overlaps returns true if r and r2 overlap. +// +//go:nosplit func (r AddrRange) Overlaps(r2 AddrRange) bool { return r.Start < r2.End && r2.Start < r.End } // IsSupersetOf returns true if r is a superset of r2; that is, the range r2 is // contained within r. +// +//go:nosplit func (r AddrRange) IsSupersetOf(r2 AddrRange) bool { return r.Start <= r2.Start && r.End >= r2.End } @@ -41,6 +51,8 @@ func (r AddrRange) IsSupersetOf(r2 AddrRange) bool { // Intersect returns a range consisting of the intersection between r and r2. // If r and r2 do not overlap, Intersect returns a range with unspecified // bounds, but for which Length() == 0. +// +//go:nosplit func (r AddrRange) Intersect(r2 AddrRange) AddrRange { if r.Start < r2.Start { r.Start = r2.Start @@ -57,6 +69,8 @@ func (r AddrRange) Intersect(r2 AddrRange) AddrRange { // CanSplitAt returns true if it is legal to split a segment spanning the range // r at x; that is, splitting at x would produce two ranges, both of which have // non-zero length. +// +//go:nosplit func (r AddrRange) CanSplitAt(x Addr) bool { return r.Contains(x) && r.Start < x } |