1 /*
2 * Copyright (c) 2011 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 /*
30 * Make sure we don't accidentally include the external definitions of
31 * the routines we're interposing on below.
32 */
33 #define _vm_map_user_
34 #define _mach_vm_user_
35 #include <mach/mach.h>
36 #include <mach/mach_traps.h>
37 #undef _vm_map_user_
38 #include <mach/vm_map_internal.h>
39 #undef _mach_vm_user_
40 #include <mach/mach_vm_internal.h>
41 #include <mach/vm_statistics.h>
42
43 #include "stack_logging_internal.h"
44
45 malloc_logger_t *__syscall_logger = NULL; // This may get set by Libc's malloc stack logging initialization code.
46
47 kern_return_t
mach_vm_allocate(mach_port_name_t target,mach_vm_address_t * address,mach_vm_size_t size,int flags)48 mach_vm_allocate(
49 mach_port_name_t target,
50 mach_vm_address_t *address,
51 mach_vm_size_t size,
52 int flags)
53 {
54 kern_return_t rv;
55
56 rv = _kernelrpc_mach_vm_allocate_trap(target, address, size, flags);
57
58 if (rv == MACH_SEND_INVALID_DEST) {
59 rv = _kernelrpc_mach_vm_allocate(target, address, size, flags);
60 }
61
62 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
63 if (__syscall_logger && rv == KERN_SUCCESS && (userTagFlags != VM_MAKE_TAG(VM_MEMORY_STACK))) {
64 __syscall_logger(stack_logging_type_vm_allocate | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
65 }
66
67 return rv;
68 }
69
70 kern_return_t
mach_vm_deallocate(mach_port_name_t target,mach_vm_address_t address,mach_vm_size_t size)71 mach_vm_deallocate(
72 mach_port_name_t target,
73 mach_vm_address_t address,
74 mach_vm_size_t size)
75 {
76 kern_return_t rv;
77
78 if (__syscall_logger) {
79 __syscall_logger(stack_logging_type_vm_deallocate, (uintptr_t)target, (uintptr_t)address, (uintptr_t)size, 0, 0);
80 }
81
82 rv = _kernelrpc_mach_vm_deallocate_trap(target, address, size);
83
84 if (rv == MACH_SEND_INVALID_DEST) {
85 rv = _kernelrpc_mach_vm_deallocate(target, address, size);
86 }
87
88 return rv;
89 }
90
91 kern_return_t
mach_vm_protect(mach_port_name_t task,mach_vm_address_t address,mach_vm_size_t size,boolean_t set_maximum,vm_prot_t new_protection)92 mach_vm_protect(
93 mach_port_name_t task,
94 mach_vm_address_t address,
95 mach_vm_size_t size,
96 boolean_t set_maximum,
97 vm_prot_t new_protection)
98 {
99 kern_return_t rv;
100
101 rv = _kernelrpc_mach_vm_protect_trap(task, address, size, set_maximum,
102 new_protection);
103
104 if (rv == MACH_SEND_INVALID_DEST) {
105 rv = _kernelrpc_mach_vm_protect(task, address, size,
106 set_maximum, new_protection);
107 }
108
109 return rv;
110 }
111
112 kern_return_t
vm_allocate(mach_port_name_t task,vm_address_t * address,vm_size_t size,int flags)113 vm_allocate(
114 mach_port_name_t task,
115 vm_address_t *address,
116 vm_size_t size,
117 int flags)
118 {
119 kern_return_t rv;
120 mach_vm_address_t mach_addr;
121
122 mach_addr = (mach_vm_address_t)*address;
123 rv = mach_vm_allocate(task, &mach_addr, size, flags);
124 #if defined(__LP64__)
125 *address = mach_addr;
126 #else
127 *address = (vm_address_t)(mach_addr & ((vm_address_t)-1));
128 #endif
129
130 return rv;
131 }
132
133 kern_return_t
vm_deallocate(mach_port_name_t task,vm_address_t address,vm_size_t size)134 vm_deallocate(
135 mach_port_name_t task,
136 vm_address_t address,
137 vm_size_t size)
138 {
139 kern_return_t rv;
140
141 rv = mach_vm_deallocate(task, address, size);
142
143 return rv;
144 }
145
146 kern_return_t
vm_protect(mach_port_name_t task,vm_address_t address,vm_size_t size,boolean_t set_maximum,vm_prot_t new_protection)147 vm_protect(
148 mach_port_name_t task,
149 vm_address_t address,
150 vm_size_t size,
151 boolean_t set_maximum,
152 vm_prot_t new_protection)
153 {
154 kern_return_t rv;
155
156 rv = mach_vm_protect(task, address, size, set_maximum, new_protection);
157
158 return rv;
159 }
160
161 kern_return_t
mach_vm_map(mach_port_name_t target,mach_vm_address_t * address,mach_vm_size_t size,mach_vm_offset_t mask,int flags,mem_entry_name_port_t object,memory_object_offset_t offset,boolean_t copy,vm_prot_t cur_protection,vm_prot_t max_protection,vm_inherit_t inheritance)162 mach_vm_map(
163 mach_port_name_t target,
164 mach_vm_address_t *address,
165 mach_vm_size_t size,
166 mach_vm_offset_t mask,
167 int flags,
168 mem_entry_name_port_t object,
169 memory_object_offset_t offset,
170 boolean_t copy,
171 vm_prot_t cur_protection,
172 vm_prot_t max_protection,
173 vm_inherit_t inheritance)
174 {
175 kern_return_t rv = MACH_SEND_INVALID_DEST;
176
177 if (object == MEMORY_OBJECT_NULL && max_protection == VM_PROT_ALL &&
178 inheritance == VM_INHERIT_DEFAULT) {
179 rv = _kernelrpc_mach_vm_map_trap(target, address, size, mask, flags,
180 cur_protection);
181 }
182
183 if (rv == MACH_SEND_INVALID_DEST) {
184 rv = _kernelrpc_mach_vm_map(target, address, size, mask, flags, object,
185 offset, copy, cur_protection, max_protection, inheritance);
186 }
187
188 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
189 if (__syscall_logger && rv == KERN_SUCCESS && (userTagFlags != VM_MAKE_TAG(VM_MEMORY_STACK))) {
190 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
191 __syscall_logger(eventTypeFlags | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
192 }
193
194 return rv;
195 }
196
197 kern_return_t
mach_vm_remap(mach_port_name_t target,mach_vm_address_t * address,mach_vm_size_t size,mach_vm_offset_t mask,int flags,mach_port_name_t src_task,mach_vm_address_t src_address,boolean_t copy,vm_prot_t * cur_protection,vm_prot_t * max_protection,vm_inherit_t inheritance)198 mach_vm_remap(
199 mach_port_name_t target,
200 mach_vm_address_t *address,
201 mach_vm_size_t size,
202 mach_vm_offset_t mask,
203 int flags,
204 mach_port_name_t src_task,
205 mach_vm_address_t src_address,
206 boolean_t copy,
207 vm_prot_t *cur_protection,
208 vm_prot_t *max_protection,
209 vm_inherit_t inheritance)
210 {
211 kern_return_t rv;
212
213 rv = _kernelrpc_mach_vm_remap(target, address, size, mask, flags,
214 src_task, src_address, copy, cur_protection, max_protection,
215 inheritance);
216
217 if (__syscall_logger && rv == KERN_SUCCESS) {
218 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
219 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
220 __syscall_logger(eventTypeFlags | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
221 }
222
223 return rv;
224 }
225
226 kern_return_t
mach_vm_remap_new(mach_port_name_t target,mach_vm_address_t * address,mach_vm_size_t size,mach_vm_offset_t mask,int flags,mach_port_name_t src_task,mach_vm_address_t src_address,boolean_t copy,vm_prot_t * cur_protection,vm_prot_t * max_protection,vm_inherit_t inheritance)227 mach_vm_remap_new(
228 mach_port_name_t target,
229 mach_vm_address_t *address,
230 mach_vm_size_t size,
231 mach_vm_offset_t mask,
232 int flags,
233 mach_port_name_t src_task,
234 mach_vm_address_t src_address,
235 boolean_t copy,
236 vm_prot_t *cur_protection,
237 vm_prot_t *max_protection,
238 vm_inherit_t inheritance)
239 {
240 kern_return_t rv;
241
242 /* {max,cur}_protection is inout */
243 rv = _kernelrpc_mach_vm_remap_new(target, address, size, mask, flags,
244 src_task, src_address, copy, cur_protection, max_protection,
245 inheritance);
246
247 if (__syscall_logger && rv == KERN_SUCCESS) {
248 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
249 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
250 __syscall_logger(eventTypeFlags | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
251 }
252
253 return rv;
254 }
255
256 kern_return_t
mach_vm_read(mach_port_name_t target,mach_vm_address_t address,mach_vm_size_t size,vm_offset_t * data,mach_msg_type_number_t * dataCnt)257 mach_vm_read(
258 mach_port_name_t target,
259 mach_vm_address_t address,
260 mach_vm_size_t size,
261 vm_offset_t *data,
262 mach_msg_type_number_t *dataCnt)
263 {
264 kern_return_t rv;
265
266 rv = _kernelrpc_mach_vm_read(target, address, size, data, dataCnt);
267
268 if (__syscall_logger && rv == KERN_SUCCESS) {
269 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
270 // The target argument is the remote task from which data is being read,
271 // so pass mach_task_self() as the destination task receiving the allocation.
272 __syscall_logger(eventTypeFlags, (uintptr_t)mach_task_self(), (uintptr_t)*dataCnt, 0, *data, 0);
273 }
274
275 return rv;
276 }
277
278 kern_return_t
vm_map(mach_port_name_t target,vm_address_t * address,vm_size_t size,vm_offset_t mask,int flags,mem_entry_name_port_t object,vm_offset_t offset,boolean_t copy,vm_prot_t cur_protection,vm_prot_t max_protection,vm_inherit_t inheritance)279 vm_map(
280 mach_port_name_t target,
281 vm_address_t *address,
282 vm_size_t size,
283 vm_offset_t mask,
284 int flags,
285 mem_entry_name_port_t object,
286 vm_offset_t offset,
287 boolean_t copy,
288 vm_prot_t cur_protection,
289 vm_prot_t max_protection,
290 vm_inherit_t inheritance)
291 {
292 kern_return_t rv;
293
294 rv = _kernelrpc_vm_map(target, address, size, mask, flags, object,
295 offset, copy, cur_protection, max_protection, inheritance);
296
297 if (__syscall_logger && rv == KERN_SUCCESS) {
298 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
299 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
300 __syscall_logger(eventTypeFlags | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
301 }
302
303 return rv;
304 }
305
306 kern_return_t
vm_remap(mach_port_name_t target,vm_address_t * address,vm_size_t size,vm_offset_t mask,int flags,mach_port_name_t src_task,vm_address_t src_address,boolean_t copy,vm_prot_t * cur_protection,vm_prot_t * max_protection,vm_inherit_t inheritance)307 vm_remap(
308 mach_port_name_t target,
309 vm_address_t *address,
310 vm_size_t size,
311 vm_offset_t mask,
312 int flags,
313 mach_port_name_t src_task,
314 vm_address_t src_address,
315 boolean_t copy,
316 vm_prot_t *cur_protection,
317 vm_prot_t *max_protection,
318 vm_inherit_t inheritance)
319 {
320 kern_return_t rv;
321
322 rv = _kernelrpc_vm_remap(target, address, size, mask, flags,
323 src_task, src_address, copy, cur_protection, max_protection,
324 inheritance);
325
326 if (__syscall_logger) {
327 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
328 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
329 __syscall_logger(eventTypeFlags | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
330 }
331
332 return rv;
333 }
334
335 kern_return_t
vm_remap_new(mach_port_name_t target,vm_address_t * address,vm_size_t size,vm_offset_t mask,int flags,mach_port_name_t src_task,vm_address_t src_address,boolean_t copy,vm_prot_t * cur_protection,vm_prot_t * max_protection,vm_inherit_t inheritance)336 vm_remap_new(
337 mach_port_name_t target,
338 vm_address_t *address,
339 vm_size_t size,
340 vm_offset_t mask,
341 int flags,
342 mach_port_name_t src_task,
343 vm_address_t src_address,
344 boolean_t copy,
345 vm_prot_t *cur_protection,
346 vm_prot_t *max_protection,
347 vm_inherit_t inheritance)
348 {
349 kern_return_t rv;
350
351 /* {max,cur}_protection is inout */
352 rv = _kernelrpc_vm_remap_new(target, address, size, mask, flags,
353 src_task, src_address, copy, cur_protection, max_protection,
354 inheritance);
355
356 if (__syscall_logger) {
357 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
358 int userTagFlags = flags & VM_FLAGS_ALIAS_MASK;
359 __syscall_logger(eventTypeFlags | userTagFlags, (uintptr_t)target, (uintptr_t)size, 0, (uintptr_t)*address, 0);
360 }
361
362 return rv;
363 }
364
365 kern_return_t
vm_read(mach_port_name_t target,vm_address_t address,vm_size_t size,vm_offset_t * data,mach_msg_type_number_t * dataCnt)366 vm_read(
367 mach_port_name_t target,
368 vm_address_t address,
369 vm_size_t size,
370 vm_offset_t *data,
371 mach_msg_type_number_t *dataCnt)
372 {
373 kern_return_t rv;
374
375 rv = _kernelrpc_vm_read(target, address, size, data, dataCnt);
376
377 if (__syscall_logger && rv == KERN_SUCCESS) {
378 int eventTypeFlags = stack_logging_type_vm_allocate | stack_logging_type_mapped_file_or_shared_mem;
379 // The target argument is the remote task from which data is being read,
380 // so pass mach_task_self() as the destination task receiving the allocation.
381 __syscall_logger(eventTypeFlags, (uintptr_t)mach_task_self(), (uintptr_t)*dataCnt, 0, *data, 0);
382 }
383
384 return rv;
385 }
386
387 kern_return_t
mach_vm_purgable_control(mach_port_name_t target,mach_vm_offset_t address,vm_purgable_t control,int * state)388 mach_vm_purgable_control(
389 mach_port_name_t target,
390 mach_vm_offset_t address,
391 vm_purgable_t control,
392 int *state)
393 {
394 kern_return_t rv;
395
396 rv = _kernelrpc_mach_vm_purgable_control_trap(target, address, control, state);
397
398 if (rv == MACH_SEND_INVALID_DEST) {
399 rv = _kernelrpc_mach_vm_purgable_control(target, address, control, state);
400 }
401
402 return rv;
403 }
404
405 kern_return_t
vm_purgable_control(mach_port_name_t task,vm_offset_t address,vm_purgable_t control,int * state)406 vm_purgable_control(
407 mach_port_name_t task,
408 vm_offset_t address,
409 vm_purgable_t control,
410 int *state)
411 {
412 return mach_vm_purgable_control(task,
413 (mach_vm_offset_t) address,
414 control,
415 state);
416 }
417
418 kern_return_t
mach_vm_update_pointers_with_remote_tags(mach_port_name_t target,mach_vm_offset_list_t in_pointer_list,mach_msg_type_number_t in_pointer_listCnt,mach_vm_offset_list_t out_pointer_list,mach_msg_type_number_t * out_pointer_listCnt)419 mach_vm_update_pointers_with_remote_tags(
420 mach_port_name_t target,
421 mach_vm_offset_list_t in_pointer_list,
422 mach_msg_type_number_t in_pointer_listCnt,
423 mach_vm_offset_list_t out_pointer_list,
424 mach_msg_type_number_t *out_pointer_listCnt)
425 {
426 return _kernelrpc_mach_vm_update_pointers_with_remote_tags(target, in_pointer_list, in_pointer_listCnt, out_pointer_list, out_pointer_listCnt);
427 }
428
429 /*
430 * The tag descriptions provided here are primarily exposed via vmmap(1)
431 * and footprint(1). The tag descriptions displayed by these tools must be
432 * human-readable and conform to a maximum length of 24 characters in order
433 * to fit within vmmap(1)'s type name column. i.e. 123456789012345678901234
434 */
435 static const char *vm_tag_descriptions[VM_MEMORY_COUNT] = {
436 /* vmmap also uses "shared memory" */
437 /* maximum width indicator 123456789012345678901234 */
438 [0] = "Untagged",
439 [VM_MEMORY_MALLOC] = "Malloc Metadata",
440 [VM_MEMORY_MALLOC_SMALL] = "Malloc Small",
441 [VM_MEMORY_MALLOC_LARGE] = "Malloc Large",
442 [VM_MEMORY_MALLOC_HUGE] = "Malloc Huge",
443 [VM_MEMORY_SBRK] = "SBRK",
444 [VM_MEMORY_REALLOC] = "Malloc Realloc",
445 [VM_MEMORY_MALLOC_TINY] = "Malloc Tiny",
446 [VM_MEMORY_MALLOC_LARGE_REUSABLE] = "Malloc Large (Reusable)",
447 [VM_MEMORY_MALLOC_LARGE_REUSED] = "Malloc Large (Reused)",
448 /* maximum width indicator 123456789012345678901234 */
449 [VM_MEMORY_ANALYSIS_TOOL] = "Performance Tool Data",
450 [VM_MEMORY_MALLOC_NANO] = "Malloc Nano",
451 [VM_MEMORY_MALLOC_MEDIUM] = "Malloc Medium",
452 [VM_MEMORY_MALLOC_PROB_GUARD] = "Malloc Prob. Guard",
453 [14] = "VM_MEMORY_14",
454 [15] = "VM_MEMORY_15",
455 [16] = "VM_MEMORY_16",
456 [17] = "VM_MEMORY_17",
457 [18] = "VM_MEMORY_18",
458 [19] = "VM_MEMORY_19",
459 /* maximum width indicator 123456789012345678901234 */
460 [VM_MEMORY_MACH_MSG] = "Mach Message",
461 [VM_MEMORY_IOKIT] = "IOKit",
462 [22] = "VM_MEMORY_22",
463 [23] = "VM_MEMORY_23",
464 [24] = "VM_MEMORY_24",
465 [25] = "VM_MEMORY_25",
466 [26] = "VM_MEMORY_26",
467 [27] = "VM_MEMORY_27",
468 [28] = "VM_MEMORY_28",
469 [29] = "VM_MEMORY_29",
470 /* maximum width indicator 123456789012345678901234 */
471 [VM_MEMORY_STACK] = "Stack",
472 [VM_MEMORY_GUARD] = "Guard",
473 [VM_MEMORY_SHARED_PMAP] = "Shared Pmap",
474 [VM_MEMORY_DYLIB] = "Dylib",
475 [VM_MEMORY_OBJC_DISPATCHERS] = "ObjC Dispatching Code",
476 [VM_MEMORY_UNSHARED_PMAP] = "Unshared Pmap",
477 [VM_MEMORY_LIBCHANNEL] = "Channel Library",
478 [37] = "VM_MEMORY_37",
479 [38] = "VM_MEMORY_38",
480 [39] = "VM_MEMORY_39",
481 /* maximum width indicator 123456789012345678901234 */
482 [VM_MEMORY_APPKIT] = "AppKit",
483 [VM_MEMORY_FOUNDATION] = "Foundation",
484 [VM_MEMORY_COREGRAPHICS] = "CoreGraphics",
485 [VM_MEMORY_CORESERVICES] = "CoreServices",
486 [VM_MEMORY_JAVA] = "Java",
487 [VM_MEMORY_COREDATA] = "CoreData",
488 [VM_MEMORY_COREDATA_OBJECTIDS] = "CoreData Object IDs",
489 [47] = "VM_MEMORY_47",
490 [48] = "VM_MEMORY_48",
491 [49] = "VM_MEMORY_49",
492 /* maximum width indicator 123456789012345678901234 */
493 [VM_MEMORY_ATS] = "ATS (Font Support)",
494 [VM_MEMORY_LAYERKIT] = "CoreAnimation",
495 [VM_MEMORY_CGIMAGE] = "CG Image",
496 [VM_MEMORY_TCMALLOC] = "WebKit Malloc",
497 [VM_MEMORY_COREGRAPHICS_DATA] = "CG Raster Data",
498 [VM_MEMORY_COREGRAPHICS_SHARED] = "CG Shared Images",
499 [VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS] = "CG Frame Buffers",
500 [VM_MEMORY_COREGRAPHICS_BACKINGSTORES] = "CG Backing Stores",
501 [VM_MEMORY_COREGRAPHICS_XALLOC] = "CG Xalloc",
502 [59] = "VM_MEMORY_59",
503 /* maximum width indicator 123456789012345678901234 */
504 [VM_MEMORY_DYLD] = "Dyld Private Memory",
505 [VM_MEMORY_DYLD_MALLOC] = "Dyld Malloc Memory",
506 [VM_MEMORY_SQLITE] = "SQLite Page Cache",
507 [VM_MEMORY_WEBASSEMBLY] = "WebAssembly Memory",
508 [VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR] = "JS JIT Generated Code",
509 [VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE] = "JS VM Register File",
510 [VM_MEMORY_GLSL] = "OpenGL GLSL",
511 [VM_MEMORY_OPENCL] = "OpenCL",
512 [VM_MEMORY_COREIMAGE] = "CoreImage",
513 [VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS] = "WebCore Purgeable Data",
514 /* maximum width indicator 123456789012345678901234 */
515 [VM_MEMORY_IMAGEIO] = "Image IO",
516 [VM_MEMORY_COREPROFILE] = "CoreProfile",
517 [VM_MEMORY_ASSETSD] = "Assets Library",
518 [VM_MEMORY_OS_ALLOC_ONCE] = "OS Alloc Once",
519 [VM_MEMORY_LIBDISPATCH] = "Dispatch Continuations",
520 [VM_MEMORY_ACCELERATE] = "Accelerate Framework",
521 [VM_MEMORY_COREUI] = "CoreUI Image Data",
522 [VM_MEMORY_COREUIFILE] = "CoreUI Image File",
523 [VM_MEMORY_GENEALOGY] = "Activity Tracing",
524 [VM_MEMORY_RAWCAMERA] = "RawCamera",
525 /* maximum width indicator 123456789012345678901234 */
526 [VM_MEMORY_CORPSEINFO] = "Process Corpse Info",
527 [VM_MEMORY_ASL] = "Apple System Log",
528 [VM_MEMORY_SWIFT_RUNTIME] = "Swift Runtime",
529 [VM_MEMORY_SWIFT_METADATA] = "Swift Metadata",
530 [VM_MEMORY_DHMM] = "DHMM",
531 [VM_MEMORY_DFR] = "DFR",
532 [VM_MEMORY_SCENEKIT] = "SceneKit",
533 [VM_MEMORY_SKYWALK] = "Skywalk Networking",
534 [VM_MEMORY_IOSURFACE] = "IOSurface",
535 [VM_MEMORY_LIBNETWORK] = "Libnetwork",
536 /* maximum width indicator 123456789012345678901234 */
537 [VM_MEMORY_AUDIO] = "Audio",
538 [VM_MEMORY_VIDEOBITSTREAM] = "Video Bitstream",
539 [VM_MEMORY_CM_XPC] = "CoreMedia XPC",
540 [VM_MEMORY_CM_RPC] = "CoreMedia RPC",
541 [VM_MEMORY_CM_MEMORYPOOL] = "CoreMedia Memory Pool",
542 [VM_MEMORY_CM_READCACHE] = "CoreMedia Read Cache",
543 [VM_MEMORY_CM_CRABS] = "CoreMedia HTTP Cache",
544 [VM_MEMORY_QUICKLOOK_THUMBNAILS] = "QuickLook Thumbnails",
545 [VM_MEMORY_ACCOUNTS] = "Accounts Framework",
546 [VM_MEMORY_SANITIZER] = "Sanitizer",
547 /* maximum width indicator 123456789012345678901234 */
548 [VM_MEMORY_IOACCELERATOR] = "IOAccelerator",
549 [VM_MEMORY_CM_REGWARP] = "CoreMedia Capture Data",
550 [VM_MEMORY_EAR_DECODER] = "EAR Speech Decoder",
551 [VM_MEMORY_COREUI_CACHED_IMAGE_DATA] = "CoreUI Cache Image Data",
552 [VM_MEMORY_COLORSYNC] = "ColorSync",
553 [VM_MEMORY_BTINFO] = "Simulated Crash Data",
554 [VM_MEMORY_CM_HLS] = "CoreMedia HLS",
555 [107] = "VM_MEMORY_107",
556 [108] = "VM_MEMORY_108",
557 [109] = "VM_MEMORY_109",
558 /* maximum width indicator 123456789012345678901234 */
559 [110] = "VM_MEMORY_110",
560 [111] = "VM_MEMORY_111",
561 [112] = "VM_MEMORY_112",
562 [113] = "VM_MEMORY_113",
563 [114] = "VM_MEMORY_114",
564 [115] = "VM_MEMORY_115",
565 [116] = "VM_MEMORY_116",
566 [117] = "VM_MEMORY_117",
567 [118] = "VM_MEMORY_118",
568 [119] = "VM_MEMORY_119",
569 /* maximum width indicator 123456789012345678901234 */
570 [120] = "VM_MEMORY_120",
571 [121] = "VM_MEMORY_121",
572 [122] = "VM_MEMORY_122",
573 [123] = "VM_MEMORY_123",
574 [124] = "VM_MEMORY_124",
575 [125] = "VM_MEMORY_125",
576 [126] = "VM_MEMORY_126",
577 [127] = "VM_MEMORY_127",
578 [128] = "VM_MEMORY_128",
579 [129] = "VM_MEMORY_129",
580 /* maximum width indicator 123456789012345678901234 */
581 [130] = "VM_MEMORY_130",
582 [131] = "VM_MEMORY_131",
583 [132] = "VM_MEMORY_132",
584 [133] = "VM_MEMORY_133",
585 [134] = "VM_MEMORY_134",
586 [135] = "VM_MEMORY_135",
587 [136] = "VM_MEMORY_136",
588 [137] = "VM_MEMORY_137",
589 [138] = "VM_MEMORY_138",
590 [139] = "VM_MEMORY_139",
591 /* maximum width indicator 123456789012345678901234 */
592 [140] = "VM_MEMORY_140",
593 [141] = "VM_MEMORY_141",
594 [142] = "VM_MEMORY_142",
595 [143] = "VM_MEMORY_143",
596 [144] = "VM_MEMORY_144",
597 [145] = "VM_MEMORY_145",
598 [146] = "VM_MEMORY_146",
599 [147] = "VM_MEMORY_147",
600 [148] = "VM_MEMORY_148",
601 [149] = "VM_MEMORY_149",
602 /* maximum width indicator 123456789012345678901234 */
603 [150] = "VM_MEMORY_150",
604 [151] = "VM_MEMORY_151",
605 [152] = "VM_MEMORY_152",
606 [153] = "VM_MEMORY_153",
607 [154] = "VM_MEMORY_154",
608 [155] = "VM_MEMORY_155",
609 [156] = "VM_MEMORY_156",
610 [157] = "VM_MEMORY_157",
611 [158] = "VM_MEMORY_158",
612 [159] = "VM_MEMORY_159",
613 /* maximum width indicator 123456789012345678901234 */
614 [160] = "VM_MEMORY_160",
615 [161] = "VM_MEMORY_161",
616 [162] = "VM_MEMORY_162",
617 [163] = "VM_MEMORY_163",
618 [164] = "VM_MEMORY_164",
619 [165] = "VM_MEMORY_165",
620 [166] = "VM_MEMORY_166",
621 [167] = "VM_MEMORY_167",
622 [168] = "VM_MEMORY_168",
623 [169] = "VM_MEMORY_169",
624 /* maximum width indicator 123456789012345678901234 */
625 [170] = "VM_MEMORY_170",
626 [171] = "VM_MEMORY_171",
627 [172] = "VM_MEMORY_172",
628 [173] = "VM_MEMORY_173",
629 [174] = "VM_MEMORY_174",
630 [175] = "VM_MEMORY_175",
631 [176] = "VM_MEMORY_176",
632 [177] = "VM_MEMORY_177",
633 [178] = "VM_MEMORY_178",
634 [179] = "VM_MEMORY_179",
635 /* maximum width indicator 123456789012345678901234 */
636 [180] = "VM_MEMORY_180",
637 [181] = "VM_MEMORY_181",
638 [182] = "VM_MEMORY_182",
639 [183] = "VM_MEMORY_183",
640 [184] = "VM_MEMORY_184",
641 [185] = "VM_MEMORY_185",
642 [186] = "VM_MEMORY_186",
643 [187] = "VM_MEMORY_187",
644 [188] = "VM_MEMORY_188",
645 [189] = "VM_MEMORY_189",
646 /* maximum width indicator 123456789012345678901234 */
647 [190] = "VM_MEMORY_190",
648 [191] = "VM_MEMORY_191",
649 [192] = "VM_MEMORY_192",
650 [193] = "VM_MEMORY_193",
651 [194] = "VM_MEMORY_194",
652 [195] = "VM_MEMORY_195",
653 [196] = "VM_MEMORY_196",
654 [197] = "VM_MEMORY_197",
655 [198] = "VM_MEMORY_198",
656 [199] = "VM_MEMORY_199",
657 /* maximum width indicator 123456789012345678901234 */
658 [200] = "VM_MEMORY_200",
659 [201] = "VM_MEMORY_201",
660 [202] = "VM_MEMORY_202",
661 [203] = "VM_MEMORY_203",
662 [204] = "VM_MEMORY_204",
663 [205] = "VM_MEMORY_205",
664 [206] = "VM_MEMORY_206",
665 [207] = "VM_MEMORY_207",
666 [208] = "VM_MEMORY_208",
667 [209] = "VM_MEMORY_209",
668 /* maximum width indicator 123456789012345678901234 */
669 [210] = "VM_MEMORY_210",
670 [211] = "VM_MEMORY_211",
671 [212] = "VM_MEMORY_212",
672 [213] = "VM_MEMORY_213",
673 [214] = "VM_MEMORY_214",
674 [215] = "VM_MEMORY_215",
675 [216] = "VM_MEMORY_216",
676 [217] = "VM_MEMORY_217",
677 [218] = "VM_MEMORY_218",
678 [219] = "VM_MEMORY_219",
679 /* maximum width indicator 123456789012345678901234 */
680 [220] = "VM_MEMORY_220",
681 [221] = "VM_MEMORY_221",
682 [222] = "VM_MEMORY_222",
683 [223] = "VM_MEMORY_223",
684 [224] = "VM_MEMORY_224",
685 [225] = "VM_MEMORY_225",
686 [226] = "VM_MEMORY_226",
687 [227] = "VM_MEMORY_227",
688 [228] = "VM_MEMORY_228",
689 [229] = "VM_MEMORY_229",
690 /* maximum width indicator 123456789012345678901234 */
691 [VM_MEMORY_ROSETTA] = "Rosetta Generic",
692 [VM_MEMORY_ROSETTA_THREAD_CONTEXT] = "Rosetta Thread Context",
693 [VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP] = "Rosetta IndirectBranch",
694 [VM_MEMORY_ROSETTA_RETURN_STACK] = "Rosetta Return Stack",
695 [VM_MEMORY_ROSETTA_EXECUTABLE_HEAP] = "Rosetta JIT",
696 [VM_MEMORY_ROSETTA_USER_LDT] = "Rosetta User LDT",
697 [VM_MEMORY_ROSETTA_ARENA] = "Rosetta Arena",
698 [237] = "VM_MEMORY_237",
699 [238] = "VM_MEMORY_238",
700 [VM_MEMORY_ROSETTA_10] = "Rosetta Tag 10",
701 /* maximum width indicator 123456789012345678901234 */
702 [VM_MEMORY_APPLICATION_SPECIFIC_1] = "App-Specific Tag 1",
703 [VM_MEMORY_APPLICATION_SPECIFIC_2] = "App-Specific Tag 2",
704 [VM_MEMORY_APPLICATION_SPECIFIC_3] = "App-Specific Tag 3",
705 [VM_MEMORY_APPLICATION_SPECIFIC_4] = "App-Specific Tag 4",
706 [VM_MEMORY_APPLICATION_SPECIFIC_5] = "App-Specific Tag 5",
707 [VM_MEMORY_APPLICATION_SPECIFIC_6] = "App-Specific Tag 6",
708 [VM_MEMORY_APPLICATION_SPECIFIC_7] = "App-Specific Tag 7",
709 [VM_MEMORY_APPLICATION_SPECIFIC_8] = "App-Specific Tag 8",
710 [VM_MEMORY_APPLICATION_SPECIFIC_9] = "App-Specific Tag 9",
711 /* maximum width indicator 123456789012345678901234 */
712 [VM_MEMORY_APPLICATION_SPECIFIC_10] = "App-Specific Tag 10",
713 [VM_MEMORY_APPLICATION_SPECIFIC_11] = "App-Specific Tag 11",
714 [VM_MEMORY_APPLICATION_SPECIFIC_12] = "App-Specific Tag 12",
715 [VM_MEMORY_APPLICATION_SPECIFIC_13] = "App-Specific Tag 13",
716 [VM_MEMORY_APPLICATION_SPECIFIC_14] = "App-Specific Tag 14",
717 [VM_MEMORY_APPLICATION_SPECIFIC_15] = "App-Specific Tag 15",
718 [VM_MEMORY_APPLICATION_SPECIFIC_16] = "App-Specific Tag 16",
719 };
720
721 const char *
mach_vm_tag_describe(unsigned int tag)722 mach_vm_tag_describe(unsigned int tag)
723 {
724 if (tag < VM_MEMORY_COUNT) {
725 return vm_tag_descriptions[tag];
726 }
727 return "Invalid Tag (?)";
728 }
729