diff options
author | Andrei Vagin <avagin@google.com> | 2021-08-20 19:19:23 -0700 |
---|---|---|
committer | Andrei Vagin <avagin@google.com> | 2021-08-21 01:41:55 -0700 |
commit | 28887fb46fe8f40f75f398c27f0a1f64c01354e4 (patch) | |
tree | 1099fda8e3c131409f7d962353df568e47da4d8c /pkg/sentry | |
parent | 0a15a216daab9523a5f0c7b93bbceae98dbcbcc1 (diff) |
platform/kvm: set physical slots without overlapping
Right now, the first slot starts with an address of a memory region and its size is faultBlockSize,
but the second slot starts with (physicalStart + faultBlockSize) & faultBlockMask.
It means they will overlap if a start address of a memory region are not aligned to faultBlockSize.
The kernel doesn't allow to add overlapped regions, but we ignore the EEXIST error.
Signed-off-by: Andrei Vagin <avagin@google.com>
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/platform/kvm/bluepill_fault.go | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/pkg/sentry/platform/kvm/bluepill_fault.go b/pkg/sentry/platform/kvm/bluepill_fault.go index 8fd8287b3..5a8f1186c 100644 --- a/pkg/sentry/platform/kvm/bluepill_fault.go +++ b/pkg/sentry/platform/kvm/bluepill_fault.go @@ -55,11 +55,7 @@ func calculateBluepillFault(physical uintptr, phyRegions []physicalRegion) (virt } // Adjust the block to match our size. - physicalStart = alignedPhysical & faultBlockMask - if physicalStart < pr.physical { - // Bound the starting point to the start of the region. - physicalStart = pr.physical - } + physicalStart = pr.physical + (alignedPhysical - pr.physical) & faultBlockMask virtualStart = pr.virtual + (physicalStart - pr.physical) physicalEnd := physicalStart + faultBlockSize if physicalEnd > end { |