summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/platform/kvm/physical_map.go
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2018-06-06 21:47:39 -0700
committerShentubot <shentubot@google.com>2018-06-06 21:48:24 -0700
commit1b5062263b4a3ca3dc0271d9e06ad0113197344c (patch)
tree69d6536240ffa1db76aaef0d4f3a873d86a0dfaf /pkg/sentry/platform/kvm/physical_map.go
parent206e90d057211f2ac53174907b2ff04801f9a481 (diff)
Add allocator abstraction for page tables.
In order to prevent possible garbage collection and reuse of page table pages prior to invalidation, introduce a former allocator abstraction that can ensure entries are held during a single traversal. This also cleans up the abstraction and splits it out of the machine itself. PiperOrigin-RevId: 199581636 Change-Id: I2257d5d7ffd9c36f9b7ecd42f769261baeaf115c
Diffstat (limited to 'pkg/sentry/platform/kvm/physical_map.go')
-rw-r--r--pkg/sentry/platform/kvm/physical_map.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/pkg/sentry/platform/kvm/physical_map.go b/pkg/sentry/platform/kvm/physical_map.go
index 5d55c9486..81a98656d 100644
--- a/pkg/sentry/platform/kvm/physical_map.go
+++ b/pkg/sentry/platform/kvm/physical_map.go
@@ -205,17 +205,19 @@ func applyPhysicalRegions(fn func(pr physicalRegion) bool) bool {
return true
}
-// TranslateToPhysical translates the given virtual address.
+// translateToPhysical translates the given virtual address.
//
// Precondition: physicalInit must have been called.
-func TranslateToPhysical(virtual uintptr) (physical uintptr, length uintptr, ok bool) {
- ok = !applyPhysicalRegions(func(pr physicalRegion) bool {
+//
+//go:nosplit
+func translateToPhysical(virtual uintptr) (physical uintptr, length uintptr, ok bool) {
+ for _, pr := range physicalRegions {
if pr.virtual <= virtual && virtual < pr.virtual+pr.length {
physical = pr.physical + (virtual - pr.virtual)
length = pr.length - (virtual - pr.virtual)
- return false
+ ok = true
+ return
}
- return true
- })
+ }
return
}