summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2021-04-11 15:52:28 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-04-19 09:09:17 +0000
commit9558d0b12b2242f8f19a3526ff0656c48b28f657 (patch)
treeb9e3b18fc31d07aa3e1df38d7e0f7940b540b053
parent5920236ba222e7ab53c90f117bfc66be6c043363 (diff)
downloadillumos-joyent-9558d0b12b2242f8f19a3526ff0656c48b28f657.tar.gz
13712 bhyve allows vmspace mapping inside existing range
Reviewed by: Patrick Mooney <pmooney@pfmooney.com> Reviewed by: Jorge Schrauwen <sjorge@blackdot.be> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/uts/i86pc/io/vmm/vmm_sol_vm.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/usr/src/uts/i86pc/io/vmm/vmm_sol_vm.c b/usr/src/uts/i86pc/io/vmm/vmm_sol_vm.c
index bedc338474..a280c1d255 100644
--- a/usr/src/uts/i86pc/io/vmm/vmm_sol_vm.c
+++ b/usr/src/uts/i86pc/io/vmm/vmm_sol_vm.c
@@ -13,6 +13,7 @@
/*
* Copyright 2019 Joyent, Inc.
* Copyright 2020 Oxide Computer Company
+ * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
*/
#include <sys/param.h>
@@ -624,17 +625,21 @@ vm_mapping_gap(struct vmspace *vms, uintptr_t addr, size_t size)
{
vmspace_mapping_t *vmsm;
list_t *ml = &vms->vms_maplist;
- const uintptr_t range_end = addr + size;
+ const uintptr_t range_end = addr + size - 1;
ASSERT(MUTEX_HELD(&vms->vms_lock));
+ ASSERT(size > 0);
for (vmsm = list_head(ml); vmsm != NULL; vmsm = list_next(ml, vmsm)) {
- const uintptr_t seg_end = vmsm->vmsm_addr + vmsm->vmsm_len;
+ const uintptr_t seg_end = vmsm->vmsm_addr + vmsm->vmsm_len - 1;
- if ((vmsm->vmsm_addr >= addr && vmsm->vmsm_addr < range_end) ||
- (seg_end > addr && seg_end < range_end)) {
- return (B_FALSE);
- }
+ /*
+ * The two ranges do not overlap if the start of either of
+ * them is after the end of the other.
+ */
+ if (vmsm->vmsm_addr > range_end || addr > seg_end)
+ continue;
+ return (B_FALSE);
}
return (B_TRUE);
}