xref: /linux/arch/powerpc/include/asm/mce.h (revision c05772018491e5294f55d63b239ab0d532e96616)
1e22a2274SMahesh Salgaonkar /*
2e22a2274SMahesh Salgaonkar  * Machine check exception header file.
3e22a2274SMahesh Salgaonkar  *
4e22a2274SMahesh Salgaonkar  * This program is free software; you can redistribute it and/or modify
5e22a2274SMahesh Salgaonkar  * it under the terms of the GNU General Public License as published by
6e22a2274SMahesh Salgaonkar  * the Free Software Foundation; either version 2 of the License, or
7e22a2274SMahesh Salgaonkar  * (at your option) any later version.
8e22a2274SMahesh Salgaonkar  *
9e22a2274SMahesh Salgaonkar  * This program is distributed in the hope that it will be useful,
10e22a2274SMahesh Salgaonkar  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11e22a2274SMahesh Salgaonkar  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12e22a2274SMahesh Salgaonkar  * GNU General Public License for more details.
13e22a2274SMahesh Salgaonkar  *
14e22a2274SMahesh Salgaonkar  * You should have received a copy of the GNU General Public License
15e22a2274SMahesh Salgaonkar  * along with this program; if not, write to the Free Software
16e22a2274SMahesh Salgaonkar  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17e22a2274SMahesh Salgaonkar  *
18e22a2274SMahesh Salgaonkar  * Copyright 2013 IBM Corporation
19e22a2274SMahesh Salgaonkar  * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
20e22a2274SMahesh Salgaonkar  */
21e22a2274SMahesh Salgaonkar 
22e22a2274SMahesh Salgaonkar #ifndef __ASM_PPC64_MCE_H__
23e22a2274SMahesh Salgaonkar #define __ASM_PPC64_MCE_H__
24e22a2274SMahesh Salgaonkar 
25e22a2274SMahesh Salgaonkar #include <linux/bitops.h>
26e22a2274SMahesh Salgaonkar 
2736df96f8SMahesh Salgaonkar enum MCE_Version {
2836df96f8SMahesh Salgaonkar 	MCE_V1 = 1,
2936df96f8SMahesh Salgaonkar };
3036df96f8SMahesh Salgaonkar 
3136df96f8SMahesh Salgaonkar enum MCE_Severity {
3236df96f8SMahesh Salgaonkar 	MCE_SEV_NO_ERROR = 0,
3336df96f8SMahesh Salgaonkar 	MCE_SEV_WARNING = 1,
3436df96f8SMahesh Salgaonkar 	MCE_SEV_ERROR_SYNC = 2,
3536df96f8SMahesh Salgaonkar 	MCE_SEV_FATAL = 3,
3636df96f8SMahesh Salgaonkar };
3736df96f8SMahesh Salgaonkar 
3836df96f8SMahesh Salgaonkar enum MCE_Disposition {
3936df96f8SMahesh Salgaonkar 	MCE_DISPOSITION_RECOVERED = 0,
4036df96f8SMahesh Salgaonkar 	MCE_DISPOSITION_NOT_RECOVERED = 1,
4136df96f8SMahesh Salgaonkar };
4236df96f8SMahesh Salgaonkar 
4336df96f8SMahesh Salgaonkar enum MCE_Initiator {
4436df96f8SMahesh Salgaonkar 	MCE_INITIATOR_UNKNOWN = 0,
4536df96f8SMahesh Salgaonkar 	MCE_INITIATOR_CPU = 1,
4636df96f8SMahesh Salgaonkar };
4736df96f8SMahesh Salgaonkar 
4836df96f8SMahesh Salgaonkar enum MCE_ErrorType {
4936df96f8SMahesh Salgaonkar 	MCE_ERROR_TYPE_UNKNOWN = 0,
5036df96f8SMahesh Salgaonkar 	MCE_ERROR_TYPE_UE = 1,
5136df96f8SMahesh Salgaonkar 	MCE_ERROR_TYPE_SLB = 2,
5236df96f8SMahesh Salgaonkar 	MCE_ERROR_TYPE_ERAT = 3,
5336df96f8SMahesh Salgaonkar 	MCE_ERROR_TYPE_TLB = 4,
547b9f71f9SNicholas Piggin 	MCE_ERROR_TYPE_USER = 5,
557b9f71f9SNicholas Piggin 	MCE_ERROR_TYPE_RA = 6,
567b9f71f9SNicholas Piggin 	MCE_ERROR_TYPE_LINK = 7,
5736df96f8SMahesh Salgaonkar };
5836df96f8SMahesh Salgaonkar 
5936df96f8SMahesh Salgaonkar enum MCE_UeErrorType {
6036df96f8SMahesh Salgaonkar 	MCE_UE_ERROR_INDETERMINATE = 0,
6136df96f8SMahesh Salgaonkar 	MCE_UE_ERROR_IFETCH = 1,
6236df96f8SMahesh Salgaonkar 	MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2,
6336df96f8SMahesh Salgaonkar 	MCE_UE_ERROR_LOAD_STORE = 3,
6436df96f8SMahesh Salgaonkar 	MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4,
6536df96f8SMahesh Salgaonkar };
6636df96f8SMahesh Salgaonkar 
6736df96f8SMahesh Salgaonkar enum MCE_SlbErrorType {
6836df96f8SMahesh Salgaonkar 	MCE_SLB_ERROR_INDETERMINATE = 0,
6936df96f8SMahesh Salgaonkar 	MCE_SLB_ERROR_PARITY = 1,
7036df96f8SMahesh Salgaonkar 	MCE_SLB_ERROR_MULTIHIT = 2,
7136df96f8SMahesh Salgaonkar };
7236df96f8SMahesh Salgaonkar 
7336df96f8SMahesh Salgaonkar enum MCE_EratErrorType {
7436df96f8SMahesh Salgaonkar 	MCE_ERAT_ERROR_INDETERMINATE = 0,
7536df96f8SMahesh Salgaonkar 	MCE_ERAT_ERROR_PARITY = 1,
7636df96f8SMahesh Salgaonkar 	MCE_ERAT_ERROR_MULTIHIT = 2,
7736df96f8SMahesh Salgaonkar };
7836df96f8SMahesh Salgaonkar 
7936df96f8SMahesh Salgaonkar enum MCE_TlbErrorType {
8036df96f8SMahesh Salgaonkar 	MCE_TLB_ERROR_INDETERMINATE = 0,
8136df96f8SMahesh Salgaonkar 	MCE_TLB_ERROR_PARITY = 1,
8236df96f8SMahesh Salgaonkar 	MCE_TLB_ERROR_MULTIHIT = 2,
8336df96f8SMahesh Salgaonkar };
8436df96f8SMahesh Salgaonkar 
857b9f71f9SNicholas Piggin enum MCE_UserErrorType {
867b9f71f9SNicholas Piggin 	MCE_USER_ERROR_INDETERMINATE = 0,
877b9f71f9SNicholas Piggin 	MCE_USER_ERROR_TLBIE = 1,
887b9f71f9SNicholas Piggin };
897b9f71f9SNicholas Piggin 
907b9f71f9SNicholas Piggin enum MCE_RaErrorType {
917b9f71f9SNicholas Piggin 	MCE_RA_ERROR_INDETERMINATE = 0,
927b9f71f9SNicholas Piggin 	MCE_RA_ERROR_IFETCH = 1,
9390df4bfbSNicholas Piggin 	MCE_RA_ERROR_IFETCH_FOREIGN = 2,
9490df4bfbSNicholas Piggin 	MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 3,
9590df4bfbSNicholas Piggin 	MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 4,
9690df4bfbSNicholas Piggin 	MCE_RA_ERROR_LOAD = 5,
9790df4bfbSNicholas Piggin 	MCE_RA_ERROR_STORE = 6,
9890df4bfbSNicholas Piggin 	MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 7,
9990df4bfbSNicholas Piggin 	MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 8,
10090df4bfbSNicholas Piggin 	MCE_RA_ERROR_LOAD_STORE_FOREIGN = 9,
1017b9f71f9SNicholas Piggin };
1027b9f71f9SNicholas Piggin 
1037b9f71f9SNicholas Piggin enum MCE_LinkErrorType {
1047b9f71f9SNicholas Piggin 	MCE_LINK_ERROR_INDETERMINATE = 0,
1057b9f71f9SNicholas Piggin 	MCE_LINK_ERROR_IFETCH_TIMEOUT = 1,
1067b9f71f9SNicholas Piggin 	MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2,
1077b9f71f9SNicholas Piggin 	MCE_LINK_ERROR_LOAD_TIMEOUT = 3,
1087b9f71f9SNicholas Piggin 	MCE_LINK_ERROR_STORE_TIMEOUT = 4,
1097b9f71f9SNicholas Piggin 	MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5,
1107b9f71f9SNicholas Piggin };
1117b9f71f9SNicholas Piggin 
11236df96f8SMahesh Salgaonkar struct machine_check_event {
11336df96f8SMahesh Salgaonkar 	enum MCE_Version	version:8;	/* 0x00 */
11436df96f8SMahesh Salgaonkar 	uint8_t			in_use;		/* 0x01 */
11536df96f8SMahesh Salgaonkar 	enum MCE_Severity	severity:8;	/* 0x02 */
11636df96f8SMahesh Salgaonkar 	enum MCE_Initiator	initiator:8;	/* 0x03 */
11736df96f8SMahesh Salgaonkar 	enum MCE_ErrorType	error_type:8;	/* 0x04 */
11836df96f8SMahesh Salgaonkar 	enum MCE_Disposition	disposition:8;	/* 0x05 */
11936df96f8SMahesh Salgaonkar 	uint8_t			reserved_1[2];	/* 0x06 */
12036df96f8SMahesh Salgaonkar 	uint64_t		gpr3;		/* 0x08 */
12136df96f8SMahesh Salgaonkar 	uint64_t		srr0;		/* 0x10 */
12236df96f8SMahesh Salgaonkar 	uint64_t		srr1;		/* 0x18 */
12336df96f8SMahesh Salgaonkar 	union {					/* 0x20 */
12436df96f8SMahesh Salgaonkar 		struct {
12536df96f8SMahesh Salgaonkar 			enum MCE_UeErrorType ue_error_type:8;
12636df96f8SMahesh Salgaonkar 			uint8_t		effective_address_provided;
12736df96f8SMahesh Salgaonkar 			uint8_t		physical_address_provided;
12836df96f8SMahesh Salgaonkar 			uint8_t		reserved_1[5];
12936df96f8SMahesh Salgaonkar 			uint64_t	effective_address;
13036df96f8SMahesh Salgaonkar 			uint64_t	physical_address;
13136df96f8SMahesh Salgaonkar 			uint8_t		reserved_2[8];
13236df96f8SMahesh Salgaonkar 		} ue_error;
13336df96f8SMahesh Salgaonkar 
13436df96f8SMahesh Salgaonkar 		struct {
13536df96f8SMahesh Salgaonkar 			enum MCE_SlbErrorType slb_error_type:8;
13636df96f8SMahesh Salgaonkar 			uint8_t		effective_address_provided;
13736df96f8SMahesh Salgaonkar 			uint8_t		reserved_1[6];
13836df96f8SMahesh Salgaonkar 			uint64_t	effective_address;
13936df96f8SMahesh Salgaonkar 			uint8_t		reserved_2[16];
14036df96f8SMahesh Salgaonkar 		} slb_error;
14136df96f8SMahesh Salgaonkar 
14236df96f8SMahesh Salgaonkar 		struct {
14336df96f8SMahesh Salgaonkar 			enum MCE_EratErrorType erat_error_type:8;
14436df96f8SMahesh Salgaonkar 			uint8_t		effective_address_provided;
14536df96f8SMahesh Salgaonkar 			uint8_t		reserved_1[6];
14636df96f8SMahesh Salgaonkar 			uint64_t	effective_address;
14736df96f8SMahesh Salgaonkar 			uint8_t		reserved_2[16];
14836df96f8SMahesh Salgaonkar 		} erat_error;
14936df96f8SMahesh Salgaonkar 
15036df96f8SMahesh Salgaonkar 		struct {
15136df96f8SMahesh Salgaonkar 			enum MCE_TlbErrorType tlb_error_type:8;
15236df96f8SMahesh Salgaonkar 			uint8_t		effective_address_provided;
15336df96f8SMahesh Salgaonkar 			uint8_t		reserved_1[6];
15436df96f8SMahesh Salgaonkar 			uint64_t	effective_address;
15536df96f8SMahesh Salgaonkar 			uint8_t		reserved_2[16];
15636df96f8SMahesh Salgaonkar 		} tlb_error;
1577b9f71f9SNicholas Piggin 
1587b9f71f9SNicholas Piggin 		struct {
1597b9f71f9SNicholas Piggin 			enum MCE_UserErrorType user_error_type:8;
1607b9f71f9SNicholas Piggin 			uint8_t		effective_address_provided;
1617b9f71f9SNicholas Piggin 			uint8_t		reserved_1[6];
1627b9f71f9SNicholas Piggin 			uint64_t	effective_address;
1637b9f71f9SNicholas Piggin 			uint8_t		reserved_2[16];
1647b9f71f9SNicholas Piggin 		} user_error;
1657b9f71f9SNicholas Piggin 
1667b9f71f9SNicholas Piggin 		struct {
1677b9f71f9SNicholas Piggin 			enum MCE_RaErrorType ra_error_type:8;
1687b9f71f9SNicholas Piggin 			uint8_t		effective_address_provided;
1697b9f71f9SNicholas Piggin 			uint8_t		reserved_1[6];
1707b9f71f9SNicholas Piggin 			uint64_t	effective_address;
1717b9f71f9SNicholas Piggin 			uint8_t		reserved_2[16];
1727b9f71f9SNicholas Piggin 		} ra_error;
1737b9f71f9SNicholas Piggin 
1747b9f71f9SNicholas Piggin 		struct {
1757b9f71f9SNicholas Piggin 			enum MCE_LinkErrorType link_error_type:8;
1767b9f71f9SNicholas Piggin 			uint8_t		effective_address_provided;
1777b9f71f9SNicholas Piggin 			uint8_t		reserved_1[6];
1787b9f71f9SNicholas Piggin 			uint64_t	effective_address;
1797b9f71f9SNicholas Piggin 			uint8_t		reserved_2[16];
1807b9f71f9SNicholas Piggin 		} link_error;
18136df96f8SMahesh Salgaonkar 	} u;
18236df96f8SMahesh Salgaonkar };
18336df96f8SMahesh Salgaonkar 
18436df96f8SMahesh Salgaonkar struct mce_error_info {
18536df96f8SMahesh Salgaonkar 	enum MCE_ErrorType error_type:8;
18636df96f8SMahesh Salgaonkar 	union {
18736df96f8SMahesh Salgaonkar 		enum MCE_UeErrorType ue_error_type:8;
18836df96f8SMahesh Salgaonkar 		enum MCE_SlbErrorType slb_error_type:8;
18936df96f8SMahesh Salgaonkar 		enum MCE_EratErrorType erat_error_type:8;
19036df96f8SMahesh Salgaonkar 		enum MCE_TlbErrorType tlb_error_type:8;
1917b9f71f9SNicholas Piggin 		enum MCE_UserErrorType user_error_type:8;
1927b9f71f9SNicholas Piggin 		enum MCE_RaErrorType ra_error_type:8;
1937b9f71f9SNicholas Piggin 		enum MCE_LinkErrorType link_error_type:8;
19436df96f8SMahesh Salgaonkar 	} u;
195c1bbf387SNicholas Piggin 	enum MCE_Severity	severity:8;
196c1bbf387SNicholas Piggin 	enum MCE_Initiator	initiator:8;
19736df96f8SMahesh Salgaonkar };
19836df96f8SMahesh Salgaonkar 
19936df96f8SMahesh Salgaonkar #define MAX_MC_EVT	100
20036df96f8SMahesh Salgaonkar 
20136df96f8SMahesh Salgaonkar /* Release flags for get_mce_event() */
20236df96f8SMahesh Salgaonkar #define MCE_EVENT_RELEASE	true
20336df96f8SMahesh Salgaonkar #define MCE_EVENT_DONTRELEASE	false
20436df96f8SMahesh Salgaonkar 
20536df96f8SMahesh Salgaonkar extern void save_mce_event(struct pt_regs *regs, long handled,
20655672ecfSMahesh Salgaonkar 			   struct mce_error_info *mce_err, uint64_t nip,
207ba41e1e1SBalbir Singh 			   uint64_t addr, uint64_t phys_addr);
20836df96f8SMahesh Salgaonkar extern int get_mce_event(struct machine_check_event *mce, bool release);
20936df96f8SMahesh Salgaonkar extern void release_mce_event(void);
210b5ff4211SMahesh Salgaonkar extern void machine_check_queue_event(void);
21163f44d65SMichael Ellerman extern void machine_check_print_event_info(struct machine_check_event *evt,
212*c0577201SPaul Mackerras 					   bool user_mode, bool in_guest);
213a43c1590SMahesh Salgaonkar #ifdef CONFIG_PPC_BOOK3S_64
214a43c1590SMahesh Salgaonkar void flush_and_reload_slb(void);
215a43c1590SMahesh Salgaonkar #endif /* CONFIG_PPC_BOOK3S_64 */
216e22a2274SMahesh Salgaonkar #endif /* __ASM_PPC64_MCE_H__ */
217