mce.h 5.8 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Machine check exception header file.
 *
 * Copyright 2013 IBM Corporation
 * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
 */

#ifndef __ASM_PPC64_MCE_H__
#define __ASM_PPC64_MCE_H__

#include <linux/bitops.h>

14 15 16 17 18 19 20
enum MCE_Version {
	MCE_V1 = 1,
};

enum MCE_Severity {
	MCE_SEV_NO_ERROR = 0,
	MCE_SEV_WARNING = 1,
21
	MCE_SEV_SEVERE = 2,
22 23 24 25 26 27 28 29 30 31 32
	MCE_SEV_FATAL = 3,
};

enum MCE_Disposition {
	MCE_DISPOSITION_RECOVERED = 0,
	MCE_DISPOSITION_NOT_RECOVERED = 1,
};

enum MCE_Initiator {
	MCE_INITIATOR_UNKNOWN = 0,
	MCE_INITIATOR_CPU = 1,
33 34 35 36
	MCE_INITIATOR_PCI = 2,
	MCE_INITIATOR_ISA = 3,
	MCE_INITIATOR_MEMORY= 4,
	MCE_INITIATOR_POWERMGM = 5,
37 38 39 40 41 42 43 44
};

enum MCE_ErrorType {
	MCE_ERROR_TYPE_UNKNOWN = 0,
	MCE_ERROR_TYPE_UE = 1,
	MCE_ERROR_TYPE_SLB = 2,
	MCE_ERROR_TYPE_ERAT = 3,
	MCE_ERROR_TYPE_TLB = 4,
45 46 47
	MCE_ERROR_TYPE_USER = 5,
	MCE_ERROR_TYPE_RA = 6,
	MCE_ERROR_TYPE_LINK = 7,
48 49
	MCE_ERROR_TYPE_DCACHE = 8,
	MCE_ERROR_TYPE_ICACHE = 9,
50 51
};

52 53 54 55 56 57 58 59
enum MCE_ErrorClass {
	MCE_ECLASS_UNKNOWN = 0,
	MCE_ECLASS_HARDWARE,
	MCE_ECLASS_HARD_INDETERMINATE,
	MCE_ECLASS_SOFTWARE,
	MCE_ECLASS_SOFT_INDETERMINATE,
};

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
enum MCE_UeErrorType {
	MCE_UE_ERROR_INDETERMINATE = 0,
	MCE_UE_ERROR_IFETCH = 1,
	MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2,
	MCE_UE_ERROR_LOAD_STORE = 3,
	MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4,
};

enum MCE_SlbErrorType {
	MCE_SLB_ERROR_INDETERMINATE = 0,
	MCE_SLB_ERROR_PARITY = 1,
	MCE_SLB_ERROR_MULTIHIT = 2,
};

enum MCE_EratErrorType {
	MCE_ERAT_ERROR_INDETERMINATE = 0,
	MCE_ERAT_ERROR_PARITY = 1,
	MCE_ERAT_ERROR_MULTIHIT = 2,
};

enum MCE_TlbErrorType {
	MCE_TLB_ERROR_INDETERMINATE = 0,
	MCE_TLB_ERROR_PARITY = 1,
	MCE_TLB_ERROR_MULTIHIT = 2,
};

86 87 88
enum MCE_UserErrorType {
	MCE_USER_ERROR_INDETERMINATE = 0,
	MCE_USER_ERROR_TLBIE = 1,
89
	MCE_USER_ERROR_SCV = 2,
90 91 92 93 94
};

enum MCE_RaErrorType {
	MCE_RA_ERROR_INDETERMINATE = 0,
	MCE_RA_ERROR_IFETCH = 1,
95 96 97 98 99 100 101 102
	MCE_RA_ERROR_IFETCH_FOREIGN = 2,
	MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 3,
	MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 4,
	MCE_RA_ERROR_LOAD = 5,
	MCE_RA_ERROR_STORE = 6,
	MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 7,
	MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 8,
	MCE_RA_ERROR_LOAD_STORE_FOREIGN = 9,
103 104 105 106 107 108 109 110 111 112 113
};

enum MCE_LinkErrorType {
	MCE_LINK_ERROR_INDETERMINATE = 0,
	MCE_LINK_ERROR_IFETCH_TIMEOUT = 1,
	MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2,
	MCE_LINK_ERROR_LOAD_TIMEOUT = 3,
	MCE_LINK_ERROR_STORE_TIMEOUT = 4,
	MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5,
};

