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