Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
e22a2274 MS |
2 | /* |
3 | * Machine check exception header file. | |
4 | * | |
e22a2274 MS |
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 | ||
36df96f8 MS |
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, | |
cda6618d | 21 | MCE_SEV_SEVERE = 2, |
36df96f8 MS |
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, | |
9ca766f9 NP |
33 | MCE_INITIATOR_PCI = 2, |
34 | MCE_INITIATOR_ISA = 3, | |
35 | MCE_INITIATOR_MEMORY= 4, | |
36 | MCE_INITIATOR_POWERMGM = 5, | |
36df96f8 MS |
37 | }; |
38 | ||
39 | enum MCE_ErrorType { | |
40 | MCE_ERROR_TYPE_UNKNOWN = 0, | |
41 | MCE_ERROR_TYPE_UE = 1, | |
42 | MCE_ERROR_TYPE_SLB = 2, | |
43 | MCE_ERROR_TYPE_ERAT = 3, | |
44 | MCE_ERROR_TYPE_TLB = 4, | |
7b9f71f9 NP |
45 | MCE_ERROR_TYPE_USER = 5, |
46 | MCE_ERROR_TYPE_RA = 6, | |
47 | MCE_ERROR_TYPE_LINK = 7, | |
9ca766f9 NP |
48 | MCE_ERROR_TYPE_DCACHE = 8, |
49 | MCE_ERROR_TYPE_ICACHE = 9, | |
36df96f8 MS |
50 | }; |
51 | ||
50dbabe0 MS |
52 | enum MCE_ErrorClass { |
53 | MCE_ECLASS_UNKNOWN = 0, | |
54 | MCE_ECLASS_HARDWARE, | |
55 | MCE_ECLASS_HARD_INDETERMINATE, | |
56 | MCE_ECLASS_SOFTWARE, | |
57 | MCE_ECLASS_SOFT_INDETERMINATE, | |
58 | }; | |
59 | ||
36df96f8 MS |
60 | enum MCE_UeErrorType { |
61 | MCE_UE_ERROR_INDETERMINATE = 0, | |
62 | MCE_UE_ERROR_IFETCH = 1, | |
63 | MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2, | |
64 | MCE_UE_ERROR_LOAD_STORE = 3, | |
65 | MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4, | |
66 | }; | |
67 | ||
68 | enum MCE_SlbErrorType { | |
69 | MCE_SLB_ERROR_INDETERMINATE = 0, | |
70 | MCE_SLB_ERROR_PARITY = 1, | |
71 | MCE_SLB_ERROR_MULTIHIT = 2, | |
72 | }; | |
73 | ||
74 | enum MCE_EratErrorType { | |
75 | MCE_ERAT_ERROR_INDETERMINATE = 0, | |
76 | MCE_ERAT_ERROR_PARITY = 1, | |
77 | MCE_ERAT_ERROR_MULTIHIT = 2, | |
78 | }; | |
79 | ||
80 | enum MCE_TlbErrorType { | |
81 | MCE_TLB_ERROR_INDETERMINATE = 0, | |
82 | MCE_TLB_ERROR_PARITY = 1, | |
83 | MCE_TLB_ERROR_MULTIHIT = 2, | |
84 | }; | |
85 | ||
7b9f71f9 NP |
86 | enum MCE_UserErrorType { |
87 | MCE_USER_ERROR_INDETERMINATE = 0, | |
88 | MCE_USER_ERROR_TLBIE = 1, | |
201220bb | 89 | MCE_USER_ERROR_SCV = 2, |
7b9f71f9 NP |
90 | }; |
91 | ||
92 | enum MCE_RaErrorType { | |
93 | MCE_RA_ERROR_INDETERMINATE = 0, | |
94 | MCE_RA_ERROR_IFETCH = 1, | |
90df4bfb NP |
95 | MCE_RA_ERROR_IFETCH_FOREIGN = 2, |
96 | MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 3, | |
97 | MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 4, | |
98 | MCE_RA_ERROR_LOAD = 5, | |
99 | MCE_RA_ERROR_STORE = 6, | |
100 | MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 7, | |
101 | MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 8, | |
102 | MCE_RA_ERROR_LOAD_STORE_FOREIGN = 9, | |
7b9f71f9 NP |
103 | }; |
104 | ||
105 | enum MCE_LinkErrorType { | |
106 | MCE_LINK_ERROR_INDETERMINATE = 0, | |
107 | MCE_LINK_ERROR_IFETCH_TIMEOUT = 1, | |
108 | MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2, | |
109 | MCE_LINK_ERROR_LOAD_TIMEOUT = 3, | |
110 | MCE_LINK_ERROR_STORE_TIMEOUT = 4, | |
111 | MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5, | |
112 | }; | |
113 | ||
36df96f8 | 114 | struct machine_check_event { |
cda6618d MS |
115 | enum MCE_Version version:8; |
116 | u8 in_use; | |
117 | enum MCE_Severity severity:8; | |
118 | enum MCE_Initiator initiator:8; | |
119 | enum MCE_ErrorType error_type:8; | |
50dbabe0 | 120 | enum MCE_ErrorClass error_class:8; |
cda6618d MS |
121 | enum MCE_Disposition disposition:8; |
122 | bool sync_error; | |
123 | u16 cpu; | |
124 | u64 gpr3; | |
125 | u64 srr0; | |
126 | u64 srr1; | |
127 | union { | |
36df96f8 MS |
128 | struct { |
129 | enum MCE_UeErrorType ue_error_type:8; | |
cda6618d MS |
130 | u8 effective_address_provided; |
131 | u8 physical_address_provided; | |
895e3dce BS |
132 | u8 ignore_event; |
133 | u8 reserved_1[4]; | |
cda6618d MS |
134 | u64 effective_address; |
135 | u64 physical_address; | |
136 | u8 reserved_2[8]; | |
36df96f8 MS |
137 | } ue_error; |
138 | ||
139 | struct { | |
140 | enum MCE_SlbErrorType slb_error_type:8; | |
cda6618d MS |
141 | u8 effective_address_provided; |
142 | u8 reserved_1[6]; | |
143 | u64 effective_address; | |
144 | u8 reserved_2[16]; | |
36df96f8 MS |
145 | } slb_error; |
146 | ||
147 | struct { | |
148 | enum MCE_EratErrorType erat_error_type:8; | |
cda6618d MS |
149 | u8 effective_address_provided; |
150 | u8 reserved_1[6]; | |
151 | u64 effective_address; | |
152 | u8 reserved_2[16]; | |
36df96f8 MS |
153 | } erat_error; |
154 | ||
155 | struct { | |
156 | enum MCE_TlbErrorType tlb_error_type:8; | |
cda6618d MS |
157 | u8 effective_address_provided; |
158 | u8 reserved_1[6]; | |
159 | u64 effective_address; | |
160 | u8 reserved_2[16]; | |
36df96f8 | 161 | } tlb_error; |
7b9f71f9 NP |
162 | |
163 | struct { | |
164 | enum MCE_UserErrorType user_error_type:8; | |
cda6618d MS |
165 | u8 effective_address_provided; |
166 | u8 reserved_1[6]; | |
167 | u64 effective_address; | |
168 | u8 reserved_2[16]; | |
7b9f71f9 NP |
169 | } user_error; |
170 | ||
171 | struct { | |
172 | enum MCE_RaErrorType ra_error_type:8; | |
cda6618d MS |
173 | u8 effective_address_provided; |
174 | u8 reserved_1[6]; | |
175 | u64 effective_address; | |
176 | u8 reserved_2[16]; | |
7b9f71f9 NP |
177 | } ra_error; |
178 | ||
179 | struct { | |
180 | enum MCE_LinkErrorType link_error_type:8; | |
cda6618d MS |
181 | u8 effective_address_provided; |
182 | u8 reserved_1[6]; | |
183 | u64 effective_address; | |
184 | u8 reserved_2[16]; | |
7b9f71f9 | 185 | } link_error; |
36df96f8 MS |
186 | } u; |
187 | }; | |
188 | ||
189 | struct mce_error_info { | |
190 | enum MCE_ErrorType error_type:8; | |
191 | union { | |
192 | enum MCE_UeErrorType ue_error_type:8; | |
193 | enum MCE_SlbErrorType slb_error_type:8; | |
194 | enum MCE_EratErrorType erat_error_type:8; | |
195 | enum MCE_TlbErrorType tlb_error_type:8; | |
7b9f71f9 NP |
196 | enum MCE_UserErrorType user_error_type:8; |
197 | enum MCE_RaErrorType ra_error_type:8; | |
198 | enum MCE_LinkErrorType link_error_type:8; | |
36df96f8 | 199 | } u; |
c1bbf387 NP |
200 | enum MCE_Severity severity:8; |
201 | enum MCE_Initiator initiator:8; | |
50dbabe0 | 202 | enum MCE_ErrorClass error_class:8; |
cda6618d | 203 | bool sync_error; |
895e3dce | 204 | bool ignore_event; |
36df96f8 MS |
205 | }; |
206 | ||
207 | #define MAX_MC_EVT 100 | |
208 | ||
209 | /* Release flags for get_mce_event() */ | |
210 | #define MCE_EVENT_RELEASE true | |
211 | #define MCE_EVENT_DONTRELEASE false | |
212 | ||
388692e9 MS |
213 | struct pt_regs; |
214 | struct notifier_block; | |
215 | ||
36df96f8 | 216 | extern void save_mce_event(struct pt_regs *regs, long handled, |
55672ecf | 217 | struct mce_error_info *mce_err, uint64_t nip, |
ba41e1e1 | 218 | uint64_t addr, uint64_t phys_addr); |
36df96f8 MS |
219 | extern int get_mce_event(struct machine_check_event *mce, bool release); |
220 | extern void release_mce_event(void); | |
b5ff4211 | 221 | extern void machine_check_queue_event(void); |
63f44d65 | 222 | extern void machine_check_print_event_info(struct machine_check_event *evt, |
c0577201 | 223 | bool user_mode, bool in_guest); |
7f177f98 | 224 | unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr); |
efbc4303 GG |
225 | extern void mce_common_process_ue(struct pt_regs *regs, |
226 | struct mce_error_info *mce_err); | |
c37a63af SS |
227 | int mce_register_notifier(struct notifier_block *nb); |
228 | int mce_unregister_notifier(struct notifier_block *nb); | |
a43c1590 MS |
229 | #ifdef CONFIG_PPC_BOOK3S_64 |
230 | void flush_and_reload_slb(void); | |
388692e9 MS |
231 | long __machine_check_early_realmode_p7(struct pt_regs *regs); |
232 | long __machine_check_early_realmode_p8(struct pt_regs *regs); | |
233 | long __machine_check_early_realmode_p9(struct pt_regs *regs); | |
234 | long __machine_check_early_realmode_p10(struct pt_regs *regs); | |
a43c1590 | 235 | #endif /* CONFIG_PPC_BOOK3S_64 */ |
e22a2274 | 236 | #endif /* __ASM_PPC64_MCE_H__ */ |