Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111873155
D33870.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D33870.diff
View Options
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -1428,47 +1428,44 @@
fl = (*seg->free_queues)[pind];
TAILQ_FOREACH(m_ret, &fl[oind].pl, listq) {
/*
- * Is the size of this allocation request
- * larger than the largest block size?
+ * Determine if the address range starting at pa
+ * is within the given range, satisfies the
+ * given alignment, and does not cross the given
+ * boundary.
*/
- if (order >= VM_NFREEORDER) {
- /*
- * Determine if a sufficient number of
- * subsequent blocks to satisfy the
- * allocation request are free.
- */
- pa = VM_PAGE_TO_PHYS(m_ret);
- pa_end = pa + size;
- if (pa_end < pa)
- continue;
- for (;;) {
- pa += 1 << (PAGE_SHIFT +
- VM_NFREEORDER - 1);
- if (pa >= pa_end ||
- pa < seg->start ||
- pa >= seg->end)
- break;
- m = &seg->first_page[atop(pa -
- seg->start)];
- if (m->order != VM_NFREEORDER -
- 1)
- break;
- }
- /* If not, go to the next block. */
- if (pa < pa_end)
- continue;
- }
+ pa = VM_PAGE_TO_PHYS(m_ret);
+ pa_end = pa + size;
+ if (pa < low || pa_end > high ||
+ !vm_addr_ok(pa, size, alignment, boundary))
+ continue;
/*
- * Determine if the blocks are within the
- * given range, satisfy the given alignment,
- * and do not cross the given boundary.
+ * Is the size of this allocation request
+ * no more than the largest block size?
*/
- pa = VM_PAGE_TO_PHYS(m_ret);
- pa_end = pa + size;
- if (pa >= low && pa_end <= high &&
- vm_addr_ok(pa, size, alignment, boundary))
+ if (order < VM_NFREEORDER)
goto done;
+
+ /*
+ * Determine if the address range is valid
+ * (without overflow in pa_end calculation)
+ * and fits within the segment.
+ */
+ if (pa_end < pa || pa_end > seg->end)
+ continue;
+
+ /*
+ * Determine if a sufficient number of
+ * subsequent blocks to satisfy the
+ * allocation request are free.
+ */
+ do {
+ pa += 1 <<
+ (PAGE_SHIFT + VM_NFREEORDER - 1);
+ if (pa >= pa_end)
+ goto done;
+ } while (VM_NFREEORDER - 1 == seg->first_page[
+ atop(pa - seg->start)].order);
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 10, 3:37 PM (16 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17086051
Default Alt Text
D33870.diff (2 KB)
Attached To
Mode
D33870: phys_alloc_seg_contig: don't allocate past seg->end
Attached
Detach File
Event Timeline
Log In to Comment