Index: sys/compat/linuxkpi/common/src/linux_page.c =================================================================== --- sys/compat/linuxkpi/common/src/linux_page.c +++ sys/compat/linuxkpi/common/src/linux_page.c @@ -219,9 +219,8 @@ return (0); MPASS(pages != NULL); - va = start; map = &curthread->td_proc->p_vmspace->vm_map; - end = start + (((size_t)nr_pages) << PAGE_SHIFT); + end = start + ptoa(nr_pages); if (!vm_map_range_valid(map, start, end)) return (-EINVAL); prot = write ? (VM_PROT_READ | VM_PROT_WRITE) : VM_PROT_READ; Index: sys/dev/md/md.c =================================================================== --- sys/dev/md/md.c +++ sys/dev/md/md.c @@ -1558,11 +1558,14 @@ case MD_NULL: break; case MD_SWAP: + KASSERT(sc->mediasize % PAGE_SIZE == 0, + ("%s: invalid media size %ju", + __func__, (uintmax_t)sc->mediasize)); if (mdr->md_mediasize <= 0 || (mdr->md_mediasize % PAGE_SIZE) != 0) return (EDOM); - oldpages = OFF_TO_IDX(round_page(sc->mediasize)); - newpages = OFF_TO_IDX(round_page(mdr->md_mediasize)); + oldpages = OFF_TO_IDX(sc->mediasize); + newpages = OFF_TO_IDX(mdr->md_mediasize); if (newpages < oldpages) { VM_OBJECT_WLOCK(sc->object); vm_object_page_remove(sc->object, newpages, 0, 0);