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