diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-05-27 17:51:40 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-27 17:51:40 +0000 |
commit | 84452958e1397b337a806f815e07ae69c4f4c896 (patch) | |
tree | 138422671bc14bd0c66f83c31be1a991888f3359 /pkg/usermem | |
parent | bae1520437ecbd3dd217880cb51eb24b59d26f51 (diff) | |
parent | 0bc022b7f3c13bb7c5c8d47d1781820161e7b1ad (diff) |
Merge release-20200518.0-45-g0bc022b7 (automated)
Diffstat (limited to 'pkg/usermem')
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/access_type.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/addr.go | 17 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/addr_range.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/addr_range_seq_unsafe.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/bytes_io.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/bytes_io_unsafe.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem_arm64.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem_arm64_state_autogen.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem_state_autogen.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem_unsafe_state_autogen.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem_x86.go | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | pkg/usermem/usermem_x86_state_autogen.go | 0 |
13 files changed, 17 insertions, 0 deletions
diff --git a/pkg/usermem/access_type.go b/pkg/usermem/access_type.go index 9c1742a59..9c1742a59 100755..100644 --- a/pkg/usermem/access_type.go +++ b/pkg/usermem/access_type.go diff --git a/pkg/usermem/addr.go b/pkg/usermem/addr.go index e79210804..c4100481e 100755..100644 --- a/pkg/usermem/addr.go +++ b/pkg/usermem/addr.go @@ -106,3 +106,20 @@ func (ar AddrRange) IsPageAligned() bool { func (ar AddrRange) String() string { return fmt.Sprintf("[%#x, %#x)", ar.Start, ar.End) } + +// PageRoundDown/Up are equivalent to Addr.RoundDown/Up, but without the +// potentially truncating conversion from uint64 to Addr. This is necessary +// because there is no way to define generic "PageRoundDown/Up" functions in Go. + +// PageRoundDown returns x rounded down to the nearest page boundary. +func PageRoundDown(x uint64) uint64 { + return x &^ (PageSize - 1) +} + +// PageRoundUp returns x rounded up to the nearest page boundary. +// ok is true iff rounding up did not wrap around. +func PageRoundUp(x uint64) (addr uint64, ok bool) { + addr = PageRoundDown(x + PageSize - 1) + ok = addr >= x + return +} diff --git a/pkg/usermem/addr_range.go b/pkg/usermem/addr_range.go index 152ed1434..152ed1434 100755..100644 --- a/pkg/usermem/addr_range.go +++ b/pkg/usermem/addr_range.go diff --git a/pkg/usermem/addr_range_seq_unsafe.go b/pkg/usermem/addr_range_seq_unsafe.go index c09337c15..c09337c15 100755..100644 --- a/pkg/usermem/addr_range_seq_unsafe.go +++ b/pkg/usermem/addr_range_seq_unsafe.go diff --git a/pkg/usermem/bytes_io.go b/pkg/usermem/bytes_io.go index e177d30eb..e177d30eb 100755..100644 --- a/pkg/usermem/bytes_io.go +++ b/pkg/usermem/bytes_io.go diff --git a/pkg/usermem/bytes_io_unsafe.go b/pkg/usermem/bytes_io_unsafe.go index 20de5037d..20de5037d 100755..100644 --- a/pkg/usermem/bytes_io_unsafe.go +++ b/pkg/usermem/bytes_io_unsafe.go diff --git a/pkg/usermem/usermem.go b/pkg/usermem/usermem.go index cd6a0ea6b..cd6a0ea6b 100755..100644 --- a/pkg/usermem/usermem.go +++ b/pkg/usermem/usermem.go diff --git a/pkg/usermem/usermem_arm64.go b/pkg/usermem/usermem_arm64.go index fdfc30a66..fdfc30a66 100755..100644 --- a/pkg/usermem/usermem_arm64.go +++ b/pkg/usermem/usermem_arm64.go diff --git a/pkg/usermem/usermem_arm64_state_autogen.go b/pkg/usermem/usermem_arm64_state_autogen.go index d7c365e5d..d7c365e5d 100755..100644 --- a/pkg/usermem/usermem_arm64_state_autogen.go +++ b/pkg/usermem/usermem_arm64_state_autogen.go diff --git a/pkg/usermem/usermem_state_autogen.go b/pkg/usermem/usermem_state_autogen.go index 20aa2d2de..20aa2d2de 100755..100644 --- a/pkg/usermem/usermem_state_autogen.go +++ b/pkg/usermem/usermem_state_autogen.go diff --git a/pkg/usermem/usermem_unsafe_state_autogen.go b/pkg/usermem/usermem_unsafe_state_autogen.go index 62f8af4c9..62f8af4c9 100755..100644 --- a/pkg/usermem/usermem_unsafe_state_autogen.go +++ b/pkg/usermem/usermem_unsafe_state_autogen.go diff --git a/pkg/usermem/usermem_x86.go b/pkg/usermem/usermem_x86.go index d96f829fb..d96f829fb 100755..100644 --- a/pkg/usermem/usermem_x86.go +++ b/pkg/usermem/usermem_x86.go diff --git a/pkg/usermem/usermem_x86_state_autogen.go b/pkg/usermem/usermem_x86_state_autogen.go index cca386593..cca386593 100755..100644 --- a/pkg/usermem/usermem_x86_state_autogen.go +++ b/pkg/usermem/usermem_x86_state_autogen.go |