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