2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
61 * Author: Avadis Tevanian, Jr., Michael Wayne Young
64 * Virtual memory map module definitions.
73 #include <mach/mach_types.h>
74 #include <mach/kern_return.h>
75 #include <mach/boolean.h>
76 #include <mach/vm_types.h>
77 #include <mach/vm_prot.h>
78 #include <mach/vm_inherit.h>
79 #include <mach/vm_behavior.h>
80 #include <mach/vm_param.h>
85 #include <sys/cdefs.h>
89 extern void vm_map_reference(vm_map_t map
);
90 extern vm_map_t
current_map(void);
92 /* Setup reserved areas in a new VM map */
93 extern kern_return_t
vm_map_exec(
101 #ifdef MACH_KERNEL_PRIVATE
103 #include <task_swapper.h>
104 #include <mach_assert.h>
106 #include <vm/vm_object.h>
107 #include <vm/vm_page.h>
108 #include <kern/lock.h>
109 #include <kern/zalloc.h>
110 #include <kern/macro_help.h>
112 #include <kern/thread.h>
114 #define current_map_fast() (current_thread()->map)
115 #define current_map() (current_map_fast())
120 * vm_map_t the high-level address map data structure.
121 * vm_map_entry_t an entry in an address map.
122 * vm_map_version_t a timestamp of a map, for use with vm_map_lookup
123 * vm_map_copy_t represents memory copied from an address map,
124 * used for inter-map copy operations
126 typedef struct vm_map_entry
*vm_map_entry_t
;
127 #define VM_MAP_ENTRY_NULL ((vm_map_entry_t) 0)
131 * Type: vm_map_object_t [internal use only]
134 * The target of an address mapping, either a virtual
135 * memory object or a sub map (of the kernel map).
137 typedef union vm_map_object
{
138 vm_object_t vm_object
; /* object object */
139 vm_map_t sub_map
; /* belongs to another map */
142 #define named_entry_lock_init(object) mutex_init(&(object)->Lock, 0)
143 #define named_entry_lock(object) mutex_lock(&(object)->Lock)
144 #define named_entry_unlock(object) mutex_unlock(&(object)->Lock)
147 * Type: vm_named_entry_t [internal use only]
150 * Description of a mapping to a memory cache object.
153 * While the handle to this object is used as a means to map
154 * and pass around the right to map regions backed by pagers
155 * of all sorts, the named_entry itself is only manipulated
156 * by the kernel. Named entries hold information on the
157 * right to map a region of a cached object. Namely,
158 * the target cache object, the beginning and ending of the
159 * region to be mapped, and the permissions, (read, write)
160 * with which it can be mapped.
164 struct vm_named_entry
{
165 decl_mutex_data(, Lock
) /* Synchronization */
167 vm_object_t object
; /* object I point to */
168 memory_object_t pager
; /* amo pager port */
169 vm_map_t map
; /* map backing submap */
171 vm_object_offset_t offset
; /* offset into object */
172 vm_object_size_t size
; /* size of region */
173 vm_prot_t protection
; /* access permissions */
174 int ref_count
; /* Number of references */
175 unsigned int /* Is backing.xxx : */
176 /* boolean_t */ internal
:1, /* ... an internal object */
177 /* boolean_t */ is_sub_map
:1, /* ... a submap? */
178 /* boolean_t */ is_pager
:1; /* ... a pager port */
182 * Type: vm_map_entry_t [internal use only]
185 * A single mapping within an address map.
188 * Address map entries consist of start and end addresses,
189 * a VM object (or sub map) and offset into that object,
190 * and user-exported inheritance and protection information.
191 * Control information for virtual copy operations is also
192 * stored in the address map entry.
194 struct vm_map_links
{
195 struct vm_map_entry
*prev
; /* previous entry */
196 struct vm_map_entry
*next
; /* next entry */
197 vm_map_offset_t start
; /* start address */
198 vm_map_offset_t end
; /* end address */
201 struct vm_map_entry
{
202 struct vm_map_links links
; /* links to other entries */
203 #define vme_prev links.prev
204 #define vme_next links.next
205 #define vme_start links.start
206 #define vme_end links.end
207 union vm_map_object object
; /* object I point to */
208 vm_object_offset_t offset
; /* offset into object */
210 /* boolean_t */ is_shared
:1, /* region is shared */
211 /* boolean_t */ is_sub_map
:1, /* Is "object" a submap? */
212 /* boolean_t */ in_transition
:1, /* Entry being changed */
213 /* boolean_t */ needs_wakeup
:1, /* Waiters on in_transition */
214 /* vm_behavior_t */ behavior
:2, /* user paging behavior hint */
215 /* behavior is not defined for submap type */
216 /* boolean_t */ needs_copy
:1, /* object need to be copied? */
217 /* Only in task maps: */
218 /* vm_prot_t */ protection
:3, /* protection code */
219 /* vm_prot_t */ max_protection
:3,/* maximum protection */
220 /* vm_inherit_t */ inheritance
:2, /* inheritance */
221 /* boolean_t */ use_pmap
:1, /* nested pmaps */
222 /* unsigned char */ alias
:8, /* user alias */
223 /* boolean_t */ no_cache
:1, /* should new pages be cached? */
224 /* unsigned char */ pad
:7; /* available bits */
225 unsigned short wired_count
; /* can be paged if = 0 */
226 unsigned short user_wired_count
; /* for vm_wire */
230 * wired_counts are unsigned short. This value is used to safeguard
231 * against any mishaps due to runaway user programs.
233 #define MAX_WIRE_COUNT 65535
238 * Type: struct vm_map_header
241 * Header for a vm_map and a vm_map_copy.
243 struct vm_map_header
{
244 struct vm_map_links links
; /* first, last, min, max */
245 int nentries
; /* Number of entries */
246 boolean_t entries_pageable
;
247 /* are map entries pageable? */
251 * Type: vm_map_t [exported; contents invisible]
254 * An address map -- a directory relating valid
255 * regions of a task's address space to the corresponding
256 * virtual memory objects.
259 * Maps are doubly-linked lists of map entries, sorted
260 * by address. One hint is used to start
261 * searches again from the last successful search,
262 * insertion, or removal. Another hint is used to
263 * quickly find free space.
266 lock_t lock
; /* uni- and smp-lock */
267 struct vm_map_header hdr
; /* Map entry header */
268 #define min_offset hdr.links.start /* start of range */
269 #define max_offset hdr.links.end /* end of range */
270 pmap_t pmap
; /* Physical map */
271 vm_map_size_t size
; /* virtual size */
272 vm_map_size_t user_wire_limit
;/* rlimit on user locked memory */
273 vm_map_size_t user_wire_size
; /* current size of user locked memory in this map */
274 int ref_count
; /* Reference count */
276 int res_count
; /* Residence count (swap) */
277 int sw_state
; /* Swap state */
278 #endif /* TASK_SWAPPER */
279 decl_mutex_data(, s_lock
) /* Lock ref, res fields */
280 vm_map_entry_t hint
; /* hint for quick lookups */
281 vm_map_entry_t first_free
; /* First free space hint */
282 boolean_t wait_for_space
; /* Should callers wait
284 boolean_t wiring_required
;/* All memory wired? */
285 boolean_t no_zero_fill
; /* No zero fill absent pages */
286 boolean_t mapped
; /* has this map been mapped */
287 unsigned int timestamp
; /* Version number */
288 unsigned int color_rr
; /* next color (not protected by a lock) */
291 #define vm_map_to_entry(map) ((struct vm_map_entry *) &(map)->hdr.links)
292 #define vm_map_first_entry(map) ((map)->hdr.links.next)
293 #define vm_map_last_entry(map) ((map)->hdr.links.prev)
297 * VM map swap states. There are no transition states.
299 #define MAP_SW_IN 1 /* map is swapped in; residence count > 0 */
300 #define MAP_SW_OUT 2 /* map is out (res_count == 0 */
301 #endif /* TASK_SWAPPER */
304 * Type: vm_map_version_t [exported; contents invisible]
307 * Map versions may be used to quickly validate a previous
311 * Because they are bulky objects, map versions are usually
312 * passed by reference.
315 * Just a timestamp for the main map.
317 typedef struct vm_map_version
{
318 unsigned int main_timestamp
;
322 * Type: vm_map_copy_t [exported; contents invisible]
325 * A map copy object represents a region of virtual memory
326 * that has been copied from an address map but is still
329 * A map copy object may only be used by a single thread
333 * There are three formats for map copy objects.
334 * The first is very similar to the main
335 * address map in structure, and as a result, some
336 * of the internal maintenance functions/macros can
337 * be used with either address maps or map copy objects.
339 * The map copy object contains a header links
340 * entry onto which the other entries that represent
341 * the region are chained.
343 * The second format is a single vm object. This was used
344 * primarily in the pageout path - but is not currently used
345 * except for placeholder copy objects (see vm_map_copy_copy()).
347 * The third format is a kernel buffer copy object - for data
348 * small enough that physical copies were the most efficient
354 #define VM_MAP_COPY_ENTRY_LIST 1
355 #define VM_MAP_COPY_OBJECT 2
356 #define VM_MAP_COPY_KERNEL_BUFFER 3
357 vm_object_offset_t offset
;
360 struct vm_map_header hdr
; /* ENTRY_LIST */
361 vm_object_t object
; /* OBJECT */
363 void *kdata
; /* KERNEL_BUFFER */
364 vm_size_t kalloc_size
; /* size of this copy_t */
370 #define cpy_hdr c_u.hdr
372 #define cpy_object c_u.object
374 #define cpy_kdata c_u.c_k.kdata
375 #define cpy_kalloc_size c_u.c_k.kalloc_size
379 * Useful macros for entry list copy objects
382 #define vm_map_copy_to_entry(copy) \
383 ((struct vm_map_entry *) &(copy)->cpy_hdr.links)
384 #define vm_map_copy_first_entry(copy) \
385 ((copy)->cpy_hdr.links.next)
386 #define vm_map_copy_last_entry(copy) \
387 ((copy)->cpy_hdr.links.prev)
390 * Macros: vm_map_lock, etc. [internal use only]
392 * Perform locking on the data portion of a map.
393 * When multiple maps are to be locked, order by map address.
394 * (See vm_map.c::vm_remap())
397 #define vm_map_lock_init(map) \
398 ((map)->timestamp = 0 , \
399 lock_init(&(map)->lock, TRUE, 0, 0))
401 #define vm_map_lock(map) lock_write(&(map)->lock)
402 #define vm_map_unlock(map) \
403 ((map)->timestamp++ , lock_write_done(&(map)->lock))
404 #define vm_map_lock_read(map) lock_read(&(map)->lock)
405 #define vm_map_unlock_read(map) lock_read_done(&(map)->lock)
406 #define vm_map_lock_write_to_read(map) \
407 ((map)->timestamp++ , lock_write_to_read(&(map)->lock))
408 /* lock_read_to_write() returns FALSE on failure. Macro evaluates to
409 * zero on success and non-zero value on failure.
411 #define vm_map_lock_read_to_write(map) (lock_read_to_write(&(map)->lock) != TRUE)
414 * Exported procedures that operate on vm_map_t.
417 /* Initialize the module */
418 extern void vm_map_init(void) __attribute__((section("__TEXT, initcode")));
420 /* Allocate a range in the specified virtual address map and
421 * return the entry allocated for that range. */
422 extern kern_return_t
vm_map_find_space(
424 vm_map_address_t
*address
, /* OUT */
426 vm_map_offset_t mask
,
428 vm_map_entry_t
*o_entry
); /* OUT */
430 /* Lookup map entry containing or the specified address in the given map */
431 extern boolean_t
vm_map_lookup_entry(
433 vm_map_address_t address
,
434 vm_map_entry_t
*entry
); /* OUT */
436 /* Find the VM object, offset, and protection for a given virtual address
437 * in the specified map, assuming a page fault of the type specified. */
438 extern kern_return_t
vm_map_lookup_locked(
439 vm_map_t
*var_map
, /* IN/OUT */
440 vm_map_address_t vaddr
,
441 vm_prot_t fault_type
,
442 int object_lock_type
,
443 vm_map_version_t
*out_version
, /* OUT */
444 vm_object_t
*object
, /* OUT */
445 vm_object_offset_t
*offset
, /* OUT */
446 vm_prot_t
*out_prot
, /* OUT */
447 boolean_t
*wired
, /* OUT */
448 vm_object_fault_info_t fault_info
, /* OUT */
449 vm_map_t
*real_map
); /* OUT */
451 /* Verifies that the map has not changed since the given version. */
452 extern boolean_t
vm_map_verify(
454 vm_map_version_t
*version
); /* REF */
456 extern vm_map_entry_t
vm_map_entry_insert(
458 vm_map_entry_t insp_entry
,
459 vm_map_offset_t start
,
462 vm_object_offset_t offset
,
463 boolean_t needs_copy
,
465 boolean_t in_transition
,
466 vm_prot_t cur_protection
,
467 vm_prot_t max_protection
,
468 vm_behavior_t behavior
,
469 vm_inherit_t inheritance
,
470 unsigned wired_count
,
475 * Functions implemented as macros
477 #define vm_map_min(map) ((map)->min_offset)
478 /* Lowest valid address in
481 #define vm_map_max(map) ((map)->max_offset)
482 /* Highest valid address */
484 #define vm_map_pmap(map) ((map)->pmap)
485 /* Physical map associated
486 * with this address map */
488 #define vm_map_verify_done(map, version) vm_map_unlock_read(map)
489 /* Operation that required
490 * a verified lookup is
494 * Macros/functions for map residence counts and swapin/out of vm maps
499 /* Gain a reference to an existing map */
500 extern void vm_map_reference(
502 /* Lose a residence count */
503 extern void vm_map_res_deallocate(
505 /* Gain a residence count on a map */
506 extern void vm_map_res_reference(
508 /* Gain reference & residence counts to possibly swapped-out map */
509 extern void vm_map_reference_swap(
512 #else /* MACH_ASSERT */
514 #define vm_map_reference(map) \
516 vm_map_t Map = (map); \
518 mutex_lock(&Map->s_lock); \
521 mutex_unlock(&Map->s_lock); \
525 #define vm_map_res_reference(map) \
527 vm_map_t Lmap = (map); \
528 if (Lmap->res_count == 0) { \
529 mutex_unlock(&Lmap->s_lock);\
531 vm_map_swapin(Lmap); \
532 mutex_lock(&Lmap->s_lock); \
534 vm_map_unlock(Lmap); \
539 #define vm_map_res_deallocate(map) \
541 vm_map_t Map = (map); \
542 if (--Map->res_count == 0) { \
543 mutex_unlock(&Map->s_lock); \
545 vm_map_swapout(Map); \
546 vm_map_unlock(Map); \
547 mutex_lock(&Map->s_lock); \
551 #define vm_map_reference_swap(map) \
553 vm_map_t Map = (map); \
554 mutex_lock(&Map->s_lock); \
556 vm_map_res_reference(Map); \
557 mutex_unlock(&Map->s_lock); \
559 #endif /* MACH_ASSERT */
561 extern void vm_map_swapin(
564 extern void vm_map_swapout(
567 #else /* TASK_SWAPPER */
569 #define vm_map_reference(map) \
571 vm_map_t Map = (map); \
573 mutex_lock(&Map->s_lock); \
575 mutex_unlock(&Map->s_lock); \
579 #define vm_map_reference_swap(map) vm_map_reference(map)
580 #define vm_map_res_reference(map)
581 #define vm_map_res_deallocate(map)
583 #endif /* TASK_SWAPPER */
586 * Submap object. Must be used to create memory to be put
587 * in a submap by vm_map_submap.
589 extern vm_object_t vm_submap_object
;
592 * Wait and wakeup macros for in_transition map entries.
594 #define vm_map_entry_wait(map, interruptible) \
595 ((map)->timestamp++ , \
596 thread_sleep_lock_write((event_t)&(map)->hdr, \
597 &(map)->lock, interruptible))
600 #define vm_map_entry_wakeup(map) \
601 thread_wakeup((event_t)(&(map)->hdr))
604 #define vm_map_ref_fast(map) \
606 mutex_lock(&map->s_lock); \
608 vm_map_res_reference(map); \
609 mutex_unlock(&map->s_lock); \
612 #define vm_map_dealloc_fast(map) \
616 mutex_lock(&map->s_lock); \
617 c = --map->ref_count; \
619 vm_map_res_deallocate(map); \
620 mutex_unlock(&map->s_lock); \
622 vm_map_destroy(map); \
626 /* simplify map entries */
627 extern void vm_map_simplify_entry(
629 vm_map_entry_t this_entry
);
630 extern void vm_map_simplify(
632 vm_map_offset_t start
);
634 /* Move the information in a map copy object to a new map copy object */
635 extern vm_map_copy_t
vm_map_copy_copy(
638 /* Create a copy object from an object. */
639 extern kern_return_t
vm_map_copyin_object(
641 vm_object_offset_t offset
,
642 vm_object_size_t size
,
643 vm_map_copy_t
*copy_result
); /* OUT */
645 /* Enter a mapping */
646 extern kern_return_t
vm_map_enter(
648 vm_map_offset_t
*address
,
650 vm_map_offset_t mask
,
653 vm_object_offset_t offset
,
654 boolean_t needs_copy
,
655 vm_prot_t cur_protection
,
656 vm_prot_t max_protection
,
657 vm_inherit_t inheritance
);
659 /* XXX should go away - replaced with regular enter of contig object */
660 extern kern_return_t
vm_map_enter_cpm(
662 vm_map_address_t
*addr
,
666 extern kern_return_t
vm_map_remap(
668 vm_map_offset_t
*address
,
670 vm_map_offset_t mask
,
673 vm_map_offset_t memory_address
,
675 vm_prot_t
*cur_protection
,
676 vm_prot_t
*max_protection
,
677 vm_inherit_t inheritance
);
681 * Read and write from a kernel buffer to a specified map.
683 extern kern_return_t
vm_map_write_user(
686 vm_map_offset_t dst_addr
,
689 extern kern_return_t
vm_map_read_user(
691 vm_map_offset_t src_addr
,
695 /* Create a new task map using an existing task map as a template. */
696 extern vm_map_t
vm_map_fork(
699 /* Change inheritance */
700 extern kern_return_t
vm_map_inherit(
702 vm_map_offset_t start
,
704 vm_inherit_t new_inheritance
);
706 /* Add or remove machine-dependent attributes from map regions */
707 extern kern_return_t
vm_map_machine_attribute(
709 vm_map_offset_t start
,
711 vm_machine_attribute_t attribute
,
712 vm_machine_attribute_val_t
* value
); /* IN/OUT */
714 extern kern_return_t
vm_map_msync(
716 vm_map_address_t address
,
718 vm_sync_t sync_flags
);
720 /* Set paging behavior */
721 extern kern_return_t
vm_map_behavior_set(
723 vm_map_offset_t start
,
725 vm_behavior_t new_behavior
);
727 extern kern_return_t
vm_map_purgable_control(
729 vm_map_offset_t address
,
730 vm_purgable_t control
,
733 extern kern_return_t
vm_map_region(
735 vm_map_offset_t
*address
,
737 vm_region_flavor_t flavor
,
738 vm_region_info_t info
,
739 mach_msg_type_number_t
*count
,
740 mach_port_t
*object_name
);
742 extern kern_return_t
vm_map_region_recurse_64(
744 vm_map_offset_t
*address
,
746 natural_t
*nesting_depth
,
747 vm_region_submap_info_64_t info
,
748 mach_msg_type_number_t
*count
);
750 extern kern_return_t
vm_map_page_info(
752 vm_map_offset_t offset
,
756 extern kern_return_t
vm_map_submap(
758 vm_map_offset_t start
,
761 vm_map_offset_t offset
,
764 extern void vm_map_submap_pmap_clean(
766 vm_map_offset_t start
,
769 vm_map_offset_t offset
);
771 /* Convert from a map entry port to a map */
772 extern vm_map_t
convert_port_entry_to_map(
775 /* Convert from a port to a vm_object */
776 extern vm_object_t
convert_port_entry_to_object(
780 /* definitions related to overriding the NX behavior */
782 #define VM_ABI_32 0x1
783 #define VM_ABI_64 0x2
785 extern int override_nx(vm_map_t map
, uint32_t user_tag
);
787 #endif /* MACH_KERNEL_PRIVATE */
791 /* Create an empty map */
792 extern vm_map_t
vm_map_create(
794 vm_map_offset_t min_off
,
795 vm_map_offset_t max_off
,
798 /* Get rid of a map */
799 extern void vm_map_destroy(
803 /* Lose a reference */
804 extern void vm_map_deallocate(
807 extern vm_map_t
vm_map_switch(
810 /* Change protection */
811 extern kern_return_t
vm_map_protect(
813 vm_map_offset_t start
,
818 /* Check protection */
819 extern boolean_t
vm_map_check_protection(
821 vm_map_offset_t start
,
823 vm_prot_t protection
);
825 /* wire down a region */
826 extern kern_return_t
vm_map_wire(
828 vm_map_offset_t start
,
830 vm_prot_t access_type
,
831 boolean_t user_wire
);
833 /* unwire a region */
834 extern kern_return_t
vm_map_unwire(
836 vm_map_offset_t start
,
838 boolean_t user_wire
);
840 /* Enter a mapping of a memory object */
841 extern kern_return_t
vm_map_enter_mem_object(
843 vm_map_offset_t
*address
,
845 vm_map_offset_t mask
,
848 vm_object_offset_t offset
,
849 boolean_t needs_copy
,
850 vm_prot_t cur_protection
,
851 vm_prot_t max_protection
,
852 vm_inherit_t inheritance
);
854 /* Deallocate a region */
855 extern kern_return_t
vm_map_remove(
857 vm_map_offset_t start
,
861 /* Discard a copy without using it */
862 extern void vm_map_copy_discard(
865 /* Overwrite existing memory with a copy */
866 extern kern_return_t
vm_map_copy_overwrite(
868 vm_map_address_t dst_addr
,
872 /* Place a copy into a map */
873 extern kern_return_t
vm_map_copyout(
875 vm_map_address_t
*dst_addr
, /* OUT */
878 extern kern_return_t
vm_map_copyin(
880 vm_map_address_t src_addr
,
882 boolean_t src_destroy
,
883 vm_map_copy_t
*copy_result
); /* OUT */
885 extern kern_return_t
vm_map_copyin_common(
887 vm_map_address_t src_addr
,
889 boolean_t src_destroy
,
890 boolean_t src_volatile
,
891 vm_map_copy_t
*copy_result
, /* OUT */
892 boolean_t use_maxprot
);
894 extern void vm_map_disable_NX(
897 extern void vm_map_set_64bit(
900 extern void vm_map_set_32bit(
903 extern boolean_t
vm_map_is_64bit(
906 extern boolean_t
vm_map_has_4GB_pagezero(
909 extern void vm_map_set_4GB_pagezero(
912 extern void vm_map_clear_4GB_pagezero(
915 extern kern_return_t
vm_map_raise_min_offset(
917 vm_map_offset_t new_min_offset
);
919 extern vm_map_offset_t
vm_compute_max_offset(
922 extern void vm_map_set_user_wire_limit(
926 #ifdef MACH_KERNEL_PRIVATE
929 * Macros to invoke vm_map_copyin_common. vm_map_copyin is the
930 * usual form; it handles a copyin based on the current protection
931 * (current protection == VM_PROT_NONE) is a failure.
932 * vm_map_copyin_maxprot handles a copyin based on maximum possible
933 * access. The difference is that a region with no current access
934 * BUT possible maximum access is rejected by vm_map_copyin(), but
935 * returned by vm_map_copyin_maxprot.
937 #define vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) \
938 vm_map_copyin_common(src_map, src_addr, len, src_destroy, \
939 FALSE, copy_result, FALSE)
941 #define vm_map_copyin_maxprot(src_map, \
942 src_addr, len, src_destroy, copy_result) \
943 vm_map_copyin_common(src_map, src_addr, len, src_destroy, \
944 FALSE, copy_result, TRUE)
946 #endif /* MACH_KERNEL_PRIVATE */
949 * Macros for rounding and truncation of vm_map offsets and sizes
951 #define vm_map_round_page(x) (((vm_map_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
952 #define vm_map_trunc_page(x) ((vm_map_offset_t)(x) & ~((signed)PAGE_MASK))
955 * Flags for vm_map_remove() and vm_map_delete()
957 #define VM_MAP_NO_FLAGS 0x0
958 #define VM_MAP_REMOVE_KUNWIRE 0x1
959 #define VM_MAP_REMOVE_INTERRUPTIBLE 0x2
960 #define VM_MAP_REMOVE_WAIT_FOR_KWIRE 0x4
961 #define VM_MAP_REMOVE_SAVE_ENTRIES 0x8
962 #define VM_MAP_REMOVE_NO_PMAP_CLEANUP 0x10
964 /* Support for UPLs from vm_maps */
966 extern kern_return_t
vm_map_get_upl(
968 vm_map_offset_t map_offset
,
971 upl_page_info_array_t page_info
,
972 mach_msg_type_number_t
*page_infoCnt
,
974 integer_t force_data_sync
);
978 #endif /* KERNEL_PRIVATE */
980 #endif /* _VM_VM_MAP_H_ */