diff options
author | Doug Moore <dougm@FreeBSD.org> | 2023-08-04 18:41:59 +0000 |
---|---|---|
committer | Doug Moore <dougm@FreeBSD.org> | 2023-08-04 18:41:59 +0000 |
commit | ccdb28275db7c94ffdafc542d9e29fd43f51f39b (patch) | |
tree | eae4c702314e24d9868b137787546bc5d29c2f22 | |
parent | a0e20c0ded1ae98ec25ded317c6a331fbd40e18c (diff) | |
download | src-ccdb28275db7c94ffdafc542d9e29fd43f51f39b.tar.gz src-ccdb28275db7c94ffdafc542d9e29fd43f51f39b.zip |
vm_phys_enq_range: no alignment assert for npages==0
Do not assume that when vm_phys_enq_range is passed npages==0 that the
vm_page argument is valid in any way, much less that it has a
page-aligned address. Just don't look at it. Assert nothing about it.
Reported by: karels
Differential Revision: https://reviews.freebsd.org/D41317
-rw-r--r-- | sys/vm/vm_phys.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c index ed358d7cd4a9..a3af3964fba4 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -690,15 +690,17 @@ vm_phys_split_pages(vm_page_t m, int oind, struct vm_freelist *fl, int order, * term fragmentation by promoting contemporaneous allocation and (hopefully) * deallocation. * - * The physical page m's buddy must not be free. + * If npages is zero, this function does nothing and ignores the physical page + * parameter m. Otherwise, the physical page m's buddy must not be free. */ static vm_page_t vm_phys_enq_range(vm_page_t m, u_int npages, struct vm_freelist *fl, int tail) { int order; - KASSERT(((VM_PAGE_TO_PHYS(m) + npages * PAGE_SIZE) & - ((PAGE_SIZE << fls(npages / 2)) - 1)) == 0, + KASSERT(npages == 0 || + ((VM_PAGE_TO_PHYS(m) + npages * PAGE_SIZE) & + ((PAGE_SIZE << (fls(npages) - 1)) - 1)) == 0, ("vm_phys_enq_range: page %p and npages %u are misaligned", m, npages)); while (npages > 0) { |