blob: 23247a132ce86aafbb660868e2d98f5499d6d372 [file] [log] [blame]
Mahesh Salgaonkare22a2272013-10-30 20:05:11 +05301/*
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
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +053027enum MCE_Version {
28 MCE_V1 = 1,
29};
30
31enum MCE_Severity {
32 MCE_SEV_NO_ERROR = 0,
33 MCE_SEV_WARNING = 1,
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +053034 MCE_SEV_SEVERE = 2,
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +053035 MCE_SEV_FATAL = 3,
36};
37
38enum MCE_Disposition {
39 MCE_DISPOSITION_RECOVERED = 0,
40 MCE_DISPOSITION_NOT_RECOVERED = 1,
41};
42
43enum MCE_Initiator {
44 MCE_INITIATOR_UNKNOWN = 0,
45 MCE_INITIATOR_CPU = 1,
46};
47
48enum 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,
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +100054 MCE_ERROR_TYPE_USER = 5,
55 MCE_ERROR_TYPE_RA = 6,
56 MCE_ERROR_TYPE_LINK = 7,
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +053057};
58
Mahesh Salgaonkar50dbabe2019-04-29 23:46:02 +053059enum 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
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +053067enum 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
75enum MCE_SlbErrorType {
76 MCE_SLB_ERROR_INDETERMINATE = 0,
77 MCE_SLB_ERROR_PARITY = 1,
78 MCE_SLB_ERROR_MULTIHIT = 2,
79};
80
81enum MCE_EratErrorType {
82 MCE_ERAT_ERROR_INDETERMINATE = 0,
83 MCE_ERAT_ERROR_PARITY = 1,
84 MCE_ERAT_ERROR_MULTIHIT = 2,
85};
86
87enum MCE_TlbErrorType {
88 MCE_TLB_ERROR_INDETERMINATE = 0,
89 MCE_TLB_ERROR_PARITY = 1,
90 MCE_TLB_ERROR_MULTIHIT = 2,
91};
92
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +100093enum MCE_UserErrorType {
94 MCE_USER_ERROR_INDETERMINATE = 0,
95 MCE_USER_ERROR_TLBIE = 1,
96};
97
98enum MCE_RaErrorType {
99 MCE_RA_ERROR_INDETERMINATE = 0,
100 MCE_RA_ERROR_IFETCH = 1,
Nicholas Piggin90df4bf2017-05-29 16:26:44 +1000101 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,
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +1000109};
110
111enum 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
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530120struct machine_check_event {
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530121 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;
Mahesh Salgaonkar50dbabe2019-04-29 23:46:02 +0530126 enum MCE_ErrorClass error_class:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530127 enum MCE_Disposition disposition:8;
128 bool sync_error;
129 u16 cpu;
130 u64 gpr3;
131 u64 srr0;
132 u64 srr1;
133 union {
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530134 struct {
135 enum MCE_UeErrorType ue_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530136 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];
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530142 } ue_error;
143
144 struct {
145 enum MCE_SlbErrorType slb_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530146 u8 effective_address_provided;
147 u8 reserved_1[6];
148 u64 effective_address;
149 u8 reserved_2[16];
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530150 } slb_error;
151
152 struct {
153 enum MCE_EratErrorType erat_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530154 u8 effective_address_provided;
155 u8 reserved_1[6];
156 u64 effective_address;
157 u8 reserved_2[16];
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530158 } erat_error;
159
160 struct {
161 enum MCE_TlbErrorType tlb_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530162 u8 effective_address_provided;
163 u8 reserved_1[6];
164 u64 effective_address;
165 u8 reserved_2[16];
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530166 } tlb_error;
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +1000167
168 struct {
169 enum MCE_UserErrorType user_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530170 u8 effective_address_provided;
171 u8 reserved_1[6];
172 u64 effective_address;
173 u8 reserved_2[16];
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +1000174 } user_error;
175
176 struct {
177 enum MCE_RaErrorType ra_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530178 u8 effective_address_provided;
179 u8 reserved_1[6];
180 u64 effective_address;
181 u8 reserved_2[16];
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +1000182 } ra_error;
183
184 struct {
185 enum MCE_LinkErrorType link_error_type:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530186 u8 effective_address_provided;
187 u8 reserved_1[6];
188 u64 effective_address;
189 u8 reserved_2[16];
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +1000190 } link_error;
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530191 } u;
192};
193
194struct 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;
Nicholas Piggin7b9f71f92017-02-28 12:00:48 +1000201 enum MCE_UserErrorType user_error_type:8;
202 enum MCE_RaErrorType ra_error_type:8;
203 enum MCE_LinkErrorType link_error_type:8;
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530204 } u;
Nicholas Pigginc1bbf382017-02-28 12:00:47 +1000205 enum MCE_Severity severity:8;
206 enum MCE_Initiator initiator:8;
Mahesh Salgaonkar50dbabe2019-04-29 23:46:02 +0530207 enum MCE_ErrorClass error_class:8;
Mahesh Salgaonkarcda66182019-04-29 23:45:55 +0530208 bool sync_error;
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530209};
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
217extern void save_mce_event(struct pt_regs *regs, long handled,
Mahesh Salgaonkar55672ec2013-12-16 10:46:24 +0530218 struct mce_error_info *mce_err, uint64_t nip,
Balbir Singhba41e1e2017-09-29 14:26:53 +1000219 uint64_t addr, uint64_t phys_addr);
Mahesh Salgaonkar36df96f2013-10-30 20:05:40 +0530220extern int get_mce_event(struct machine_check_event *mce, bool release);
221extern void release_mce_event(void);
Mahesh Salgaonkarb5ff4212013-10-30 20:05:49 +0530222extern void machine_check_queue_event(void);
Michael Ellerman63f44d62017-04-03 15:29:34 +1000223extern void machine_check_print_event_info(struct machine_check_event *evt,
Paul Mackerrasc0577202019-02-21 13:40:20 +1100224 bool user_mode, bool in_guest);
Ganesh Goudar7f177f92019-04-15 15:35:44 +0530225unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr);
Mahesh Salgaonkara43c1592018-09-11 19:57:00 +0530226#ifdef CONFIG_PPC_BOOK3S_64
227void flush_and_reload_slb(void);
228#endif /* CONFIG_PPC_BOOK3S_64 */
Mahesh Salgaonkare22a2272013-10-30 20:05:11 +0530229#endif /* __ASM_PPC64_MCE_H__ */