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