]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
f427ee49 | 2 | * Copyright (c) 2000-2020 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 A |
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. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
0a7de745 | 31 | /* |
1c79356b A |
32 | * Mach Operating System |
33 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University | |
34 | * All Rights Reserved. | |
0a7de745 | 35 | * |
1c79356b A |
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. | |
0a7de745 | 41 | * |
1c79356b A |
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. | |
0a7de745 | 45 | * |
1c79356b | 46 | * Carnegie Mellon requests users of this software to return to |
0a7de745 | 47 | * |
1c79356b A |
48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
49 | * School of Computer Science | |
50 | * Carnegie Mellon University | |
51 | * Pittsburgh PA 15213-3890 | |
0a7de745 | 52 | * |
1c79356b A |
53 | * any improvements or extensions that they make and grant Carnegie Mellon |
54 | * the rights to redistribute these changes. | |
55 | */ | |
56 | /* | |
57 | */ | |
58 | /* | |
59 | * File: mach/vm_statistics.h | |
60 | * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub | |
61 | * | |
62 | * Virtual memory statistics structure. | |
63 | * | |
64 | */ | |
65 | ||
0a7de745 A |
66 | #ifndef _MACH_VM_STATISTICS_H_ |
67 | #define _MACH_VM_STATISTICS_H_ | |
1c79356b | 68 | |
f427ee49 A |
69 | #ifdef __cplusplus |
70 | extern "C" { | |
71 | #endif | |
1c79356b | 72 | |
f427ee49 A |
73 | #include <mach/machine/vm_types.h> |
74 | #include <mach/machine/kern_return.h> | |
b0d623f7 A |
75 | |
76 | /* | |
77 | * vm_statistics | |
78 | * | |
79 | * History: | |
0a7de745 A |
80 | * rev0 - original structure. |
81 | * rev1 - added purgable info (purgable_count and purges). | |
82 | * rev2 - added speculative_count. | |
b0d623f7 A |
83 | * |
84 | * Note: you cannot add any new fields to this structure. Add them below in | |
0a7de745 | 85 | * vm_statistics64. |
b0d623f7 A |
86 | */ |
87 | ||
1c79356b | 88 | struct vm_statistics { |
0a7de745 A |
89 | natural_t free_count; /* # of pages free */ |
90 | natural_t active_count; /* # of pages active */ | |
91 | natural_t inactive_count; /* # of pages inactive */ | |
92 | natural_t wire_count; /* # of pages wired down */ | |
93 | natural_t zero_fill_count; /* # of zero fill pages */ | |
94 | natural_t reactivations; /* # of pages reactivated */ | |
95 | natural_t pageins; /* # of pageins */ | |
96 | natural_t pageouts; /* # of pageouts */ | |
97 | natural_t faults; /* # of faults */ | |
98 | natural_t cow_faults; /* # of copy-on-writes */ | |
99 | natural_t lookups; /* object cache lookups */ | |
100 | natural_t hits; /* object cache hits */ | |
91447636 | 101 | |
2d21ac55 | 102 | /* added for rev1 */ |
0a7de745 A |
103 | natural_t purgeable_count; /* # of pages purgeable */ |
104 | natural_t purges; /* # of pages purged */ | |
2d21ac55 A |
105 | |
106 | /* added for rev2 */ | |
107 | /* | |
108 | * NB: speculative pages are already accounted for in "free_count", | |
109 | * so "speculative_count" is the number of "free" pages that are | |
110 | * used to hold data that was read speculatively from disk but | |
111 | * haven't actually been used by anyone so far. | |
112 | */ | |
0a7de745 | 113 | natural_t speculative_count; /* # of pages speculative */ |
1c79356b A |
114 | }; |
115 | ||
b0d623f7 | 116 | /* Used by all architectures */ |
0a7de745 A |
117 | typedef struct vm_statistics *vm_statistics_t; |
118 | typedef struct vm_statistics vm_statistics_data_t; | |
1c79356b | 119 | |
0a7de745 | 120 | /* |
b0d623f7 A |
121 | * vm_statistics64 |
122 | * | |
123 | * History: | |
0a7de745 A |
124 | * rev0 - original structure. |
125 | * rev1 - added purgable info (purgable_count and purges). | |
126 | * rev2 - added speculative_count. | |
b0d623f7 | 127 | * ---- |
0a7de745 A |
128 | * rev3 - changed name to vm_statistics64. |
129 | * changed some fields in structure to 64-bit on | |
b0d623f7 | 130 | * arm, i386 and x86_64 architectures. |
6d2010ae A |
131 | * rev4 - require 64-bit alignment for efficient access |
132 | * in the kernel. No change to reported data. | |
b0d623f7 A |
133 | * |
134 | */ | |
135 | ||
136 | struct vm_statistics64 { | |
0a7de745 A |
137 | natural_t free_count; /* # of pages free */ |
138 | natural_t active_count; /* # of pages active */ | |
139 | natural_t inactive_count; /* # of pages inactive */ | |
140 | natural_t wire_count; /* # of pages wired down */ | |
141 | uint64_t zero_fill_count; /* # of zero fill pages */ | |
142 | uint64_t reactivations; /* # of pages reactivated */ | |
143 | uint64_t pageins; /* # of pageins */ | |
144 | uint64_t pageouts; /* # of pageouts */ | |
145 | uint64_t faults; /* # of faults */ | |
146 | uint64_t cow_faults; /* # of copy-on-writes */ | |
147 | uint64_t lookups; /* object cache lookups */ | |
148 | uint64_t hits; /* object cache hits */ | |
149 | uint64_t purges; /* # of pages purged */ | |
150 | natural_t purgeable_count; /* # of pages purgeable */ | |
b0d623f7 A |
151 | /* |
152 | * NB: speculative pages are already accounted for in "free_count", | |
153 | * so "speculative_count" is the number of "free" pages that are | |
154 | * used to hold data that was read speculatively from disk but | |
155 | * haven't actually been used by anyone so far. | |
156 | */ | |
0a7de745 | 157 | natural_t speculative_count; /* # of pages speculative */ |
b0d623f7 | 158 | |
39236c6e | 159 | /* added for rev1 */ |
0a7de745 A |
160 | uint64_t decompressions; /* # of pages decompressed */ |
161 | uint64_t compressions; /* # of pages compressed */ | |
162 | uint64_t swapins; /* # of pages swapped in (via compression segments) */ | |
163 | uint64_t swapouts; /* # of pages swapped out (via compression segments) */ | |
164 | natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */ | |
165 | natural_t throttled_count; /* # of pages throttled */ | |
166 | natural_t external_page_count; /* # of pages that are file-backed (non-swap) */ | |
167 | natural_t internal_page_count; /* # of pages that are anonymous */ | |
168 | uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */ | |
6d2010ae | 169 | } __attribute__((aligned(8))); |
b0d623f7 | 170 | |
0a7de745 A |
171 | typedef struct vm_statistics64 *vm_statistics64_t; |
172 | typedef struct vm_statistics64 vm_statistics64_data_t; | |
b0d623f7 | 173 | |
f427ee49 A |
174 | kern_return_t vm_stats(void *info, unsigned int *count); |
175 | ||
0a7de745 | 176 | /* |
b0d623f7 A |
177 | * VM_STATISTICS_TRUNCATE_TO_32_BIT |
178 | * | |
179 | * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from | |
180 | * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics). | |
181 | */ | |
182 | #define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) | |
183 | ||
0a7de745 | 184 | /* |
6d2010ae A |
185 | * vm_extmod_statistics |
186 | * | |
187 | * Structure to record modifications to a task by an | |
188 | * external agent. | |
189 | * | |
190 | * History: | |
0a7de745 | 191 | * rev0 - original structure. |
6d2010ae A |
192 | */ |
193 | ||
194 | struct vm_extmod_statistics { | |
0a7de745 A |
195 | int64_t task_for_pid_count; /* # of times task port was looked up */ |
196 | int64_t task_for_pid_caller_count; /* # of times this task called task_for_pid */ | |
197 | int64_t thread_creation_count; /* # of threads created in task */ | |
198 | int64_t thread_creation_caller_count; /* # of threads created by task */ | |
199 | int64_t thread_set_state_count; /* # of register state sets in task */ | |
200 | int64_t thread_set_state_caller_count; /* # of register state sets by task */ | |
6d2010ae A |
201 | } __attribute__((aligned(8))); |
202 | ||
203 | typedef struct vm_extmod_statistics *vm_extmod_statistics_t; | |
204 | typedef struct vm_extmod_statistics vm_extmod_statistics_data_t; | |
b0d623f7 | 205 | |
39236c6e | 206 | typedef struct vm_purgeable_stat { |
0a7de745 A |
207 | uint64_t count; |
208 | uint64_t size; | |
39236c6e A |
209 | }vm_purgeable_stat_t; |
210 | ||
211 | struct vm_purgeable_info { | |
212 | vm_purgeable_stat_t fifo_data[8]; | |
213 | vm_purgeable_stat_t obsolete_data; | |
214 | vm_purgeable_stat_t lifo_data[8]; | |
215 | }; | |
216 | ||
0a7de745 | 217 | typedef struct vm_purgeable_info *vm_purgeable_info_t; |
1c79356b A |
218 | |
219 | /* included for the vm_map_page_query call */ | |
220 | ||
221 | #define VM_PAGE_QUERY_PAGE_PRESENT 0x1 | |
222 | #define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2 | |
223 | #define VM_PAGE_QUERY_PAGE_REF 0x4 | |
224 | #define VM_PAGE_QUERY_PAGE_DIRTY 0x8 | |
2d21ac55 A |
225 | #define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10 |
226 | #define VM_PAGE_QUERY_PAGE_COPIED 0x20 | |
0a7de745 A |
227 | #define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40 |
228 | #define VM_PAGE_QUERY_PAGE_EXTERNAL 0x80 | |
229 | #define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 | |
230 | #define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 | |
231 | #define VM_PAGE_QUERY_PAGE_CS_NX 0x400 | |
cb323159 | 232 | #define VM_PAGE_QUERY_PAGE_REUSABLE 0x800 |
1c79356b | 233 | |
0a7de745 | 234 | #ifdef MACH_KERNEL_PRIVATE |
1c79356b A |
235 | |
236 | /* | |
237 | * Each machine dependent implementation is expected to | |
238 | * keep certain statistics. They may do this anyway they | |
239 | * so choose, but are expected to return the statistics | |
240 | * in the following structure. | |
241 | */ | |
242 | ||
243 | struct pmap_statistics { | |
0a7de745 A |
244 | integer_t resident_count; /* # of pages mapped (total)*/ |
245 | integer_t resident_max; /* # of pages mapped (peak) */ | |
246 | integer_t wired_count; /* # of pages wired */ | |
247 | ||
248 | integer_t device; | |
249 | integer_t device_peak; | |
250 | integer_t internal; | |
251 | integer_t internal_peak; | |
252 | integer_t external; | |
253 | integer_t external_peak; | |
254 | integer_t reusable; | |
255 | integer_t reusable_peak; | |
256 | uint64_t compressed __attribute__((aligned(8))); | |
257 | uint64_t compressed_peak __attribute__((aligned(8))); | |
258 | uint64_t compressed_lifetime __attribute__((aligned(8))); | |
1c79356b A |
259 | }; |
260 | ||
0a7de745 | 261 | typedef struct pmap_statistics *pmap_statistics_t; |
1c79356b | 262 | |
0a7de745 A |
263 | #define PMAP_STATS_PEAK(field) \ |
264 | MACRO_BEGIN \ | |
265 | if (field > field##_peak) { \ | |
266 | field##_peak = field; \ | |
267 | } \ | |
39236c6e A |
268 | MACRO_END |
269 | ||
0a7de745 | 270 | #endif /* MACH_KERNEL_PRIVATE */ |
91447636 A |
271 | |
272 | /* | |
273 | * VM allocation flags: | |
0a7de745 | 274 | * |
91447636 | 275 | * VM_FLAGS_FIXED |
0a7de745 | 276 | * (really the absence of VM_FLAGS_ANYWHERE) |
91447636 | 277 | * Allocate new VM region at the specified virtual address, if possible. |
0a7de745 | 278 | * |
91447636 A |
279 | * VM_FLAGS_ANYWHERE |
280 | * Allocate new VM region anywhere it would fit in the address space. | |
281 | * | |
282 | * VM_FLAGS_PURGABLE | |
283 | * Create a purgable VM object for that new VM region. | |
284 | * | |
a39ff7e2 A |
285 | * VM_FLAGS_4GB_CHUNK |
286 | * The new VM region will be chunked up into 4GB sized pieces. | |
287 | * | |
91447636 A |
288 | * VM_FLAGS_NO_PMAP_CHECK |
289 | * (for DEBUG kernel config only, ignored for other configs) | |
290 | * Do not check that there is no stale pmap mapping for the new VM region. | |
291 | * This is useful for kernel memory allocations at bootstrap when building | |
292 | * the initial kernel address space while some memory is already in use. | |
293 | * | |
294 | * VM_FLAGS_OVERWRITE | |
295 | * The new VM region can replace existing VM regions if necessary | |
296 | * (to be used in combination with VM_FLAGS_FIXED). | |
2d21ac55 A |
297 | * |
298 | * VM_FLAGS_NO_CACHE | |
299 | * Pages brought in to this VM region are placed on the speculative | |
300 | * queue instead of the active queue. In other words, they are not | |
301 | * cached so that they will be stolen first if memory runs low. | |
91447636 | 302 | */ |
5ba3f43e | 303 | |
0a7de745 A |
304 | #define VM_FLAGS_FIXED 0x0000 |
305 | #define VM_FLAGS_ANYWHERE 0x0001 | |
306 | #define VM_FLAGS_PURGABLE 0x0002 | |
307 | #define VM_FLAGS_4GB_CHUNK 0x0004 | |
308 | #define VM_FLAGS_RANDOM_ADDR 0x0008 | |
309 | #define VM_FLAGS_NO_CACHE 0x0010 | |
310 | #define VM_FLAGS_RESILIENT_CODESIGN 0x0020 | |
311 | #define VM_FLAGS_RESILIENT_MEDIA 0x0040 | |
312 | #define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ | |
b0d623f7 A |
313 | /* |
314 | * VM_FLAGS_SUPERPAGE_MASK | |
315 | * 3 bits that specify whether large pages should be used instead of | |
316 | * base pages (!=0), as well as the requested page size. | |
317 | */ | |
0a7de745 A |
318 | #define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ |
319 | #define VM_FLAGS_RETURN_DATA_ADDR 0x100000 /* Return address of target data, rather than base of page */ | |
320 | #define VM_FLAGS_RETURN_4K_DATA_ADDR 0x800000 /* Return 4K aligned address of target data */ | |
321 | #define VM_FLAGS_ALIAS_MASK 0xFF000000 | |
322 | #define VM_GET_FLAGS_ALIAS(flags, alias) \ | |
323 | (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 | |
5ba3f43e | 324 | #if !XNU_KERNEL_PRIVATE |
0a7de745 A |
325 | #define VM_SET_FLAGS_ALIAS(flags, alias) \ |
326 | (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ | |
327 | (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) | |
5ba3f43e | 328 | #endif /* !XNU_KERNEL_PRIVATE */ |
1c79356b | 329 | |
2d21ac55 | 330 | /* These are the flags that we accept from user-space */ |
0a7de745 A |
331 | #define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ |
332 | VM_FLAGS_ANYWHERE | \ | |
333 | VM_FLAGS_PURGABLE | \ | |
334 | VM_FLAGS_4GB_CHUNK | \ | |
335 | VM_FLAGS_RANDOM_ADDR | \ | |
336 | VM_FLAGS_NO_CACHE | \ | |
337 | VM_FLAGS_OVERWRITE | \ | |
338 | VM_FLAGS_SUPERPAGE_MASK | \ | |
339 | VM_FLAGS_ALIAS_MASK) | |
340 | #define VM_FLAGS_USER_MAP (VM_FLAGS_USER_ALLOCATE | \ | |
341 | VM_FLAGS_RETURN_4K_DATA_ADDR | \ | |
342 | VM_FLAGS_RETURN_DATA_ADDR) | |
cb323159 A |
343 | #define VM_FLAGS_USER_REMAP (VM_FLAGS_FIXED | \ |
344 | VM_FLAGS_ANYWHERE | \ | |
345 | VM_FLAGS_RANDOM_ADDR | \ | |
346 | VM_FLAGS_OVERWRITE| \ | |
347 | VM_FLAGS_RETURN_DATA_ADDR | \ | |
348 | VM_FLAGS_RESILIENT_CODESIGN | \ | |
349 | VM_FLAGS_RESILIENT_MEDIA) | |
2d21ac55 | 350 | |
fe8ab488 | 351 | #define VM_FLAGS_SUPERPAGE_SHIFT 16 |
0a7de745 A |
352 | #define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ |
353 | #define SUPERPAGE_SIZE_ANY 1 | |
fe8ab488 A |
354 | #define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT) |
355 | #define VM_FLAGS_SUPERPAGE_SIZE_ANY (SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT) | |
356 | #if defined(__x86_64__) || !defined(KERNEL) | |
0a7de745 | 357 | #define SUPERPAGE_SIZE_2MB 2 |
fe8ab488 A |
358 | #define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<<VM_FLAGS_SUPERPAGE_SHIFT) |
359 | #endif | |
360 | ||
d9a64523 A |
361 | /* |
362 | * EXC_GUARD definitions for virtual memory. | |
363 | */ | |
0a7de745 | 364 | #define GUARD_TYPE_VIRT_MEMORY 0x5 |
d9a64523 A |
365 | |
366 | /* Reasons for exception for virtual memory */ | |
367 | enum virtual_memory_guard_exception_codes { | |
0a7de745 | 368 | kGUARD_EXC_DEALLOC_GAP = 1u << 0 |
d9a64523 | 369 | }; |
5ba3f43e A |
370 | |
371 | #ifdef KERNEL_PRIVATE | |
372 | typedef struct { | |
373 | unsigned int | |
0a7de745 A |
374 | vmkf_atomic_entry:1, |
375 | vmkf_permanent:1, | |
376 | vmkf_guard_after:1, | |
377 | vmkf_guard_before:1, | |
378 | vmkf_submap:1, | |
379 | vmkf_already:1, | |
380 | vmkf_beyond_max:1, | |
381 | vmkf_no_pmap_check:1, | |
382 | vmkf_map_jit:1, | |
383 | vmkf_iokit_acct:1, | |
384 | vmkf_keep_map_locked:1, | |
385 | vmkf_fourk:1, | |
386 | vmkf_overwrite_immutable:1, | |
387 | vmkf_remap_prot_copy:1, | |
388 | vmkf_cs_enforcement_override:1, | |
389 | vmkf_cs_enforcement:1, | |
cb323159 A |
390 | vmkf_nested_pmap:1, |
391 | vmkf_no_copy_on_read:1, | |
cb323159 | 392 | vmkf_32bit_map_va:1, |
f427ee49 A |
393 | vmkf_copy_single_object:1, |
394 | vmkf_copy_pageable:1, | |
395 | vmkf_copy_same_map:1, | |
396 | vmkf_translated_allow_execute:1, | |
397 | __vmkf_unused:9; | |
5ba3f43e | 398 | } vm_map_kernel_flags_t; |
0a7de745 A |
399 | #define VM_MAP_KERNEL_FLAGS_NONE (vm_map_kernel_flags_t) { \ |
400 | .vmkf_atomic_entry = 0, /* keep entry atomic (no coalescing) */ \ | |
401 | .vmkf_permanent = 0, /* mapping can NEVER be unmapped */ \ | |
402 | .vmkf_guard_after = 0, /* guard page after the mapping */ \ | |
403 | .vmkf_guard_before = 0, /* guard page before the mapping */ \ | |
404 | .vmkf_submap = 0, /* mapping a VM submap */ \ | |
405 | .vmkf_already = 0, /* OK if same mapping already exists */ \ | |
406 | .vmkf_beyond_max = 0, /* map beyond the map's max offset */ \ | |
407 | .vmkf_no_pmap_check = 0, /* do not check that pmap is empty */ \ | |
408 | .vmkf_map_jit = 0, /* mark entry as JIT region */ \ | |
409 | .vmkf_iokit_acct = 0, /* IOKit accounting */ \ | |
5ba3f43e | 410 | .vmkf_keep_map_locked = 0, /* keep map locked when returning from vm_map_enter() */ \ |
0a7de745 A |
411 | .vmkf_fourk = 0, /* use fourk pager */ \ |
412 | .vmkf_overwrite_immutable = 0, /* can overwrite immutable mappings */ \ | |
413 | .vmkf_remap_prot_copy = 0, /* vm_remap for VM_PROT_COPY */ \ | |
d9a64523 | 414 | .vmkf_cs_enforcement_override = 0, /* override CS_ENFORCEMENT */ \ |
0a7de745 | 415 | .vmkf_cs_enforcement = 0, /* new value for CS_ENFORCEMENT */ \ |
cb323159 A |
416 | .vmkf_nested_pmap = 0, /* use a nested pmap */ \ |
417 | .vmkf_no_copy_on_read = 0, /* do not use copy_on_read */ \ | |
f427ee49 A |
418 | .vmkf_32bit_map_va = 0, /* allocate in low 32-bits range */ \ |
419 | .vmkf_copy_single_object = 0, /* vm_map_copy only 1 VM object */ \ | |
420 | .vmkf_copy_pageable = 0, /* vm_map_copy with pageable entries */ \ | |
421 | .vmkf_copy_same_map = 0, /* vm_map_copy to remap in original map */ \ | |
422 | .vmkf_translated_allow_execute = 0, /* allow execute in translated processes */ \ | |
0a7de745 | 423 | .__vmkf_unused = 0 \ |
5ba3f43e | 424 | } |
cb323159 A |
425 | |
426 | typedef struct { | |
427 | unsigned int | |
428 | vmnekf_ledger_tag:3, | |
429 | vmnekf_ledger_no_footprint:1, | |
430 | __vmnekf_unused:28; | |
431 | } vm_named_entry_kernel_flags_t; | |
432 | #define VM_NAMED_ENTRY_KERNEL_FLAGS_NONE (vm_named_entry_kernel_flags_t) { \ | |
433 | .vmnekf_ledger_tag = 0, \ | |
434 | .vmnekf_ledger_no_footprint = 0, \ | |
435 | .__vmnekf_unused = 0 \ | |
436 | } | |
437 | ||
5ba3f43e A |
438 | #endif /* KERNEL_PRIVATE */ |
439 | ||
cb323159 A |
440 | /* current accounting postmark */ |
441 | #define __VM_LEDGER_ACCOUNTING_POSTMARK 2019032600 | |
442 | ||
443 | /* discrete values: */ | |
444 | #define VM_LEDGER_TAG_NONE 0x00000000 | |
445 | #define VM_LEDGER_TAG_DEFAULT 0x00000001 | |
446 | #define VM_LEDGER_TAG_NETWORK 0x00000002 | |
447 | #define VM_LEDGER_TAG_MEDIA 0x00000003 | |
448 | #define VM_LEDGER_TAG_GRAPHICS 0x00000004 | |
449 | #define VM_LEDGER_TAG_NEURAL 0x00000005 | |
450 | #define VM_LEDGER_TAG_MAX 0x00000005 | |
451 | /* individual bits: */ | |
452 | #define VM_LEDGER_FLAG_NO_FOOTPRINT 0x00000001 | |
453 | #define VM_LEDGER_FLAGS (VM_LEDGER_FLAG_NO_FOOTPRINT) | |
5ba3f43e A |
454 | |
455 | ||
1c79356b A |
456 | #define VM_MEMORY_MALLOC 1 |
457 | #define VM_MEMORY_MALLOC_SMALL 2 | |
458 | #define VM_MEMORY_MALLOC_LARGE 3 | |
459 | #define VM_MEMORY_MALLOC_HUGE 4 | |
460 | #define VM_MEMORY_SBRK 5// uninteresting -- no one should call | |
55e303ae A |
461 | #define VM_MEMORY_REALLOC 6 |
462 | #define VM_MEMORY_MALLOC_TINY 7 | |
b0d623f7 A |
463 | #define VM_MEMORY_MALLOC_LARGE_REUSABLE 8 |
464 | #define VM_MEMORY_MALLOC_LARGE_REUSED 9 | |
1c79356b A |
465 | |
466 | #define VM_MEMORY_ANALYSIS_TOOL 10 | |
467 | ||
39236c6e | 468 | #define VM_MEMORY_MALLOC_NANO 11 |
0a7de745 | 469 | #define VM_MEMORY_MALLOC_MEDIUM 12 |
f427ee49 | 470 | #define VM_MEMORY_MALLOC_PGUARD 13 |
39236c6e | 471 | |
1c79356b | 472 | #define VM_MEMORY_MACH_MSG 20 |
0a7de745 | 473 | #define VM_MEMORY_IOKIT 21 |
1c79356b A |
474 | #define VM_MEMORY_STACK 30 |
475 | #define VM_MEMORY_GUARD 31 | |
0a7de745 | 476 | #define VM_MEMORY_SHARED_PMAP 32 |
1c79356b | 477 | /* memory containing a dylib */ |
0a7de745 | 478 | #define VM_MEMORY_DYLIB 33 |
b0d623f7 | 479 | #define VM_MEMORY_OBJC_DISPATCHERS 34 |
1c79356b | 480 | |
316670eb | 481 | /* Was a nested pmap (VM_MEMORY_SHARED_PMAP) which has now been unnested */ |
0a7de745 | 482 | #define VM_MEMORY_UNSHARED_PMAP 35 |
316670eb A |
483 | |
484 | ||
1c79356b A |
485 | // Placeholders for now -- as we analyze the libraries and find how they |
486 | // use memory, we can make these labels more specific. | |
487 | #define VM_MEMORY_APPKIT 40 | |
488 | #define VM_MEMORY_FOUNDATION 41 | |
489 | #define VM_MEMORY_COREGRAPHICS 42 | |
316670eb A |
490 | #define VM_MEMORY_CORESERVICES 43 |
491 | #define VM_MEMORY_CARBON VM_MEMORY_CORESERVICES | |
9bccf70c | 492 | #define VM_MEMORY_JAVA 44 |
39236c6e A |
493 | #define VM_MEMORY_COREDATA 45 |
494 | #define VM_MEMORY_COREDATA_OBJECTIDS 46 | |
1c79356b | 495 | #define VM_MEMORY_ATS 50 |
2d21ac55 A |
496 | #define VM_MEMORY_LAYERKIT 51 |
497 | #define VM_MEMORY_CGIMAGE 52 | |
498 | #define VM_MEMORY_TCMALLOC 53 | |
499 | ||
500 | /* private raster data (i.e. layers, some images, QGL allocator) */ | |
0a7de745 | 501 | #define VM_MEMORY_COREGRAPHICS_DATA 54 |
2d21ac55 A |
502 | |
503 | /* shared image and font caches */ | |
0a7de745 | 504 | #define VM_MEMORY_COREGRAPHICS_SHARED 55 |
2d21ac55 A |
505 | |
506 | /* Memory used for virtual framebuffers, shadowing buffers, etc... */ | |
0a7de745 | 507 | #define VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56 |
2d21ac55 A |
508 | |
509 | /* Window backing stores, custom shadow data, and compressed backing stores */ | |
0a7de745 | 510 | #define VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57 |
2d21ac55 | 511 | |
39037602 A |
512 | /* x-alloc'd memory */ |
513 | #define VM_MEMORY_COREGRAPHICS_XALLOC 58 | |
514 | ||
2d21ac55 A |
515 | /* catch-all for other uses, such as the read-only shared data page */ |
516 | #define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS | |
1c79356b | 517 | |
1c79356b A |
518 | /* memory allocated by the dynamic loader for itself */ |
519 | #define VM_MEMORY_DYLD 60 | |
520 | /* malloc'd memory created by dyld */ | |
521 | #define VM_MEMORY_DYLD_MALLOC 61 | |
522 | ||
b0d623f7 A |
523 | /* Used for sqlite page cache */ |
524 | #define VM_MEMORY_SQLITE 62 | |
525 | ||
526 | /* JavaScriptCore heaps */ | |
527 | #define VM_MEMORY_JAVASCRIPT_CORE 63 | |
5ba3f43e | 528 | #define VM_MEMORY_WEBASSEMBLY VM_MEMORY_JAVASCRIPT_CORE |
b0d623f7 A |
529 | /* memory allocated for the JIT */ |
530 | #define VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64 | |
531 | #define VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65 | |
532 | ||
533 | /* memory allocated for GLSL */ | |
534 | #define VM_MEMORY_GLSL 66 | |
535 | ||
6d2010ae A |
536 | /* memory allocated for OpenCL.framework */ |
537 | #define VM_MEMORY_OPENCL 67 | |
538 | ||
539 | /* memory allocated for QuartzCore.framework */ | |
540 | #define VM_MEMORY_COREIMAGE 68 | |
541 | ||
542 | /* memory allocated for WebCore Purgeable Buffers */ | |
543 | #define VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS 69 | |
544 | ||
545 | /* ImageIO memory */ | |
0a7de745 | 546 | #define VM_MEMORY_IMAGEIO 70 |
6d2010ae A |
547 | |
548 | /* CoreProfile memory */ | |
0a7de745 | 549 | #define VM_MEMORY_COREPROFILE 71 |
6d2010ae A |
550 | |
551 | /* assetsd / MobileSlideShow memory */ | |
0a7de745 | 552 | #define VM_MEMORY_ASSETSD 72 |
6d2010ae | 553 | |
39236c6e A |
554 | /* libsystem_kernel os_once_alloc */ |
555 | #define VM_MEMORY_OS_ALLOC_ONCE 73 | |
556 | ||
557 | /* libdispatch internal allocator */ | |
558 | #define VM_MEMORY_LIBDISPATCH 74 | |
559 | ||
560 | /* Accelerate.framework image backing stores */ | |
561 | #define VM_MEMORY_ACCELERATE 75 | |
562 | ||
563 | /* CoreUI image block data */ | |
564 | #define VM_MEMORY_COREUI 76 | |
565 | ||
fe8ab488 A |
566 | /* CoreUI image file */ |
567 | #define VM_MEMORY_COREUIFILE 77 | |
568 | ||
569 | /* Genealogy buffers */ | |
570 | #define VM_MEMORY_GENEALOGY 78 | |
571 | ||
3e170ce0 A |
572 | /* RawCamera VM allocated memory */ |
573 | #define VM_MEMORY_RAWCAMERA 79 | |
574 | ||
575 | /* corpse info for dead process */ | |
576 | #define VM_MEMORY_CORPSEINFO 80 | |
577 | ||
578 | /* Apple System Logger (ASL) messages */ | |
579 | #define VM_MEMORY_ASL 81 | |
580 | ||
39037602 A |
581 | /* Swift runtime */ |
582 | #define VM_MEMORY_SWIFT_RUNTIME 82 | |
583 | ||
584 | /* Swift metadata */ | |
585 | #define VM_MEMORY_SWIFT_METADATA 83 | |
586 | ||
587 | /* DHMM data */ | |
588 | #define VM_MEMORY_DHMM 84 | |
589 | ||
743345f9 | 590 | |
39037602 A |
591 | /* memory allocated by SceneKit.framework */ |
592 | #define VM_MEMORY_SCENEKIT 86 | |
593 | ||
594 | /* memory allocated by skywalk networking */ | |
595 | #define VM_MEMORY_SKYWALK 87 | |
596 | ||
5ba3f43e A |
597 | #define VM_MEMORY_IOSURFACE 88 |
598 | ||
599 | #define VM_MEMORY_LIBNETWORK 89 | |
600 | ||
601 | #define VM_MEMORY_AUDIO 90 | |
602 | ||
603 | #define VM_MEMORY_VIDEOBITSTREAM 91 | |
604 | ||
d9a64523 A |
605 | /* memory allocated by CoreMedia */ |
606 | #define VM_MEMORY_CM_XPC 92 | |
607 | ||
608 | #define VM_MEMORY_CM_RPC 93 | |
609 | ||
610 | #define VM_MEMORY_CM_MEMORYPOOL 94 | |
611 | ||
612 | #define VM_MEMORY_CM_READCACHE 95 | |
613 | ||
614 | #define VM_MEMORY_CM_CRABS 96 | |
615 | ||
616 | /* memory allocated for QuickLookThumbnailing */ | |
617 | #define VM_MEMORY_QUICKLOOK_THUMBNAILS 97 | |
618 | ||
619 | /* memory allocated by Accounts framework */ | |
620 | #define VM_MEMORY_ACCOUNTS 98 | |
621 | ||
cb323159 A |
622 | /* memory allocated by Sanitizer runtime libraries */ |
623 | #define VM_MEMORY_SANITIZER 99 | |
624 | ||
625 | /* Differentiate memory needed by GPU drivers and frameworks from generic IOKit allocations */ | |
626 | #define VM_MEMORY_IOACCELERATOR 100 | |
627 | ||
628 | /* memory allocated by CoreMedia for global image registration of frames */ | |
629 | #define VM_MEMORY_CM_REGWARP 101 | |
630 | ||
f427ee49 A |
631 | /* memory allocated by EmbeddedAcousticRecognition for speech decoder */ |
632 | #define VM_MEMORY_EAR_DECODER 102 | |
633 | ||
634 | /* CoreUI cached image data */ | |
635 | #define VM_MEMORY_COREUI_CACHED_IMAGE_DATA 103 | |
636 | ||
637 | /* Reserve 230-239 for Rosetta */ | |
638 | #define VM_MEMORY_ROSETTA 230 | |
639 | #define VM_MEMORY_ROSETTA_THREAD_CONTEXT 231 | |
640 | #define VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP 232 | |
641 | #define VM_MEMORY_ROSETTA_RETURN_STACK 233 | |
642 | #define VM_MEMORY_ROSETTA_EXECUTABLE_HEAP 234 | |
643 | #define VM_MEMORY_ROSETTA_USER_LDT 235 | |
644 | #define VM_MEMORY_ROSETTA_ARENA 236 | |
645 | #define VM_MEMORY_ROSETTA_10 239 | |
646 | ||
1c79356b A |
647 | /* Reserve 240-255 for application */ |
648 | #define VM_MEMORY_APPLICATION_SPECIFIC_1 240 | |
649 | #define VM_MEMORY_APPLICATION_SPECIFIC_16 255 | |
650 | ||
5ba3f43e | 651 | #if !XNU_KERNEL_PRIVATE |
2d21ac55 | 652 | #define VM_MAKE_TAG(tag) ((tag) << 24) |
5ba3f43e | 653 | #endif /* XNU_KERNEL_PRIVATE */ |
3e170ce0 A |
654 | |
655 | ||
656 | #if KERNEL_PRIVATE | |
657 | ||
658 | /* kernel map tags */ | |
39037602 | 659 | /* please add new definition strings to zprint */ |
3e170ce0 | 660 | |
0a7de745 A |
661 | #define VM_KERN_MEMORY_NONE 0 |
662 | ||
663 | #define VM_KERN_MEMORY_OSFMK 1 | |
664 | #define VM_KERN_MEMORY_BSD 2 | |
665 | #define VM_KERN_MEMORY_IOKIT 3 | |
666 | #define VM_KERN_MEMORY_LIBKERN 4 | |
667 | #define VM_KERN_MEMORY_OSKEXT 5 | |
668 | #define VM_KERN_MEMORY_KEXT 6 | |
669 | #define VM_KERN_MEMORY_IPC 7 | |
670 | #define VM_KERN_MEMORY_STACK 8 | |
671 | #define VM_KERN_MEMORY_CPU 9 | |
672 | #define VM_KERN_MEMORY_PMAP 10 | |
673 | #define VM_KERN_MEMORY_PTE 11 | |
674 | #define VM_KERN_MEMORY_ZONE 12 | |
675 | #define VM_KERN_MEMORY_KALLOC 13 | |
676 | #define VM_KERN_MEMORY_COMPRESSOR 14 | |
677 | #define VM_KERN_MEMORY_COMPRESSED_DATA 15 | |
678 | #define VM_KERN_MEMORY_PHANTOM_CACHE 16 | |
679 | #define VM_KERN_MEMORY_WAITQ 17 | |
680 | #define VM_KERN_MEMORY_DIAG 18 | |
681 | #define VM_KERN_MEMORY_LOG 19 | |
682 | #define VM_KERN_MEMORY_FILE 20 | |
683 | #define VM_KERN_MEMORY_MBUF 21 | |
684 | #define VM_KERN_MEMORY_UBC 22 | |
685 | #define VM_KERN_MEMORY_SECURITY 23 | |
686 | #define VM_KERN_MEMORY_MLOCK 24 | |
687 | #define VM_KERN_MEMORY_REASON 25 | |
688 | #define VM_KERN_MEMORY_SKYWALK 26 | |
689 | #define VM_KERN_MEMORY_LTABLE 27 | |
f427ee49 | 690 | #define VM_KERN_MEMORY_HV 28 |
0a7de745 | 691 | |
f427ee49 | 692 | #define VM_KERN_MEMORY_FIRST_DYNAMIC 29 |
3e170ce0 | 693 | /* out of tags: */ |
0a7de745 A |
694 | #define VM_KERN_MEMORY_ANY 255 |
695 | #define VM_KERN_MEMORY_COUNT 256 | |
3e170ce0 A |
696 | |
697 | /* end kernel map tags */ | |
698 | ||
699 | // mach_memory_info.flags | |
0a7de745 A |
700 | #define VM_KERN_SITE_TYPE 0x000000FF |
701 | #define VM_KERN_SITE_TAG 0x00000000 | |
702 | #define VM_KERN_SITE_KMOD 0x00000001 | |
703 | #define VM_KERN_SITE_KERNEL 0x00000002 | |
704 | #define VM_KERN_SITE_COUNTER 0x00000003 | |
705 | #define VM_KERN_SITE_WIRED 0x00000100 /* add to wired count */ | |
706 | #define VM_KERN_SITE_HIDE 0x00000200 /* no zprint */ | |
707 | #define VM_KERN_SITE_NAMED 0x00000400 | |
708 | #define VM_KERN_SITE_ZONE 0x00000800 | |
f427ee49 | 709 | #define VM_KERN_SITE_ZONE_VIEW 0x00001000 |
0a7de745 A |
710 | |
711 | #define VM_KERN_COUNT_MANAGED 0 | |
712 | #define VM_KERN_COUNT_RESERVED 1 | |
713 | #define VM_KERN_COUNT_WIRED 2 | |
714 | #define VM_KERN_COUNT_WIRED_MANAGED 3 | |
715 | #define VM_KERN_COUNT_STOLEN 4 | |
716 | #define VM_KERN_COUNT_LOPAGE 5 | |
717 | #define VM_KERN_COUNT_MAP_KERNEL 6 | |
718 | #define VM_KERN_COUNT_MAP_ZONE 7 | |
719 | #define VM_KERN_COUNT_MAP_KALLOC 8 | |
3e170ce0 | 720 | |
5ba3f43e A |
721 | #define VM_KERN_COUNT_WIRED_BOOT 9 |
722 | ||
0a7de745 | 723 | #define VM_KERN_COUNT_BOOT_STOLEN 10 |
5ba3f43e | 724 | |
f427ee49 A |
725 | /* The number of bytes from the kernel cache that are wired in memory */ |
726 | #define VM_KERN_COUNT_WIRED_STATIC_KERNELCACHE 11 | |
727 | ||
728 | #define VM_KERN_COUNTER_COUNT 12 | |
3e170ce0 A |
729 | |
730 | #endif /* KERNEL_PRIVATE */ | |
731 | ||
f427ee49 A |
732 | #ifdef __cplusplus |
733 | } | |
734 | #endif | |
735 | ||
0a7de745 | 736 | #endif /* _MACH_VM_STATISTICS_H_ */ |