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_ERROR_SYNC = 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; /* 0x00 */ 114 uint8_t in_use; /* 0x01 */ 115 enum MCE_Severity severity:8; /* 0x02 */ 116 enum MCE_Initiator initiator:8; /* 0x03 */ 117 enum MCE_ErrorType error_type:8; /* 0x04 */ 118 enum MCE_Disposition disposition:8; /* 0x05 */ 119 uint8_t reserved_1[2]; /* 0x06 */ 120 uint64_t gpr3; /* 0x08 */ 121 uint64_t srr0; /* 0x10 */ 122 uint64_t srr1; /* 0x18 */ 123 union { /* 0x20 */ 124 struct { 125 enum MCE_UeErrorType ue_error_type:8; 126 uint8_t effective_address_provided; 127 uint8_t physical_address_provided; 128 uint8_t reserved_1[5]; 129 uint64_t effective_address; 130 uint64_t physical_address; 131 uint8_t reserved_2[8]; 132 } ue_error; 133 134 struct { 135 enum MCE_SlbErrorType slb_error_type:8; 136 uint8_t effective_address_provided; 137 uint8_t reserved_1[6]; 138 uint64_t effective_address; 139 uint8_t reserved_2[16]; 140 } slb_error; 141 142 struct { 143 enum MCE_EratErrorType erat_error_type:8; 144 uint8_t effective_address_provided; 145 uint8_t reserved_1[6]; 146 uint64_t effective_address; 147 uint8_t reserved_2[16]; 148 } erat_error; 149 150 struct { 151 enum MCE_TlbErrorType tlb_error_type:8; 152 uint8_t effective_address_provided; 153 uint8_t reserved_1[6]; 154 uint64_t effective_address; 155 uint8_t reserved_2[16]; 156 } tlb_error; 157 158 struct { 159 enum MCE_UserErrorType user_error_type:8; 160 uint8_t effective_address_provided; 161 uint8_t reserved_1[6]; 162 uint64_t effective_address; 163 uint8_t reserved_2[16]; 164 } user_error; 165 166 struct { 167 enum MCE_RaErrorType ra_error_type:8; 168 uint8_t effective_address_provided; 169 uint8_t reserved_1[6]; 170 uint64_t effective_address; 171 uint8_t reserved_2[16]; 172 } ra_error; 173 174 struct { 175 enum MCE_LinkErrorType link_error_type:8; 176 uint8_t effective_address_provided; 177 uint8_t reserved_1[6]; 178 uint64_t effective_address; 179 uint8_t reserved_2[16]; 180 } link_error; 181 } u; 182 }; 183 184 struct mce_error_info { 185 enum MCE_ErrorType error_type:8; 186 union { 187 enum MCE_UeErrorType ue_error_type:8; 188 enum MCE_SlbErrorType slb_error_type:8; 189 enum MCE_EratErrorType erat_error_type:8; 190 enum MCE_TlbErrorType tlb_error_type:8; 191 enum MCE_UserErrorType user_error_type:8; 192 enum MCE_RaErrorType ra_error_type:8; 193 enum MCE_LinkErrorType link_error_type:8; 194 } u; 195 enum MCE_Severity severity:8; 196 enum MCE_Initiator initiator:8; 197 }; 198 199 #define MAX_MC_EVT 100 200 201 /* Release flags for get_mce_event() */ 202 #define MCE_EVENT_RELEASE true 203 #define MCE_EVENT_DONTRELEASE false 204 205 extern void save_mce_event(struct pt_regs *regs, long handled, 206 struct mce_error_info *mce_err, uint64_t nip, 207 uint64_t addr, uint64_t phys_addr); 208 extern int get_mce_event(struct machine_check_event *mce, bool release); 209 extern void release_mce_event(void); 210 extern void machine_check_queue_event(void); 211 extern void machine_check_print_event_info(struct machine_check_event *evt, 212 bool user_mode, bool in_guest); 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