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 27e22a2274SMahesh Salgaonkar /* 28e22a2274SMahesh Salgaonkar * Machine Check bits on power7 and power8 29e22a2274SMahesh Salgaonkar */ 30e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_LOADSTORE(srr1) ((srr1) & PPC_BIT(42)) /* P8 too */ 31e22a2274SMahesh Salgaonkar 32e22a2274SMahesh Salgaonkar /* SRR1 bits for machine check (On Power7 and Power8) */ 33e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH(srr1) ((srr1) & PPC_BITMASK(43, 45)) /* P8 too */ 34e22a2274SMahesh Salgaonkar 35e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_UE (0x1 << PPC_BITLSHIFT(45)) /* P8 too */ 36e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_SLB_PARITY (0x2 << PPC_BITLSHIFT(45)) /* P8 too */ 37e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_SLB_MULTIHIT (0x3 << PPC_BITLSHIFT(45)) /* P8 too */ 38e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_SLB_BOTH (0x4 << PPC_BITLSHIFT(45)) 39e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_TLB_MULTIHIT (0x5 << PPC_BITLSHIFT(45)) /* P8 too */ 40e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_UE_TLB_RELOAD (0x6 << PPC_BITLSHIFT(45)) /* P8 too */ 41e22a2274SMahesh Salgaonkar #define P7_SRR1_MC_IFETCH_UE_IFU_INTERNAL (0x7 << PPC_BITLSHIFT(45)) 42e22a2274SMahesh Salgaonkar 43e22a2274SMahesh Salgaonkar /* SRR1 bits for machine check (On Power8) */ 44e22a2274SMahesh Salgaonkar #define P8_SRR1_MC_IFETCH_ERAT_MULTIHIT (0x4 << PPC_BITLSHIFT(45)) 45e22a2274SMahesh Salgaonkar 46e22a2274SMahesh Salgaonkar /* DSISR bits for machine check (On Power7 and Power8) */ 47e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_UE (PPC_BIT(48)) /* P8 too */ 48e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_UE_TABLEWALK (PPC_BIT(49)) /* P8 too */ 49e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_ERAT_MULTIHIT (PPC_BIT(52)) /* P8 too */ 50e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_TLB_MULTIHIT_MFTLB (PPC_BIT(53)) /* P8 too */ 51e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_SLB_PARITY_MFSLB (PPC_BIT(55)) /* P8 too */ 52e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_SLB_MULTIHIT (PPC_BIT(56)) /* P8 too */ 53e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_SLB_MULTIHIT_PARITY (PPC_BIT(57)) /* P8 too */ 54e22a2274SMahesh Salgaonkar 55e22a2274SMahesh Salgaonkar /* 56e22a2274SMahesh Salgaonkar * DSISR bits for machine check (Power8) in addition to above. 57e22a2274SMahesh Salgaonkar * Secondary DERAT Multihit 58e22a2274SMahesh Salgaonkar */ 59e22a2274SMahesh Salgaonkar #define P8_DSISR_MC_ERAT_MULTIHIT_SEC (PPC_BIT(54)) 60e22a2274SMahesh Salgaonkar 61e22a2274SMahesh Salgaonkar /* SLB error bits */ 62e22a2274SMahesh Salgaonkar #define P7_DSISR_MC_SLB_ERRORS (P7_DSISR_MC_ERAT_MULTIHIT | \ 63e22a2274SMahesh Salgaonkar P7_DSISR_MC_SLB_PARITY_MFSLB | \ 64e22a2274SMahesh Salgaonkar P7_DSISR_MC_SLB_MULTIHIT | \ 65e22a2274SMahesh Salgaonkar P7_DSISR_MC_SLB_MULTIHIT_PARITY) 66e22a2274SMahesh Salgaonkar 67ae744f34SMahesh Salgaonkar #define P8_DSISR_MC_SLB_ERRORS (P7_DSISR_MC_SLB_ERRORS | \ 68ae744f34SMahesh Salgaonkar P8_DSISR_MC_ERAT_MULTIHIT_SEC) 6936df96f8SMahesh Salgaonkar enum MCE_Version { 7036df96f8SMahesh Salgaonkar MCE_V1 = 1, 7136df96f8SMahesh Salgaonkar }; 7236df96f8SMahesh Salgaonkar 7336df96f8SMahesh Salgaonkar enum MCE_Severity { 7436df96f8SMahesh Salgaonkar MCE_SEV_NO_ERROR = 0, 7536df96f8SMahesh Salgaonkar MCE_SEV_WARNING = 1, 7636df96f8SMahesh Salgaonkar MCE_SEV_ERROR_SYNC = 2, 7736df96f8SMahesh Salgaonkar MCE_SEV_FATAL = 3, 7836df96f8SMahesh Salgaonkar }; 7936df96f8SMahesh Salgaonkar 8036df96f8SMahesh Salgaonkar enum MCE_Disposition { 8136df96f8SMahesh Salgaonkar MCE_DISPOSITION_RECOVERED = 0, 8236df96f8SMahesh Salgaonkar MCE_DISPOSITION_NOT_RECOVERED = 1, 8336df96f8SMahesh Salgaonkar }; 8436df96f8SMahesh Salgaonkar 8536df96f8SMahesh Salgaonkar enum MCE_Initiator { 8636df96f8SMahesh Salgaonkar MCE_INITIATOR_UNKNOWN = 0, 8736df96f8SMahesh Salgaonkar MCE_INITIATOR_CPU = 1, 8836df96f8SMahesh Salgaonkar }; 8936df96f8SMahesh Salgaonkar 9036df96f8SMahesh Salgaonkar enum MCE_ErrorType { 9136df96f8SMahesh Salgaonkar MCE_ERROR_TYPE_UNKNOWN = 0, 9236df96f8SMahesh Salgaonkar MCE_ERROR_TYPE_UE = 1, 9336df96f8SMahesh Salgaonkar MCE_ERROR_TYPE_SLB = 2, 9436df96f8SMahesh Salgaonkar MCE_ERROR_TYPE_ERAT = 3, 9536df96f8SMahesh Salgaonkar MCE_ERROR_TYPE_TLB = 4, 9636df96f8SMahesh Salgaonkar }; 9736df96f8SMahesh Salgaonkar 9836df96f8SMahesh Salgaonkar enum MCE_UeErrorType { 9936df96f8SMahesh Salgaonkar MCE_UE_ERROR_INDETERMINATE = 0, 10036df96f8SMahesh Salgaonkar MCE_UE_ERROR_IFETCH = 1, 10136df96f8SMahesh Salgaonkar MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2, 10236df96f8SMahesh Salgaonkar MCE_UE_ERROR_LOAD_STORE = 3, 10336df96f8SMahesh Salgaonkar MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4, 10436df96f8SMahesh Salgaonkar }; 10536df96f8SMahesh Salgaonkar 10636df96f8SMahesh Salgaonkar enum MCE_SlbErrorType { 10736df96f8SMahesh Salgaonkar MCE_SLB_ERROR_INDETERMINATE = 0, 10836df96f8SMahesh Salgaonkar MCE_SLB_ERROR_PARITY = 1, 10936df96f8SMahesh Salgaonkar MCE_SLB_ERROR_MULTIHIT = 2, 11036df96f8SMahesh Salgaonkar }; 11136df96f8SMahesh Salgaonkar 11236df96f8SMahesh Salgaonkar enum MCE_EratErrorType { 11336df96f8SMahesh Salgaonkar MCE_ERAT_ERROR_INDETERMINATE = 0, 11436df96f8SMahesh Salgaonkar MCE_ERAT_ERROR_PARITY = 1, 11536df96f8SMahesh Salgaonkar MCE_ERAT_ERROR_MULTIHIT = 2, 11636df96f8SMahesh Salgaonkar }; 11736df96f8SMahesh Salgaonkar 11836df96f8SMahesh Salgaonkar enum MCE_TlbErrorType { 11936df96f8SMahesh Salgaonkar MCE_TLB_ERROR_INDETERMINATE = 0, 12036df96f8SMahesh Salgaonkar MCE_TLB_ERROR_PARITY = 1, 12136df96f8SMahesh Salgaonkar MCE_TLB_ERROR_MULTIHIT = 2, 12236df96f8SMahesh Salgaonkar }; 12336df96f8SMahesh Salgaonkar 12436df96f8SMahesh Salgaonkar struct machine_check_event { 12536df96f8SMahesh Salgaonkar enum MCE_Version version:8; /* 0x00 */ 12636df96f8SMahesh Salgaonkar uint8_t in_use; /* 0x01 */ 12736df96f8SMahesh Salgaonkar enum MCE_Severity severity:8; /* 0x02 */ 12836df96f8SMahesh Salgaonkar enum MCE_Initiator initiator:8; /* 0x03 */ 12936df96f8SMahesh Salgaonkar enum MCE_ErrorType error_type:8; /* 0x04 */ 13036df96f8SMahesh Salgaonkar enum MCE_Disposition disposition:8; /* 0x05 */ 13136df96f8SMahesh Salgaonkar uint8_t reserved_1[2]; /* 0x06 */ 13236df96f8SMahesh Salgaonkar uint64_t gpr3; /* 0x08 */ 13336df96f8SMahesh Salgaonkar uint64_t srr0; /* 0x10 */ 13436df96f8SMahesh Salgaonkar uint64_t srr1; /* 0x18 */ 13536df96f8SMahesh Salgaonkar union { /* 0x20 */ 13636df96f8SMahesh Salgaonkar struct { 13736df96f8SMahesh Salgaonkar enum MCE_UeErrorType ue_error_type:8; 13836df96f8SMahesh Salgaonkar uint8_t effective_address_provided; 13936df96f8SMahesh Salgaonkar uint8_t physical_address_provided; 14036df96f8SMahesh Salgaonkar uint8_t reserved_1[5]; 14136df96f8SMahesh Salgaonkar uint64_t effective_address; 14236df96f8SMahesh Salgaonkar uint64_t physical_address; 14336df96f8SMahesh Salgaonkar uint8_t reserved_2[8]; 14436df96f8SMahesh Salgaonkar } ue_error; 14536df96f8SMahesh Salgaonkar 14636df96f8SMahesh Salgaonkar struct { 14736df96f8SMahesh Salgaonkar enum MCE_SlbErrorType slb_error_type:8; 14836df96f8SMahesh Salgaonkar uint8_t effective_address_provided; 14936df96f8SMahesh Salgaonkar uint8_t reserved_1[6]; 15036df96f8SMahesh Salgaonkar uint64_t effective_address; 15136df96f8SMahesh Salgaonkar uint8_t reserved_2[16]; 15236df96f8SMahesh Salgaonkar } slb_error; 15336df96f8SMahesh Salgaonkar 15436df96f8SMahesh Salgaonkar struct { 15536df96f8SMahesh Salgaonkar enum MCE_EratErrorType erat_error_type:8; 15636df96f8SMahesh Salgaonkar uint8_t effective_address_provided; 15736df96f8SMahesh Salgaonkar uint8_t reserved_1[6]; 15836df96f8SMahesh Salgaonkar uint64_t effective_address; 15936df96f8SMahesh Salgaonkar uint8_t reserved_2[16]; 16036df96f8SMahesh Salgaonkar } erat_error; 16136df96f8SMahesh Salgaonkar 16236df96f8SMahesh Salgaonkar struct { 16336df96f8SMahesh Salgaonkar enum MCE_TlbErrorType tlb_error_type:8; 16436df96f8SMahesh Salgaonkar uint8_t effective_address_provided; 16536df96f8SMahesh Salgaonkar uint8_t reserved_1[6]; 16636df96f8SMahesh Salgaonkar uint64_t effective_address; 16736df96f8SMahesh Salgaonkar uint8_t reserved_2[16]; 16836df96f8SMahesh Salgaonkar } tlb_error; 16936df96f8SMahesh Salgaonkar } u; 17036df96f8SMahesh Salgaonkar }; 17136df96f8SMahesh Salgaonkar 17236df96f8SMahesh Salgaonkar struct mce_error_info { 17336df96f8SMahesh Salgaonkar enum MCE_ErrorType error_type:8; 17436df96f8SMahesh Salgaonkar union { 17536df96f8SMahesh Salgaonkar enum MCE_UeErrorType ue_error_type:8; 17636df96f8SMahesh Salgaonkar enum MCE_SlbErrorType slb_error_type:8; 17736df96f8SMahesh Salgaonkar enum MCE_EratErrorType erat_error_type:8; 17836df96f8SMahesh Salgaonkar enum MCE_TlbErrorType tlb_error_type:8; 17936df96f8SMahesh Salgaonkar } u; 18036df96f8SMahesh Salgaonkar uint8_t reserved[2]; 18136df96f8SMahesh Salgaonkar }; 18236df96f8SMahesh Salgaonkar 18336df96f8SMahesh Salgaonkar #define MAX_MC_EVT 100 18436df96f8SMahesh Salgaonkar 18536df96f8SMahesh Salgaonkar /* Release flags for get_mce_event() */ 18636df96f8SMahesh Salgaonkar #define MCE_EVENT_RELEASE true 18736df96f8SMahesh Salgaonkar #define MCE_EVENT_DONTRELEASE false 18836df96f8SMahesh Salgaonkar 18936df96f8SMahesh Salgaonkar extern void save_mce_event(struct pt_regs *regs, long handled, 19036df96f8SMahesh Salgaonkar struct mce_error_info *mce_err, uint64_t addr); 19136df96f8SMahesh Salgaonkar extern int get_mce_event(struct machine_check_event *mce, bool release); 19236df96f8SMahesh Salgaonkar extern void release_mce_event(void); 193b5ff4211SMahesh Salgaonkar extern void machine_check_queue_event(void); 194b5ff4211SMahesh Salgaonkar extern void machine_check_process_queued_event(void); 195b5ff4211SMahesh Salgaonkar extern void machine_check_print_event_info(struct machine_check_event *evt); 196*b63a0ffeSMahesh Salgaonkar extern uint64_t get_mce_fault_addr(struct machine_check_event *evt); 197ae744f34SMahesh Salgaonkar 198e22a2274SMahesh Salgaonkar #endif /* __ASM_PPC64_MCE_H__ */ 199