summaryrefslogtreecommitdiff
path: root/vm/vm_kern.c
diff options
context:
space:
mode:
authorDiego Nieto Cid <dnietoc@gmail.com>2025-09-21 21:23:42 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-09-22 00:51:29 +0200
commit9ae4d99c1d1e7c9c0977cebb4df9b86fa92cca94 (patch)
tree62e1baaaefde974b943755eb8771ad0a2ca182f4 /vm/vm_kern.c
parent1269629d90b28a23ef9742645cfaf657ea3165bb (diff)
Implement per-task virtual memory limitHEADmaster
* doc/mach.texi: add a "Memory Limitations" section to document the new interfaces. * include/mach/gnumach.defs: (vm_set_size_limit) new routine (vm_get_size_limit) likewise * kern/task.c: (task_create_kernel) if parent_task is not null copy virtual memory limit * tests/test-vm.c: (test_vm_limit) add test for the new routines * vm/vm_map.h: (struct vm_map) new fields size_none, size_cur_limit and size_max_limit (vm_map_find_entry) add new parameters cur_protection and max_protection * vm/vm_map.c: (vm_map_setup) initialize new fields (vm_map_enforce_limit) new function (vm_map_copy_limits) new function (vm_map_find_entry) add protection and max_protection parameters. call limit enforcer function (vm_map_enter) likewise (vm_map_copyout) likewise (vm_map_copyout_page_list) likewise (vm_map_fork) copy parent limit to the new map and compute and set size_none of the new map * vm/vm_user.c: (vm_set_size_limit) new function (vm_get_size_limit) likewise * xen/grant.c: update call to vm_map_find_entry to pass protection parameters Message-ID: <0b71f4f89b7cc2b159893a805480d7493d522d60.1758485757.git.dnietoc@gmail.com>
Diffstat (limited to 'vm/vm_kern.c')
-rw-r--r--vm/vm_kern.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/vm/vm_kern.c b/vm/vm_kern.c
index 51223d98..37185687 100644
--- a/vm/vm_kern.c
+++ b/vm/vm_kern.c
@@ -108,7 +108,8 @@ projected_buffer_allocate(
vm_map_lock(kernel_map);
kr = vm_map_find_entry(kernel_map, &addr, size, (vm_offset_t) 0,
- VM_OBJECT_NULL, &k_entry);
+ VM_OBJECT_NULL, &k_entry,
+ VM_PROT_DEFAULT, VM_PROT_ALL);
if (kr != KERN_SUCCESS) {
vm_map_unlock(kernel_map);
vm_object_deallocate(object);
@@ -125,7 +126,8 @@ projected_buffer_allocate(
vm_map_lock(map);
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
- VM_OBJECT_NULL, &u_entry);
+ VM_OBJECT_NULL, &u_entry,
+ protection, protection);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);
vm_map_lock(kernel_map);
@@ -141,8 +143,6 @@ projected_buffer_allocate(
/*Creates coupling with kernel mapping of the buffer, and
also guarantees that user cannot directly manipulate
buffer VM entry*/
- u_entry->protection = protection;
- u_entry->max_protection = protection;
u_entry->inheritance = inheritance;
vm_map_unlock(map);
*user_p = addr;
@@ -209,7 +209,8 @@ projected_buffer_map(
vm_map_lock(map);
kr = vm_map_find_entry(map, &user_addr, size, (vm_offset_t) 0,
- VM_OBJECT_NULL, &u_entry);
+ VM_OBJECT_NULL, &u_entry,
+ protection, protection);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);
return kr;
@@ -222,8 +223,6 @@ projected_buffer_map(
/*Creates coupling with kernel mapping of the buffer, and
also guarantees that user cannot directly manipulate
buffer VM entry*/
- u_entry->protection = protection;
- u_entry->max_protection = protection;
u_entry->inheritance = inheritance;
u_entry->wired_count = k_entry->wired_count;
vm_map_unlock(map);
@@ -393,7 +392,8 @@ kmem_alloc(
retry:
vm_map_lock(map);
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
- VM_OBJECT_NULL, &entry);
+ VM_OBJECT_NULL, &entry,
+ VM_PROT_DEFAULT, VM_PROT_ALL);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);
@@ -465,7 +465,8 @@ kmem_valloc(
retry:
vm_map_lock(map);
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
- kernel_object, &entry);
+ kernel_object, &entry,
+ VM_PROT_DEFAULT, VM_PROT_ALL);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);
@@ -585,7 +586,8 @@ kmem_alloc_aligned(
retry:
vm_map_lock(map);
kr = vm_map_find_entry(map, &addr, size, size - 1,
- kernel_object, &entry);
+ kernel_object, &entry,
+ VM_PROT_DEFAULT, VM_PROT_ALL);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);