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 boolean_t prot_copy_allow
;/* is VM_PROT_COPY allowed on this map */
288 unsigned int timestamp
; /* Version number */
289 unsigned int color_rr
; /* next color (not protected by a lock) */
292 #define vm_map_to_entry(map) ((struct vm_map_entry *) &(map)->hdr.links)
293 #define vm_map_first_entry(map) ((map)->hdr.links.next)
294 #define vm_map_last_entry(map) ((map)->hdr.links.prev)
298 * VM map swap states. There are no transition states.
300 #define MAP_SW_IN 1 /* map is swapped in; residence count > 0 */
301 #define MAP_SW_OUT 2 /* map is out (res_count == 0 */
302 #endif /* TASK_SWAPPER */
305 * Type: vm_map_version_t [exported; contents invisible]
308 * Map versions may be used to quickly validate a previous
312 * Because they are bulky objects, map versions are usually
313 * passed by reference.
316 * Just a timestamp for the main map.
318 typedef struct vm_map_version
{
319 unsigned int main_timestamp
;
323 * Type: vm_map_copy_t [exported; contents invisible]
326 * A map copy object represents a region of virtual memory
327 * that has been copied from an address map but is still
330 * A map copy object may only be used by a single thread
334 * There are three formats for map copy objects.
335 * The first is very similar to the main
336 * address map in structure, and as a result, some
337 * of the internal maintenance functions/macros can
338 * be used with either address maps or map copy objects.
340 * The map copy object contains a header links
341 * entry onto which the other entries that represent
342 * the region are chained.
344 * The second format is a single vm object. This was used
345 * primarily in the pageout path - but is not currently used
346 * except for placeholder copy objects (see vm_map_copy_copy()).
348 * The third format is a kernel buffer copy object - for data
349 * small enough that physical copies were the most efficient
355 #define VM_MAP_COPY_ENTRY_LIST 1
356 #define VM_MAP_COPY_OBJECT 2
357 #define VM_MAP_COPY_KERNEL_BUFFER 3
358 vm_object_offset_t offset
;
361 struct vm_map_header hdr
; /* ENTRY_LIST */
362 vm_object_t object
; /* OBJECT */
364 void *kdata
; /* KERNEL_BUFFER */
365 vm_size_t kalloc_size
; /* size of this copy_t */
371 #define cpy_hdr c_u.hdr
373 #define cpy_object c_u.object
375 #define cpy_kdata c_u.c_k.kdata
376 #define cpy_kalloc_size c_u.c_k.kalloc_size
380 * Useful macros for entry list copy objects
383 #define vm_map_copy_to_entry(copy) \
384 ((struct vm_map_entry *) &(copy)->cpy_hdr.links)
385 #define vm_map_copy_first_entry(copy) \
386 ((copy)->cpy_hdr.links.next)
387 #define vm_map_copy_last_entry(copy) \
388 ((copy)->cpy_hdr.links.prev)
391 * Macros: vm_map_lock, etc. [internal use only]
393 * Perform locking on the data portion of a map.
394 * When multiple maps are to be locked, order by map address.
395 * (See vm_map.c::vm_remap())
398 #define vm_map_lock_init(map) \
399 ((map)->timestamp = 0 , \
400 lock_init(&(map)->lock, TRUE, 0, 0))
402 #define vm_map_lock(map) lock_write(&(map)->lock)
403 #define vm_map_unlock(map) \
404 ((map)->timestamp++ , lock_write_done(&(map)->lock))
405 #define vm_map_lock_read(map) lock_read(&(map)->lock)
406 #define vm_map_unlock_read(map) lock_read_done(&(map)->lock)
407 #define vm_map_lock_write_to_read(map) \
408 ((map)->timestamp++ , lock_write_to_read(&(map)->lock))
409 /* lock_read_to_write() returns FALSE on failure. Macro evaluates to
410 * zero on success and non-zero value on failure.
412 #define vm_map_lock_read_to_write(map) (lock_read_to_write(&(map)->lock) != TRUE)
415 * Exported procedures that operate on vm_map_t.
418 /* Initialize the module */
419 extern void vm_map_init(void) __attribute__((section("__TEXT, initcode")));
421 /* Allocate a range in the specified virtual address map and
422 * return the entry allocated for that range. */
423 extern kern_return_t
vm_map_find_space(
425 vm_map_address_t
*address
, /* OUT */
427 vm_map_offset_t mask
,
429 vm_map_entry_t
*o_entry
); /* OUT */
431 /* Lookup map entry containing or the specified address in the given map */
432 extern boolean_t
vm_map_lookup_entry(
434 vm_map_address_t address
,
435 vm_map_entry_t
*entry
); /* OUT */
437 /* Find the VM object, offset, and protection for a given virtual address
438 * in the specified map, assuming a page fault of the type specified. */
439 extern kern_return_t
vm_map_lookup_locked(
440 vm_map_t
*var_map
, /* IN/OUT */
441 vm_map_address_t vaddr
,
442 vm_prot_t fault_type
,
443 int object_lock_type
,
444 vm_map_version_t
*out_version
, /* OUT */
445 vm_object_t
*object
, /* OUT */
446 vm_object_offset_t
*offset
, /* OUT */
447 vm_prot_t
*out_prot
, /* OUT */
448 boolean_t
*wired
, /* OUT */
449 vm_object_fault_info_t fault_info
, /* OUT */
450 vm_map_t
*real_map
); /* OUT */
452 /* Verifies that the map has not changed since the given version. */
453 extern boolean_t
vm_map_verify(
455 vm_map_version_t
*version
); /* REF */
457 extern vm_map_entry_t
vm_map_entry_insert(
459 vm_map_entry_t insp_entry
,
460 vm_map_offset_t start
,
463 vm_object_offset_t offset
,
464 boolean_t needs_copy
,
466 boolean_t in_transition
,
467 vm_prot_t cur_protection
,
468 vm_prot_t max_protection
,
469 vm_behavior_t behavior
,
470 vm_inherit_t inheritance
,
471 unsigned wired_count
,
476 * Functions implemented as macros
478 #define vm_map_min(map) ((map)->min_offset)
479 /* Lowest valid address in
482 #define vm_map_max(map) ((map)->max_offset)
483 /* Highest valid address */
485 #define vm_map_pmap(map) ((map)->pmap)
486 /* Physical map associated
487 * with this address map */
489 #define vm_map_verify_done(map, version) vm_map_unlock_read(map)
490 /* Operation that required
491 * a verified lookup is
495 * Macros/functions for map residence counts and swapin/out of vm maps
500 /* Gain a reference to an existing map */
501 extern void vm_map_reference(
503 /* Lose a residence count */
504 extern void vm_map_res_deallocate(
506 /* Gain a residence count on a map */
507 extern void vm_map_res_reference(
509 /* Gain reference & residence counts to possibly swapped-out map */
510 extern void vm_map_reference_swap(
513 #else /* MACH_ASSERT */
515 #define vm_map_reference(map) \
517 vm_map_t Map = (map); \
519 mutex_lock(&Map->s_lock); \
522 mutex_unlock(&Map->s_lock); \
526 #define vm_map_res_reference(map) \
528 vm_map_t Lmap = (map); \
529 if (Lmap->res_count == 0) { \
530 mutex_unlock(&Lmap->s_lock);\
532 vm_map_swapin(Lmap); \
533 mutex_lock(&Lmap->s_lock); \
535 vm_map_unlock(Lmap); \
540 #define vm_map_res_deallocate(map) \
542 vm_map_t Map = (map); \
543 if (--Map->res_count == 0) { \
544 mutex_unlock(&Map->s_lock); \
546 vm_map_swapout(Map); \
547 vm_map_unlock(Map); \
548 mutex_lock(&Map->s_lock); \
552 #define vm_map_reference_swap(map) \
554 vm_map_t Map = (map); \
555 mutex_lock(&Map->s_lock); \
557 vm_map_res_reference(Map); \
558 mutex_unlock(&Map->s_lock); \
560 #endif /* MACH_ASSERT */
562 extern void vm_map_swapin(
565 extern void vm_map_swapout(
568 #else /* TASK_SWAPPER */
570 #define vm_map_reference(map) \
572 vm_map_t Map = (map); \
574 mutex_lock(&Map->s_lock); \
576 mutex_unlock(&Map->s_lock); \
580 #define vm_map_reference_swap(map) vm_map_reference(map)
581 #define vm_map_res_reference(map)
582 #define vm_map_res_deallocate(map)
584 #endif /* TASK_SWAPPER */
587 * Submap object. Must be used to create memory to be put
588 * in a submap by vm_map_submap.
590 extern vm_object_t vm_submap_object
;
593 * Wait and wakeup macros for in_transition map entries.
595 #define vm_map_entry_wait(map, interruptible) \
596 ((map)->timestamp++ , \
597 thread_sleep_lock_write((event_t)&(map)->hdr, \
598 &(map)->lock, interruptible))
601 #define vm_map_entry_wakeup(map) \
602 thread_wakeup((event_t)(&(map)->hdr))
605 #define vm_map_ref_fast(map) \
607 mutex_lock(&map->s_lock); \
609 vm_map_res_reference(map); \
610 mutex_unlock(&map->s_lock); \
613 #define vm_map_dealloc_fast(map) \
617 mutex_lock(&map->s_lock); \
618 c = --map->ref_count; \
620 vm_map_res_deallocate(map); \
621 mutex_unlock(&map->s_lock); \
623 vm_map_destroy(map); \
627 /* simplify map entries */
628 extern void vm_map_simplify_entry(
630 vm_map_entry_t this_entry
);
631 extern void vm_map_simplify(
633 vm_map_offset_t start
);
635 /* Move the information in a map copy object to a new map copy object */
636 extern vm_map_copy_t
vm_map_copy_copy(
639 /* Create a copy object from an object. */
640 extern kern_return_t
vm_map_copyin_object(
642 vm_object_offset_t offset
,
643 vm_object_size_t size
,
644 vm_map_copy_t
*copy_result
); /* OUT */
646 /* Enter a mapping */
647 extern kern_return_t
vm_map_enter(
649 vm_map_offset_t
*address
,
651 vm_map_offset_t mask
,
654 vm_object_offset_t offset
,
655 boolean_t needs_copy
,
656 vm_prot_t cur_protection
,
657 vm_prot_t max_protection
,
658 vm_inherit_t inheritance
);
660 /* XXX should go away - replaced with regular enter of contig object */
661 extern kern_return_t
vm_map_enter_cpm(
663 vm_map_address_t
*addr
,
667 extern kern_return_t
vm_map_remap(
669 vm_map_offset_t
*address
,
671 vm_map_offset_t mask
,
674 vm_map_offset_t memory_address
,
676 vm_prot_t
*cur_protection
,
677 vm_prot_t
*max_protection
,
678 vm_inherit_t inheritance
);
682 * Read and write from a kernel buffer to a specified map.
684 extern kern_return_t
vm_map_write_user(
687 vm_map_offset_t dst_addr
,
690 extern kern_return_t
vm_map_read_user(
692 vm_map_offset_t src_addr
,
696 /* Create a new task map using an existing task map as a template. */
697 extern vm_map_t
vm_map_fork(
700 /* Change inheritance */
701 extern kern_return_t
vm_map_inherit(
703 vm_map_offset_t start
,
705 vm_inherit_t new_inheritance
);
707 /* Add or remove machine-dependent attributes from map regions */
708 extern kern_return_t
vm_map_machine_attribute(
710 vm_map_offset_t start
,
712 vm_machine_attribute_t attribute
,
713 vm_machine_attribute_val_t
* value
); /* IN/OUT */
715 extern kern_return_t
vm_map_msync(
717 vm_map_address_t address
,
719 vm_sync_t sync_flags
);
721 /* Set paging behavior */
722 extern kern_return_t
vm_map_behavior_set(
724 vm_map_offset_t start
,
726 vm_behavior_t new_behavior
);
728 extern kern_return_t
vm_map_purgable_control(
730 vm_map_offset_t address
,
731 vm_purgable_t control
,
734 extern kern_return_t
vm_map_region(
736 vm_map_offset_t
*address
,
738 vm_region_flavor_t flavor
,
739 vm_region_info_t info
,
740 mach_msg_type_number_t
*count
,
741 mach_port_t
*object_name
);
743 extern kern_return_t
vm_map_region_recurse_64(
745 vm_map_offset_t
*address
,
747 natural_t
*nesting_depth
,
748 vm_region_submap_info_64_t info
,
749 mach_msg_type_number_t
*count
);
751 extern kern_return_t
vm_map_page_info(
753 vm_map_offset_t offset
,
757 extern kern_return_t
vm_map_submap(
759 vm_map_offset_t start
,
762 vm_map_offset_t offset
,
765 extern void vm_map_submap_pmap_clean(
767 vm_map_offset_t start
,
770 vm_map_offset_t offset
);
772 /* Convert from a map entry port to a map */
773 extern vm_map_t
convert_port_entry_to_map(
776 /* Convert from a port to a vm_object */
777 extern vm_object_t
convert_port_entry_to_object(
781 /* definitions related to overriding the NX behavior */
783 #define VM_ABI_32 0x1
784 #define VM_ABI_64 0x2
786 extern int override_nx(vm_map_t map
, uint32_t user_tag
);
788 #endif /* MACH_KERNEL_PRIVATE */
792 /* Create an empty map */
793 extern vm_map_t
vm_map_create(
795 vm_map_offset_t min_off
,
796 vm_map_offset_t max_off
,
799 /* Get rid of a map */
800 extern void vm_map_destroy(
804 /* Lose a reference */
805 extern void vm_map_deallocate(
808 extern vm_map_t
vm_map_switch(
811 /* Change protection */
812 extern kern_return_t
vm_map_protect(
814 vm_map_offset_t start
,
819 /* Check protection */
820 extern boolean_t
vm_map_check_protection(
822 vm_map_offset_t start
,
824 vm_prot_t protection
);
826 /* wire down a region */
827 extern kern_return_t
vm_map_wire(
829 vm_map_offset_t start
,
831 vm_prot_t access_type
,
832 boolean_t user_wire
);
834 /* unwire a region */
835 extern kern_return_t
vm_map_unwire(
837 vm_map_offset_t start
,
839 boolean_t user_wire
);
841 /* Enter a mapping of a memory object */
842 extern kern_return_t
vm_map_enter_mem_object(
844 vm_map_offset_t
*address
,
846 vm_map_offset_t mask
,
849 vm_object_offset_t offset
,
850 boolean_t needs_copy
,
851 vm_prot_t cur_protection
,
852 vm_prot_t max_protection
,
853 vm_inherit_t inheritance
);
855 /* Deallocate a region */
856 extern kern_return_t
vm_map_remove(
858 vm_map_offset_t start
,
862 /* Discard a copy without using it */
863 extern void vm_map_copy_discard(
866 /* Overwrite existing memory with a copy */
867 extern kern_return_t
vm_map_copy_overwrite(
869 vm_map_address_t dst_addr
,
873 /* Place a copy into a map */
874 extern kern_return_t
vm_map_copyout(
876 vm_map_address_t
*dst_addr
, /* OUT */
879 extern kern_return_t
vm_map_copyin(
881 vm_map_address_t src_addr
,
883 boolean_t src_destroy
,
884 vm_map_copy_t
*copy_result
); /* OUT */
886 extern kern_return_t
vm_map_copyin_common(
888 vm_map_address_t src_addr
,
890 boolean_t src_destroy
,
891 boolean_t src_volatile
,
892 vm_map_copy_t
*copy_result
, /* OUT */
893 boolean_t use_maxprot
);
895 extern void vm_map_disable_NX(
898 extern void vm_map_set_64bit(
901 extern void vm_map_set_32bit(
904 extern boolean_t
vm_map_is_64bit(
907 extern boolean_t
vm_map_has_4GB_pagezero(
910 extern void vm_map_set_4GB_pagezero(
913 extern void vm_map_clear_4GB_pagezero(
916 extern kern_return_t
vm_map_raise_min_offset(
918 vm_map_offset_t new_min_offset
);
920 extern vm_map_offset_t
vm_compute_max_offset(
923 extern void vm_map_set_user_wire_limit(
927 extern void vm_map_set_prot_copy_allow(
931 #ifdef MACH_KERNEL_PRIVATE
934 * Macros to invoke vm_map_copyin_common. vm_map_copyin is the
935 * usual form; it handles a copyin based on the current protection
936 * (current protection == VM_PROT_NONE) is a failure.
937 * vm_map_copyin_maxprot handles a copyin based on maximum possible
938 * access. The difference is that a region with no current access
939 * BUT possible maximum access is rejected by vm_map_copyin(), but
940 * returned by vm_map_copyin_maxprot.
942 #define vm_map_copyin(src_map, src_addr, len, src_destroy, copy_result) \
943 vm_map_copyin_common(src_map, src_addr, len, src_destroy, \
944 FALSE, copy_result, FALSE)
946 #define vm_map_copyin_maxprot(src_map, \
947 src_addr, len, src_destroy, copy_result) \
948 vm_map_copyin_common(src_map, src_addr, len, src_destroy, \
949 FALSE, copy_result, TRUE)
951 #endif /* MACH_KERNEL_PRIVATE */
954 * Macros for rounding and truncation of vm_map offsets and sizes
956 #define vm_map_round_page(x) (((vm_map_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
957 #define vm_map_trunc_page(x) ((vm_map_offset_t)(x) & ~((signed)PAGE_MASK))
960 * Flags for vm_map_remove() and vm_map_delete()
962 #define VM_MAP_NO_FLAGS 0x0
963 #define VM_MAP_REMOVE_KUNWIRE 0x1
964 #define VM_MAP_REMOVE_INTERRUPTIBLE 0x2
965 #define VM_MAP_REMOVE_WAIT_FOR_KWIRE 0x4
966 #define VM_MAP_REMOVE_SAVE_ENTRIES 0x8
967 #define VM_MAP_REMOVE_NO_PMAP_CLEANUP 0x10
969 /* Support for UPLs from vm_maps */
971 extern kern_return_t
vm_map_get_upl(
973 vm_map_offset_t map_offset
,
976 upl_page_info_array_t page_info
,
977 mach_msg_type_number_t
*page_infoCnt
,
979 integer_t force_data_sync
);
983 #endif /* KERNEL_PRIVATE */
985 #endif /* _VM_VM_MAP_H_ */