114
struct machine_check_event {
115 116 117 118 119
	enum MCE_Version	version:8;
	u8			in_use;
	enum MCE_Severity	severity:8;
	enum MCE_Initiator	initiator:8;
	enum MCE_ErrorType	error_type:8;
120
	enum MCE_ErrorClass	error_class:8;
121 122 123 124 125 126 127
	enum MCE_Disposition	disposition:8;
	bool			sync_error;
	u16			cpu;
	u64			gpr3;
	u64			srr0;
	u64			srr1;
	union {
128 129
		struct {
			enum MCE_UeErrorType ue_error_type:8;
130 131
			u8		effective_address_provided;
			u8		physical_address_provided;
132 133
			u8		ignore_event;
			u8		reserved_1[4];
134 135 136
			u64		effective_address;
			u64		physical_address;
			u8		reserved_2[8];
137 138 139 140
		} ue_error;

		struct {
			enum MCE_SlbErrorType slb_error_type:8;
141 142 143 144
			u8		effective_address_provided;
			u8		reserved_1[6];
			u64		effective_address;
			u8		reserved_2[16];
145 146 147 148
		} slb_error;

		struct {
			enum MCE_EratErrorType erat_error_type:8;
149 150 151 152
			u8		effective_address_provided;
			u8		reserved_1[6];
			u64		effective_address;
			u8		reserved_2[16];
153 154 155 156
		} erat_error;

		struct {
			enum MCE_TlbErrorType tlb_error_type:8;
157 158 159 160
			u8		effective_address_provided;
			u8		reserved_1[6];
			u64		effective_address;
			u8		reserved_2[16];
161
		} tlb_error;
162 163 164

		struct {
			enum MCE_UserErrorType user_error_type:8;
165 166 167 168
			u8		effective_address_provided;
			u8		reserved_1[6];
			u64		effective_address;
			u8		reserved_2[16];
169 170 171 172
		} user_error;

		struct {
			enum MCE_RaErrorType ra_error_type:8;
173 174 175 176
			u8		effective_address_provided;
			u8		reserved_1[6];
			u64		effective_address;
			u8		reserved_2[16];
177 178 179 180
		} ra_error;

		struct {
			enum MCE_LinkErrorType link_error_type:8;
181 182 183 184
			u8		effective_address_provided;
			u8		reserved_1[6];
			u64		effective_address;
			u8		reserved_2[16];
185
		} link_error;
186 187 188 189 190 191 192 193 194 195
	} u;
};

struct mce_error_info {
	enum MCE_ErrorType error_type:8;
	union {
		enum MCE_UeErrorType ue_error_type:8;
		enum MCE_SlbErrorType slb_error_type:8;
		enum MCE_EratErrorType erat_error_type:8;
		enum MCE_TlbErrorType tlb_error_type:8;
196 197 198
		enum MCE_UserErrorType user_error_type:8;
		enum MCE_RaErrorType ra_error_type:8;
		enum MCE_LinkErrorType link_error_type:8;
199
	} u;
200 201
	enum MCE_Severity	severity:8;
	enum MCE_Initiator	initiator:8;
202
	enum MCE_ErrorClass	error_class:8;
203
	bool			sync_error;
204
	bool			ignore_event;
205 206 207 208 209 210 211 212
};

#define MAX_MC_EVT	100

/* Release flags for get_mce_event() */
#define MCE_EVENT_RELEASE	true
#define MCE_EVENT_DONTRELEASE	false

213 214 215
struct pt_regs;
struct notifier_block;

216
extern void save_mce_event(struct pt_regs *regs, long handled,
217
			   struct mce_error_info *mce_err, uint64_t nip,
218
			   uint64_t addr, uint64_t phys_addr);
219 220
extern int get_mce_event(struct machine_check_event *mce, bool release);
extern void release_mce_event(void);
221
extern void machine_check_queue_event(void);
222
extern void machine_check_print_event_info(struct machine_check_event *evt,
223
					   bool user_mode, bool in_guest);
224
unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr);
225 226
extern void mce_common_process_ue(struct pt_regs *regs,
				  struct mce_error_info *mce_err);
227 228
int mce_register_notifier(struct notifier_block *nb);
int mce_unregister_notifier(struct notifier_block *nb);
229 230
#ifdef CONFIG_PPC_BOOK3S_64
void flush_and_reload_slb(void);
231 232 233 234
long __machine_check_early_realmode_p7(struct pt_regs *regs);
long __machine_check_early_realmode_p8(struct pt_regs *regs);
long __machine_check_early_realmode_p9(struct pt_regs *regs);
long __machine_check_early_realmode_p10(struct pt_regs *regs);
235
#endif /* CONFIG_PPC_BOOK3S_64 */
236
#endif /* __ASM_PPC64_MCE_H__ */