1/*
2 * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
3 *
4 * @Apple_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
21 */
22
23#ifndef BSD_SYS_KDEBUG_TRIAGE_H
24#define BSD_SYS_KDEBUG_TRIAGE_H
25
26void delete_buffers_triage(void);
27
28#define KDBG_TRIAGE_CLASS_MASK (0xff000000)
29#define KDBG_TRIAGE_CLASS_OFFSET (24)
30#define KDBG_TRIAGE_CLASS_MAX (0xff)
31
32/* Unused but reserved for future use (possibly for payload encoding) */
33#define KDBG_TRIAGE_RESERVED (0)
34#define KDBG_TRIAGE_RESERVED_MASK (0x00ff0000)
35#define KDBG_TRIAGE_RESERVED_OFFSET (16)
36#define KDBG_TRIAGE_RESERVED_MAX (0xff)
37
38#define KDBG_TRIAGE_CODE_MASK (0x0000fffc)
39#define KDBG_TRIAGE_CODE_OFFSET (2)
40#define KDBG_TRIAGE_CODE_MAX (0x3fff)
41
42#define KDBG_TRIAGE_EVENTID(Class, Reserved, Code) \
43 (((unsigned)((Class) & 0xff) << KDBG_TRIAGE_CLASS_OFFSET) | \
44 ((unsigned)((Reserved) & 0xff) << KDBG_TRIAGE_RESERVED_OFFSET) | \
45 ((unsigned)((Code) & 0x3fff) << KDBG_TRIAGE_CODE_OFFSET))
46
47#define KDBG_TRIAGE_EXTRACT_CLASS(Debugid) \
48 ((uint8_t)(((Debugid) & KDBG_TRIAGE_CLASS_MASK) >> KDBG_TRIAGE_CLASS_OFFSET))
49#define KDBG_TRIAGE_EXTRACT_CODE(Debugid) \
50 ((uint16_t)(((Debugid) & KDBG_TRIAGE_CODE_MASK) >> KDBG_TRIAGE_CODE_OFFSET))
51
52#define KDBG_TRIAGE_MAX_STRINGS (5)
53#define KDBG_TRIAGE_MAX_STRLEN (128)
54
55/****** VM Codes Begin ******/
56#define KDBG_TRIAGE_SUBSYS_VM (1)
57
58enum vm_subsys_error_codes {
59 KDBG_TRIAGE_VM_PREFIX = 0,
60 KDBG_TRIAGE_VM_NO_DATA,
61 KDBG_TRIAGE_VM_TEXT_CORRUPTION,
62 KDBG_TRIAGE_VM_ADDRESS_NOT_FOUND,
63 KDBG_TRIAGE_VM_PROTECTION_FAILURE,
64 KDBG_TRIAGE_VM_FAULT_MEMORY_SHORTAGE,
65 KDBG_TRIAGE_VM_FAULT_COPY_MEMORY_SHORTAGE,
66 KDBG_TRIAGE_VM_FAULT_OBJCOPYSLOWLY_MEMORY_SHORTAGE,
67 KDBG_TRIAGE_VM_FAULT_OBJIOPLREQ_MEMORY_SHORTAGE,
68 KDBG_TRIAGE_VM_FAULT_INTERRUPTED,
69 KDBG_TRIAGE_VM_SUCCESS_NO_PAGE,
70 KDBG_TRIAGE_VM_GUARDPAGE_FAULT,
71 KDBG_TRIAGE_VM_NONZERO_PREEMPTION_LEVEL,
72 KDBG_TRIAGE_VM_BUSYPAGE_WAIT_INTERRUPTED,
73 KDBG_TRIAGE_VM_PURGEABLE_FAULT_ERROR,
74 KDBG_TRIAGE_VM_OBJECT_SHADOW_SEVERED,
75 KDBG_TRIAGE_VM_OBJECT_NOT_ALIVE,
76 KDBG_TRIAGE_VM_OBJECT_NO_PAGER,
77 KDBG_TRIAGE_VM_OBJECT_NO_PAGER_FORCED_UNMOUNT,
78 KDBG_TRIAGE_VM_OBJECT_NO_PAGER_UNGRAFT,
79 KDBG_TRIAGE_VM_PAGE_HAS_ERROR,
80 KDBG_TRIAGE_VM_PAGE_HAS_RESTART,
81 KDBG_TRIAGE_VM_FAILED_IMMUTABLE_PAGE_WRITE,
82 KDBG_TRIAGE_VM_FAILED_NX_PAGE_EXEC_MAPPING,
83 KDBG_TRIAGE_VM_PMAP_ENTER_RESOURCE_SHORTAGE,
84 KDBG_TRIAGE_VM_COMPRESSOR_GET_OUT_OF_RANGE,
85 KDBG_TRIAGE_VM_COMPRESSOR_GET_NO_PAGE,
86 KDBG_TRIAGE_VM_COMPRESSOR_DECOMPRESS_FAILED,
87 KDBG_TRIAGE_VM_SUBMAP_NO_COW_ON_EXECUTABLE,
88 KDBG_TRIAGE_VM_SUBMAP_COPY_SLOWLY_FAILED,
89 KDBG_TRIAGE_VM_SUBMAP_COPY_STRAT_FAILED,
90 KDBG_TRIAGE_VM_VNODEPAGER_CLREAD_NO_UPL,
91 KDBG_TRIAGE_VM_VNODEPAGEIN_NO_UBCINFO,
92 KDBG_TRIAGE_VM_VNODEPAGEIN_FSPAGEIN_FAIL,
93 KDBG_TRIAGE_VM_VNODEPAGEIN_NO_UPL,
94 KDBG_TRIAGE_VM_ECC_DIRTY,
95 KDBG_TRIAGE_VM_ECC_CLEAN,
96 KDBG_TRIAGE_VM_COPYOUTMAP_SAMEMAP_ERROR,
97 KDBG_TRIAGE_VM_COPYOUTMAP_DIFFERENTMAP_ERROR,
98 KDBG_TRIAGE_VM_COPYOVERWRITE_FULL_NESTED_ERROR,
99 KDBG_TRIAGE_VM_COPYOVERWRITE_PARTIAL_NESTED_ERROR,
100 KDBG_TRIAGE_VM_COPYOVERWRITE_PARTIAL_HEAD_NESTED_ERROR,
101 KDBG_TRIAGE_VM_COPYOVERWRITE_PARTIAL_TAIL_NESTED_ERROR,
102 KDBG_TRIAGE_VM_COPYOUT_INTERNAL_SIZE_ERROR,
103 KDBG_TRIAGE_VM_COPYOUT_KERNEL_BUFFER_ERROR,
104 KDBG_TRIAGE_VM_COPYOUT_INTERNAL_ADJUSTING_ERROR,
105 KDBG_TRIAGE_VM_COPYOUT_INTERNAL_SPACE_ERROR,
106 KDBG_TRIAGE_VM_ALLOCATE_KERNEL_BADFLAGS_ERROR,
107 KDBG_TRIAGE_VM_ALLOCATE_KERNEL_BADMAP_ERROR,
108 KDBG_TRIAGE_VM_ALLOCATE_KERNEL_BADSIZE_ERROR,
109 KDBG_TRIAGE_VM_ALLOCATE_KERNEL_VMMAPENTER_ERROR,
110 KDBG_TRIAGE_VM_CODE_SIGNING,
111 KDBG_TRIAGE_VM_MAX
112};
113#define VM_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_VM_MAX)
114
115/****** VM Codes End ******/
116
117/****** Cluster Codes Begin ******/
118#define KDBG_TRIAGE_SUBSYS_CLUSTER (2)
119
120enum cluster_subsys_error_codes {
121 KDBG_TRIAGE_CL_PREFIX = 0,
122 KDBG_TRIAGE_CL_PGIN_PAST_EOF,
123 KDBG_TRIAGE_CL_MAX
124};
125#define CLUSTER_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_CL_MAX)
126
127/****** Cluster Codes End ******/
128
129/****** Shared Region Codes Begin ******/
130#define KDBG_TRIAGE_SUBSYS_SHARED_REGION (3)
131
132enum shared_region_subsys_error_codes {
133 KDBG_TRIAGE_SHARED_REGION_PREFIX = 0,
134 KDBG_TRIAGE_SHARED_REGION_NO_UPL,
135 KDBG_TRIAGE_SHARED_REGION_SLIDE_ERROR,
136 KDBG_TRIAGE_SHARED_REGION_PAGER_MEMORY_SHORTAGE,
137 KDBG_TRIAGE_SHARED_REGION_MAX
138};
139#define SHARED_REGION_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_SHARED_REGION_MAX)
140
141/****** Shared Region Codes End ******/
142
143/****** DYLD pager Codes Begin ******/
144#define KDBG_TRIAGE_SUBSYS_DYLD_PAGER (4)
145
146enum dyld_pager_subsys_error_codes {
147 KDBG_TRIAGE_DYLD_PAGER_PREFIX = 0,
148 KDBG_TRIAGE_DYLD_PAGER_NO_UPL,
149 KDBG_TRIAGE_DYLD_PAGER_MEMORY_SHORTAGE,
150 KDBG_TRIAGE_DYLD_PAGER_SLIDE_ERROR,
151 KDBG_TRIAGE_DYLD_PAGER_CHAIN_OUT_OF_RANGE,
152 KDBG_TRIAGE_DYLD_PAGER_SEG_INFO_OUT_OF_RANGE,
153 KDBG_TRIAGE_DYLD_PAGER_SEG_SIZE_OUT_OF_RANGE,
154 KDBG_TRIAGE_DYLD_PAGER_SEG_PAGE_CNT_OUT_OF_RANGE,
155 KDBG_TRIAGE_DYLD_PAGER_NO_SEG_FOR_VA,
156 KDBG_TRIAGE_DYLD_PAGER_RANGE_NOT_FOUND,
157 KDBG_TRIAGE_DYLD_PAGER_DELTA_TOO_LARGE,
158 KDBG_TRIAGE_DYLD_PAGER_PAGE_START_OUT_OF_RANGE,
159 KDBG_TRIAGE_DYLD_PAGER_BAD_POINTER_FMT,
160 KDBG_TRIAGE_DYLD_PAGER_INVALID_AUTH_KEY,
161 KDBG_TRIAGE_DYLD_PAGER_BIND_ORDINAL,
162 KDBG_TRIAGE_DYLD_PAGER_MAX
163};
164#define DYLD_PAGER_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_DYLD_PAGER_MAX)
165
166/****** DYLD pager Codes End ******/
167
168/****** APPLE_PROTECT_PAGER pager Codes Begin ******/
169#define KDBG_TRIAGE_SUBSYS_APPLE_PROTECT_PAGER (5)
170
171enum apple_protect_pager_subsys_error_codes {
172 KDBG_TRIAGE_APPLE_PROTECT_PAGER_PREFIX = 0,
173 KDBG_TRIAGE_APPLE_PROTECT_PAGER_MEMORY_SHORTAGE,
174 KDBG_TRIAGE_APPLE_PROTECT_PAGER_MAX
175};
176#define APPLE_PROTECT_PAGER_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_APPLE_PROTECT_PAGER_MAX)
177
178/****** APPLE_PROTECT pager Codes End ******/
179
180/****** FOURK pager Codes Begin ******/
181#define KDBG_TRIAGE_SUBSYS_FOURK_PAGER (6)
182
183enum fourk_pager_subsys_error_codes {
184 KDBG_TRIAGE_FOURK_PAGER_PREFIX = 0,
185 KDBG_TRIAGE_FOURK_PAGER_MEMORY_SHORTAGE,
186 KDBG_TRIAGE_FOURK_PAGER_MAX
187};
188#define FOURK_PAGER_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_FOURK_PAGER_MAX)
189
190/****** FOURK pager Codes End ******/
191
192/****** Kext ktriage Begin ******/
193/*
194 * kexts can define their own strings and augment them with an argument.
195 * ktriage only needs to know the subsystem id, and expects that the first
196 * string will be the subsystem prefix string.
197 *
198 * Right now we don't support dynamically adding or removing subsystems.
199 */
200
201#define KDBG_TRIAGE_SUBSYS_APFS (7)
202#define KDBG_TRIAGE_SUBSYS_DECMPFS (8)
203
204/****** Kext ktriage End ******/
205
206/****** Corpse pager Codes Begin ******/
207#define KDBG_TRIAGE_SUBSYS_CORPSE (9)
208
209enum corpse_subsys_error_codes {
210 KDBG_TRIAGE_CORPSE_PREFIX = 0,
211 KDBG_TRIAGE_CORPSE_PROC_TOO_BIG,
212 KDBG_TRIAGE_CORPSE_FAIL_LIBGMALLOC,
213 KDBG_TRIAGE_CORPSE_BLOCKED_JETSAM,
214 KDBG_TRIAGE_CORPSE_LIMIT,
215 KDBG_TRIAGE_CORPSES_DISABLED,
216 KDBG_TRIAGE_CORPSE_DISABLED_FOR_PROC,
217 KDBG_TRIAGE_CORPSE_MAX
218};
219#define CORPSE_MAX_TRIAGE_STRINGS (KDBG_TRIAGE_CORPSE_MAX)
220
221/****** Corpse pager Codes End ******/
222
223/* please update KDBG_TRIAGE_SUBSYS_MAX when adding a new subsystem */
224
225#define KDBG_TRIAGE_SUBSYS_MAX KDBG_TRIAGE_SUBSYS_CORPSE
226
227#endif /* BSD_SYS_KDEBUG_TRIAGE_H */
228