1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Machine check exception header file.
5 * Copyright 2013 IBM Corporation
9 #ifndef __ASM_PPC64_MCE_H__
10 #define __ASM_PPC64_MCE_H__
12 #include <linux/bitops.h>
25 enum MCE_Disposition {
26 MCE_DISPOSITION_RECOVERED = 0,
27 MCE_DISPOSITION_NOT_RECOVERED = 1,
31 MCE_INITIATOR_UNKNOWN = 0,
32 MCE_INITIATOR_CPU = 1,
33 MCE_INITIATOR_PCI = 2,
34 MCE_INITIATOR_ISA = 3,
35 MCE_INITIATOR_MEMORY= 4,
36 MCE_INITIATOR_POWERMGM = 5,
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,
45 MCE_ERROR_TYPE_USER = 5,
46 MCE_ERROR_TYPE_RA = 6,
47 MCE_ERROR_TYPE_LINK = 7,
48 MCE_ERROR_TYPE_DCACHE = 8,
49 MCE_ERROR_TYPE_ICACHE = 9,
53 MCE_ECLASS_UNKNOWN = 0,
55 MCE_ECLASS_HARD_INDETERMINATE,
57 MCE_ECLASS_SOFT_INDETERMINATE,
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,
68 enum MCE_SlbErrorType {
69 MCE_SLB_ERROR_INDETERMINATE = 0,
70 MCE_SLB_ERROR_PARITY = 1,
71 MCE_SLB_ERROR_MULTIHIT = 2,
74 enum MCE_EratErrorType {
75 MCE_ERAT_ERROR_INDETERMINATE = 0,
76 MCE_ERAT_ERROR_PARITY = 1,
77 MCE_ERAT_ERROR_MULTIHIT = 2,
80 enum MCE_TlbErrorType {
81 MCE_TLB_ERROR_INDETERMINATE = 0,
82 MCE_TLB_ERROR_PARITY = 1,
83 MCE_TLB_ERROR_MULTIHIT = 2,
86 enum MCE_UserErrorType {
87 MCE_USER_ERROR_INDETERMINATE = 0,
88 MCE_USER_ERROR_TLBIE = 1,
89 MCE_USER_ERROR_SCV = 2,
92 enum MCE_RaErrorType {
93 MCE_RA_ERROR_INDETERMINATE = 0,
94 MCE_RA_ERROR_IFETCH = 1,
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,
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,
114 struct machine_check_event {
115 enum MCE_Version version:8;
117 enum MCE_Severity severity:8;
118 enum MCE_Initiator initiator:8;
119 enum MCE_ErrorType error_type:8;
120 enum MCE_ErrorClass error_class:8;
121 enum MCE_Disposition disposition:8;
129 enum MCE_UeErrorType ue_error_type:8;
130 u8 effective_address_provided;
131 u8 physical_address_provided;
134 u64 effective_address;
135 u64 physical_address;
140 enum MCE_SlbErrorType slb_error_type:8;
141 u8 effective_address_provided;
143 u64 effective_address;
148 enum MCE_EratErrorType erat_error_type:8;
149 u8 effective_address_provided;
151 u64 effective_address;
156 enum MCE_TlbErrorType tlb_error_type:8;
157 u8 effective_address_provided;
159 u64 effective_address;
164 enum MCE_UserErrorType user_error_type:8;
165 u8 effective_address_provided;
167 u64 effective_address;
172 enum MCE_RaErrorType ra_error_type:8;
173 u8 effective_address_provided;
175 u64 effective_address;
180 enum MCE_LinkErrorType link_error_type:8;
181 u8 effective_address_provided;
183 u64 effective_address;
189 struct mce_error_info {
190 enum MCE_ErrorType error_type:8;
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;
196 enum MCE_UserErrorType user_error_type:8;
197 enum MCE_RaErrorType ra_error_type:8;
198 enum MCE_LinkErrorType link_error_type:8;
200 enum MCE_Severity severity:8;
201 enum MCE_Initiator initiator:8;
202 enum MCE_ErrorClass error_class:8;
207 #define MAX_MC_EVT 10
211 struct machine_check_event mce_event[MAX_MC_EVT];
212 /* Queue for delayed MCE events. */
214 struct machine_check_event mce_event_queue[MAX_MC_EVT];
215 /* Queue for delayed MCE UE events. */
217 struct machine_check_event mce_ue_event_queue[MAX_MC_EVT];
220 /* Release flags for get_mce_event() */
221 #define MCE_EVENT_RELEASE true
222 #define MCE_EVENT_DONTRELEASE false
225 struct notifier_block;
227 extern void save_mce_event(struct pt_regs *regs, long handled,
228 struct mce_error_info *mce_err, uint64_t nip,
229 uint64_t addr, uint64_t phys_addr);
230 extern int get_mce_event(struct machine_check_event *mce, bool release);
231 extern void release_mce_event(void);
232 extern void machine_check_queue_event(void);
233 extern void machine_check_print_event_info(struct machine_check_event *evt,
234 bool user_mode, bool in_guest);
235 unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr);
236 extern void mce_common_process_ue(struct pt_regs *regs,
237 struct mce_error_info *mce_err);
238 void mce_irq_work_queue(void);
239 int mce_register_notifier(struct notifier_block *nb);
240 int mce_unregister_notifier(struct notifier_block *nb);
242 #ifdef CONFIG_PPC_BOOK3S_64
243 void mce_run_irq_context_handlers(void);
245 static inline void mce_run_irq_context_handlers(void) { };
246 #endif /* CONFIG_PPC_BOOK3S_64 */
248 #ifdef CONFIG_PPC_BOOK3S_64
249 void set_mce_pending_irq_work(void);
250 void clear_mce_pending_irq_work(void);
251 #endif /* CONFIG_PPC_BOOK3S_64 */
253 #ifdef CONFIG_PPC_BOOK3S_64
254 void flush_and_reload_slb(void);
255 void flush_erat(void);
256 long __machine_check_early_realmode_p7(struct pt_regs *regs);
257 long __machine_check_early_realmode_p8(struct pt_regs *regs);
258 long __machine_check_early_realmode_p9(struct pt_regs *regs);
259 long __machine_check_early_realmode_p10(struct pt_regs *regs);
260 #endif /* CONFIG_PPC_BOOK3S_64 */
262 #ifdef CONFIG_PPC_BOOK3S_64
265 static inline void mce_init(void) { };
266 #endif /* CONFIG_PPC_BOOK3S_64 */
268 #endif /* __ASM_PPC64_MCE_H__ */