1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Machine check exception header file. 4 * 5 * Copyright 2013 IBM Corporation 6 * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> 7 */ 8 9 #ifndef __ASM_PPC64_MCE_H__ 10 #define __ASM_PPC64_MCE_H__ 11 12 #include <linux/bitops.h> 13 14 enum MCE_Version { 15 MCE_V1 = 1, 16 }; 17 18 enum MCE_Severity { 19 MCE_SEV_NO_ERROR = 0, 20 MCE_SEV_WARNING = 1, 21 MCE_SEV_SEVERE = 2, 22 MCE_SEV_FATAL = 3, 23 }; 24 25 enum MCE_Disposition { 26 MCE_DISPOSITION_RECOVERED = 0, 27 MCE_DISPOSITION_NOT_RECOVERED = 1, 28 }; 29 30 enum MCE_Initiator { 31 MCE_INITIATOR_UNKNOWN = 0, 32 MCE_INITIATOR_CPU = 1, 33 }; 34 35 enum MCE_ErrorType { 36 MCE_ERROR_TYPE_UNKNOWN = 0, 37 MCE_ERROR_TYPE_UE = 1, 38 MCE_ERROR_TYPE_SLB = 2, 39 MCE_ERROR_TYPE_ERAT = 3, 40 MCE_ERROR_TYPE_TLB = 4, 41 MCE_ERROR_TYPE_USER = 5, 42 MCE_ERROR_TYPE_RA = 6, 43 MCE_ERROR_TYPE_LINK = 7, 44 }; 45 46 enum MCE_ErrorClass { 47 MCE_ECLASS_UNKNOWN = 0, 48 MCE_ECLASS_HARDWARE, 49 MCE_ECLASS_HARD_INDETERMINATE, 50 MCE_ECLASS_SOFTWARE, 51 MCE_ECLASS_SOFT_INDETERMINATE, 52 }; 53 54 enum MCE_UeErrorType { 55 MCE_UE_ERROR_INDETERMINATE = 0, 56 MCE_UE_ERROR_IFETCH = 1, 57 MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2, 58 MCE_UE_ERROR_LOAD_STORE = 3, 59 MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4, 60 }; 61 62 enum MCE_SlbErrorType { 63 MCE_SLB_ERROR_INDETERMINATE = 0, 64 MCE_SLB_ERROR_PARITY = 1, 65 MCE_SLB_ERROR_MULTIHIT = 2, 66 }; 67 68 enum MCE_EratErrorType { 69 MCE_ERAT_ERROR_INDETERMINATE = 0, 70 MCE_ERAT_ERROR_PARITY = 1, 71 MCE_ERAT_ERROR_MULTIHIT = 2, 72 }; 73 74 enum MCE_TlbErrorType { 75 MCE_TLB_ERROR_INDETERMINATE = 0, 76 MCE_TLB_ERROR_PARITY = 1, 77 MCE_TLB_ERROR_MULTIHIT = 2, 78 }; 79 80 enum MCE_UserErrorType { 81 MCE_USER_ERROR_INDETERMINATE = 0, 82 MCE_USER_ERROR_TLBIE = 1, 83 }; 84 85 enum MCE_RaErrorType { 86 MCE_RA_ERROR_INDETERMINATE = 0, 87 MCE_RA_ERROR_IFETCH = 1, 88 MCE_RA_ERROR_IFETCH_FOREIGN = 2, 89 MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 3, 90 MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 4, 91 MCE_RA_ERROR_LOAD = 5, 92 MCE_RA_ERROR_STORE = 6, 93 MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 7, 94 MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 8, 95 MCE_RA_ERROR_LOAD_STORE_FOREIGN = 9, 96 }; 97 98 enum MCE_LinkErrorType { 99 MCE_LINK_ERROR_INDETERMINATE = 0, 100 MCE_LINK_ERROR_IFETCH_TIMEOUT = 1, 101 MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2, 102 MCE_LINK_ERROR_LOAD_TIMEOUT = 3, 103 MCE_LINK_ERROR_STORE_TIMEOUT = 4, 104 MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5, 105 }; 106 107 struct machine_check_event { 108 enum MCE_Version version:8; 109 u8 in_use; 110 enum MCE_Severity severity:8; 111 enum MCE_Initiator initiator:8; 112 enum MCE_ErrorType error_type:8; 113 enum MCE_ErrorClass error_class:8; 114 enum MCE_Disposition disposition:8; 115 bool sync_error; 116 u16 cpu; 117 u64 gpr3; 118 u64 srr0; 119 u64 srr1; 120 union { 121 struct { 122 enum MCE_UeErrorType ue_error_type:8; 123 u8 effective_address_provided; 124 u8 physical_address_provided; 125 u8 reserved_1[5]; 126 u64 effective_address; 127 u64 physical_address; 128 u8 reserved_2[8]; 129 } ue_error; 130 131 struct { 132 enum MCE_SlbErrorType slb_error_type:8; 133 u8 effective_address_provided; 134 u8 reserved_1[6]; 135 u64 effective_address; 136 u8 reserved_2[16]; 137 } slb_error; 138 139 struct { 140 enum MCE_EratErrorType erat_error_type:8; 141 u8 effective_address_provided; 142 u8 reserved_1[6]; 143 u64 effective_address; 144 u8 reserved_2[16]; 145 } erat_error; 146 147 struct { 148 enum MCE_TlbErrorType tlb_error_type:8; 149 u8 effective_address_provided; 150 u8 reserved_1[6]; 151 u64 effective_address; 152 u8 reserved_2[16]; 153 } tlb_error; 154 155 struct { 156 enum MCE_UserErrorType user_error_type:8; 157 u8 effective_address_provided; 158 u8 reserved_1[6]; 159 u64 effective_address; 160 u8 reserved_2[16]; 161 } user_error; 162 163 struct { 164 enum MCE_RaErrorType ra_error_type:8; 165 u8 effective_address_provided; 166 u8 reserved_1[6]; 167 u64 effective_address; 168 u8 reserved_2[16]; 169 } ra_error; 170 171 struct { 172 enum MCE_LinkErrorType link_error_type:8; 173 u8 effective_address_provided; 174 u8 reserved_1[6]; 175 u64 effective_address; 176 u8 reserved_2[16]; 177 } link_error; 178 } u; 179 }; 180 181 struct mce_error_info { 182 enum MCE_ErrorType error_type:8; 183 union { 184 enum MCE_UeErrorType ue_error_type:8; 185 enum MCE_SlbErrorType slb_error_type:8; 186 enum MCE_EratErrorType erat_error_type:8; 187 enum MCE_TlbErrorType tlb_error_type:8; 188 enum MCE_UserErrorType user_error_type:8; 189 enum MCE_RaErrorType ra_error_type:8; 190 enum MCE_LinkErrorType link_error_type:8; 191 } u; 192 enum MCE_Severity severity:8; 193 enum MCE_Initiator initiator:8; 194 enum MCE_ErrorClass error_class:8; 195 bool sync_error; 196 }; 197 198 #define MAX_MC_EVT 100 199 200 /* Release flags for get_mce_event() */ 201 #define MCE_EVENT_RELEASE true 202 #define MCE_EVENT_DONTRELEASE false 203 204 extern void save_mce_event(struct pt_regs *regs, long handled, 205 struct mce_error_info *mce_err, uint64_t nip, 206 uint64_t addr, uint64_t phys_addr); 207 extern int get_mce_event(struct machine_check_event *mce, bool release); 208 extern void release_mce_event(void); 209 extern void machine_check_queue_event(void); 210 extern void machine_check_print_event_info(struct machine_check_event *evt, 211 bool user_mode, bool in_guest); 212 unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr); 213 #ifdef CONFIG_PPC_BOOK3S_64 214 void flush_and_reload_slb(void); 215 #endif /* CONFIG_PPC_BOOK3S_64 */ 216 #endif /* __ASM_PPC64_MCE_H__ */ 217