summaryrefslogtreecommitdiff
path: root/mach-defpager
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2016-12-24 02:57:36 +0100
committerRichard Braun <rbraun@sceen.net>2016-12-24 03:16:00 +0100
commit92e3b0a3c3ba90c90605debf6e149e5a4b8d9a8f (patch)
treef79640022bdcfda93fe5ab29bfbc800d33b1c95a /mach-defpager
parentee4795884ec145303115ac1bd88878684df46118 (diff)
mach-defpager: make the default pager use vm_wire_all
The vm_wire_all call was recently added to GNU Mach so that the default pager doesn't depend on glibc malloc hooks any more. * mach-defpager/default_pager.c (start_default_pager_thread): Remove call to wire_memory. * mach-defpager/kalloc.c (kget_space): Likewise. * mach-defpager/wiring.c: Include mach/gnumach.h. (wire_memory): Remove function. (wire_all_memory): Replace call to wire_memory with a direct call to vm_wire, call vm_wire_all after the fixup loop. (vm_allocate, __vm_allocate): Remove functions. * mach-defpager/wiring.h (wire_memory): Remove function.
Diffstat (limited to 'mach-defpager')
-rw-r--r--mach-defpager/default_pager.c2
-rw-r--r--mach-defpager/kalloc.c2
-rw-r--r--mach-defpager/wiring.c67
-rw-r--r--mach-defpager/wiring.h1
4 files changed, 13 insertions, 59 deletions
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
index 787ba5b5..cddbcfa1 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -3011,8 +3011,6 @@ start_default_pager_thread(internal)
vm_page_size, TRUE);
if (kr != KERN_SUCCESS)
panic(my_name);
- wire_memory(ndpt->dpt_buffer, vm_page_size,
- VM_PROT_READ|VM_PROT_WRITE);
err = pthread_create(&ndpt->dpt_thread, NULL, default_pager_thread,
ndpt);
diff --git a/mach-defpager/kalloc.c b/mach-defpager/kalloc.c
index e4ed12fb..33566438 100644
--- a/mach-defpager/kalloc.c
+++ b/mach-defpager/kalloc.c
@@ -150,8 +150,6 @@ vm_offset_t kget_space(vm_offset_t size)
VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT)
!= KERN_SUCCESS)
return 0;
- wire_memory(new_space, space_to_add,
- VM_PROT_READ|VM_PROT_WRITE);
pthread_spin_lock(&kget_space_lock);
continue;
}
diff --git a/mach-defpager/wiring.c b/mach-defpager/wiring.c
index a0a608d6..ac20dda7 100644
--- a/mach-defpager/wiring.c
+++ b/mach-defpager/wiring.c
@@ -28,6 +28,7 @@
*/
#include <mach.h>
#include <mach_init.h>
+#include <mach/gnumach.h>
#include <mach/machine/vm_param.h>
#include "default_pager.h"
@@ -44,24 +45,6 @@ wire_setup(host_priv)
}
void
-wire_memory(start, size, prot)
- vm_address_t start;
- vm_size_t size;
- vm_prot_t prot;
-{
- kern_return_t kr;
-
- if (priv_host_port == MACH_PORT_NULL)
- return;
-
- kr = vm_wire(priv_host_port,
- this_task,
- start, size, prot);
- if (kr != KERN_SUCCESS)
- panic("mem_wire: %d", kr);
-}
-
-void
wire_thread()
{
kern_return_t kr;
@@ -125,7 +108,10 @@ wire_all_memory()
page += vm_page_size)
*(volatile int *) page = *(int *) page;
- wire_memory(address, size, protection);
+ kr = vm_wire(priv_host_port, this_task,
+ address, size, protection);
+ if (kr != KERN_SUCCESS)
+ panic("vm_wire: %d", kr);
if (!(protection & VM_PROT_WRITE))
{
@@ -135,42 +121,15 @@ wire_all_memory()
}
address += size;
}
-}
-/*
- * Alias for vm_allocate to return wired memory.
- */
-kern_return_t
-vm_allocate(task, address, size, anywhere)
- task_t task;
- vm_address_t *address;
- vm_size_t size;
- boolean_t anywhere;
-{
- kern_return_t kr;
+ /*
+ * Automatically wire down future mappings, including those
+ * that are currently PROT_NONE but become accessible.
+ */
- if (anywhere)
- *address = VM_MIN_ADDRESS;
- kr = vm_map(task,
- address, size, (vm_offset_t) 0, anywhere,
- MEMORY_OBJECT_NULL, (vm_offset_t)0, FALSE,
- VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT);
- if (kr != KERN_SUCCESS)
- return kr;
+ kr = vm_wire_all(priv_host_port, this_task, VM_WIRE_ALL);
- if (task == this_task)
- (void) vm_wire(priv_host_port, task, *address, size,
- VM_PROT_DEFAULT);
- return KERN_SUCCESS;
-}
-
-/* Other versions of this function in libc... */
-kern_return_t
-__vm_allocate (task, address, size, anywhere)
- task_t task;
- vm_address_t *address;
- vm_size_t size;
- boolean_t anywhere;
-{
- return vm_allocate (task, address, size, anywhere);
+ if (kr != KERN_SUCCESS) {
+ panic("wire_all_memory: %d", kr);
+ }
}
diff --git a/mach-defpager/wiring.h b/mach-defpager/wiring.h
index b5f8e53f..e545834d 100644
--- a/mach-defpager/wiring.h
+++ b/mach-defpager/wiring.h
@@ -30,6 +30,5 @@
#include <mach_init.h>
extern void wire_setup(/* mach_port_t host_priv */);
-extern void wire_memory(/* vm_address_t, vm_size_t, vm_prot_t */);
extern void wire_thread();
extern void wire_all_memory();