aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_kern.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2018-07-19 20:00:28 +0000
committerMark Johnston <markj@FreeBSD.org>2018-07-19 20:00:28 +0000
commit483f692ea6db8f90266208175c2c83a5eaae5786 (patch)
tree29b25334c93c9cb24022bc8c6d332c3b757b1901 /sys/vm/vm_kern.c
parent73624a804a52723d7377003bfee94af39e9fa1fe (diff)
downloadsrc-483f692ea6db8f90266208175c2c83a5eaae5786.tar.gz
src-483f692ea6db8f90266208175c2c83a5eaae5786.zip
Notes
Diffstat (limited to 'sys/vm/vm_kern.c')
-rw-r--r--sys/vm/vm_kern.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index 037db5723396..724205c95309 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -688,6 +688,38 @@ kmem_init(vm_offset_t start, vm_offset_t end)
vm_map_unlock(m);
}
+/*
+ * kmem_bootstrap_free:
+ *
+ * Free pages backing preloaded data (e.g., kernel modules) to the
+ * system. Currently only supported on platforms that create a
+ * vm_phys segment for preloaded data.
+ */
+void
+kmem_bootstrap_free(vm_offset_t start, vm_size_t size)
+{
+#if defined(__i386__) || defined(__amd64__)
+ struct vm_domain *vmd;
+ vm_offset_t end;
+ vm_paddr_t pa;
+ vm_page_t m;
+
+ end = trunc_page(start + size);
+ start = round_page(start);
+
+ (void)vm_map_remove(kernel_map, start, end);
+ for (; start < end; start += PAGE_SIZE) {
+ pa = pmap_kextract(start);
+ m = PHYS_TO_VM_PAGE(pa);
+
+ vmd = vm_pagequeue_domain(m);
+ vm_domain_free_lock(vmd);
+ vm_phys_free_pages(m, 0);
+ vm_domain_free_unlock(vmd);
+ }
+#endif
+}
+
#ifdef DIAGNOSTIC
/*
* Allow userspace to directly trigger the VM drain routine for testing