xref: /openbmc/linux/arch/powerpc/include/asm/mce.h (revision 74a22e8f)
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_ErrorClass {
60 	MCE_ECLASS_UNKNOWN = 0,
61 	MCE_ECLASS_HARDWARE,
62 	MCE_ECLASS_HARD_INDETERMINATE,
63 	MCE_ECLASS_SOFTWARE,
64 	MCE_ECLASS_SOFT_INDETERMINATE,
65 };
66 
67 enum MCE_UeErrorType {
68 	MCE_UE_ERROR_INDETERMINATE = 0,
69 	MCE_UE_ERROR_IFETCH = 1,
70 	MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2,
71 	MCE_UE_ERROR_LOAD_STORE = 3,
72 	MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4,
73 };
74 
75 enum MCE_SlbErrorType {
76 	MCE_SLB_ERROR_INDETERMINATE = 0,
77 	MCE_SLB_ERROR_PARITY = 1,
78 	MCE_SLB_ERROR_MULTIHIT = 2,
79 };
80 
81 enum MCE_EratErrorType {
82 	MCE_ERAT_ERROR_INDETERMINATE = 0,
83 	MCE_ERAT_ERROR_PARITY = 1,
84 	MCE_ERAT_ERROR_MULTIHIT = 2,
85 };
86 
87 enum MCE_TlbErrorType {
88 	MCE_TLB_ERROR_INDETERMINATE = 0,
89 	MCE_TLB_ERROR_PARITY = 1,
90 	MCE_TLB_ERROR_MULTIHIT = 2,
91 };
92 
93 enum MCE_UserErrorType {
94 	MCE_USER_ERROR_INDETERMINATE = 0,
95 	MCE_USER_ERROR_TLBIE = 1,
96 };
97 
98 enum MCE_RaErrorType {
99 	MCE_RA_ERROR_INDETERMINATE = 0,
100 	MCE_RA_ERROR_IFETCH = 1,
101 	MCE_RA_ERROR_IFETCH_FOREIGN = 2,
102 	MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 3,
103 	MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 4,
104 	MCE_RA_ERROR_LOAD = 5,
105 	MCE_RA_ERROR_STORE = 6,
106 	MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 7,
107 	MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 8,
108 	MCE_RA_ERROR_LOAD_STORE_FOREIGN = 9,
109 };
110 
111 enum MCE_LinkErrorType {
112 	MCE_LINK_ERROR_INDETERMINATE = 0,
113 	MCE_LINK_ERROR_IFETCH_TIMEOUT = 1,
114 	MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2,
115 	MCE_LINK_ERROR_LOAD_TIMEOUT = 3,
116 	MCE_LINK_ERROR_STORE_TIMEOUT = 4,
117 	MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5,
118 };
119 
120 struct machine_check_event {
121 	enum MCE_Version	version:8;
122 	u8			in_use;
123 	enum MCE_Severity	severity:8;
124 	enum MCE_Initiator	initiator:8;
125 	enum MCE_ErrorType	error_type:8;
126 	enum MCE_ErrorClass	error_class:8;
127 	enum MCE_Disposition	disposition:8;
128 	bool			sync_error;
129 	u16			cpu;
130 	u64			gpr3;
131 	u64			srr0;
132 	u64			srr1;
133 	union {
134 		struct {
135 			enum MCE_UeErrorType ue_error_type:8;
136 			u8		effective_address_provided;
137 			u8		physical_address_provided;
138 			u8		reserved_1[5];
139 			u64		effective_address;
140 			u64		physical_address;
141 			u8		reserved_2[8];
142 		} ue_error;
143 
144 		struct {
145 			enum MCE_SlbErrorType slb_error_type:8;
146 			u8		effective_address_provided;
147 			u8		reserved_1[6];
148 			u64		effective_address;
149 			u8		reserved_2[16];
150 		} slb_error;
151 
152 		struct {
153 			enum MCE_EratErrorType erat_error_type:8;
154 			u8		effective_address_provided;
155 			u8		reserved_1[6];
156 			u64		effective_address;
157 			u8		reserved_2[16];
158 		} erat_error;
159 
160 		struct {
161 			enum MCE_TlbErrorType tlb_error_type:8;
162 			u8		effective_address_provided;
163 			u8		reserved_1[6];
164 			u64		effective_address;
165 			u8		reserved_2[16];
166 		} tlb_error;
167 
168 		struct {
169 			enum MCE_UserErrorType user_error_type:8;
170 			u8		effective_address_provided;
171 			u8		reserved_1[6];
172 			u64		effective_address;
173 			u8		reserved_2[16];
174 		} user_error;
175 
176 		struct {
177 			enum MCE_RaErrorType ra_error_type:8;
178 			u8		effective_address_provided;
179 			u8		reserved_1[6];
180 			u64		effective_address;
181 			u8		reserved_2[16];
182 		} ra_error;
183 
184 		struct {
185 			enum MCE_LinkErrorType link_error_type:8;
186 			u8		effective_address_provided;
187 			u8		reserved_1[6];
188 			u64		effective_address;
189 			u8		reserved_2[16];
190 		} link_error;
191 	} u;
192 };
193 
194 struct mce_error_info {
195 	enum MCE_ErrorType error_type:8;
196 	union {
197 		enum MCE_UeErrorType ue_error_type:8;
198 		enum MCE_SlbErrorType slb_error_type:8;
199 		enum MCE_EratErrorType erat_error_type:8;
200 		enum MCE_TlbErrorType tlb_error_type:8;
201 		enum MCE_UserErrorType user_error_type:8;
202 		enum MCE_RaErrorType ra_error_type:8;
203 		enum MCE_LinkErrorType link_error_type:8;
204 	} u;
205 	enum MCE_Severity	severity:8;
206 	enum MCE_Initiator	initiator:8;
207 	enum MCE_ErrorClass	error_class:8;
208 	bool			sync_error;
209 };
210 
211 #define MAX_MC_EVT	100
212 
213 /* Release flags for get_mce_event() */
214 #define MCE_EVENT_RELEASE	true
215 #define MCE_EVENT_DONTRELEASE	false
216 
217 extern void save_mce_event(struct pt_regs *regs, long handled,
218 			   struct mce_error_info *mce_err, uint64_t nip,
219 			   uint64_t addr, uint64_t phys_addr);
220 extern int get_mce_event(struct machine_check_event *mce, bool release);
221 extern void release_mce_event(void);
222 extern void machine_check_queue_event(void);
223 extern void machine_check_print_event_info(struct machine_check_event *evt,
224 					   bool user_mode, bool in_guest);
225 unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr);
226 #ifdef CONFIG_PPC_BOOK3S_64
227 void flush_and_reload_slb(void);
228 #endif /* CONFIG_PPC_BOOK3S_64 */
229 #endif /* __ASM_PPC64_MCE_H__ */
230