Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Machine check exception header file.
0004  *
0005  * Copyright 2013 IBM Corporation
0006  * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
0007  */
0008 
0009 #ifndef __ASM_PPC64_MCE_H__
0010 #define __ASM_PPC64_MCE_H__
0011 
0012 #include <linux/bitops.h>
0013 
0014 enum MCE_Version {
0015     MCE_V1 = 1,
0016 };
0017 
0018 enum MCE_Severity {
0019     MCE_SEV_NO_ERROR = 0,
0020     MCE_SEV_WARNING = 1,
0021     MCE_SEV_SEVERE = 2,
0022     MCE_SEV_FATAL = 3,
0023 };
0024 
0025 enum MCE_Disposition {
0026     MCE_DISPOSITION_RECOVERED = 0,
0027     MCE_DISPOSITION_NOT_RECOVERED = 1,
0028 };
0029 
0030 enum MCE_Initiator {
0031     MCE_INITIATOR_UNKNOWN = 0,
0032     MCE_INITIATOR_CPU = 1,
0033     MCE_INITIATOR_PCI = 2,
0034     MCE_INITIATOR_ISA = 3,
0035     MCE_INITIATOR_MEMORY= 4,
0036     MCE_INITIATOR_POWERMGM = 5,
0037 };
0038 
0039 enum MCE_ErrorType {
0040     MCE_ERROR_TYPE_UNKNOWN = 0,
0041     MCE_ERROR_TYPE_UE = 1,
0042     MCE_ERROR_TYPE_SLB = 2,
0043     MCE_ERROR_TYPE_ERAT = 3,
0044     MCE_ERROR_TYPE_TLB = 4,
0045     MCE_ERROR_TYPE_USER = 5,
0046     MCE_ERROR_TYPE_RA = 6,
0047     MCE_ERROR_TYPE_LINK = 7,
0048     MCE_ERROR_TYPE_DCACHE = 8,
0049     MCE_ERROR_TYPE_ICACHE = 9,
0050 };
0051 
0052 enum MCE_ErrorClass {
0053     MCE_ECLASS_UNKNOWN = 0,
0054     MCE_ECLASS_HARDWARE,
0055     MCE_ECLASS_HARD_INDETERMINATE,
0056     MCE_ECLASS_SOFTWARE,
0057     MCE_ECLASS_SOFT_INDETERMINATE,
0058 };
0059 
0060 enum MCE_UeErrorType {
0061     MCE_UE_ERROR_INDETERMINATE = 0,
0062     MCE_UE_ERROR_IFETCH = 1,
0063     MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH = 2,
0064     MCE_UE_ERROR_LOAD_STORE = 3,
0065     MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 4,
0066 };
0067 
0068 enum MCE_SlbErrorType {
0069     MCE_SLB_ERROR_INDETERMINATE = 0,
0070     MCE_SLB_ERROR_PARITY = 1,
0071     MCE_SLB_ERROR_MULTIHIT = 2,
0072 };
0073 
0074 enum MCE_EratErrorType {
0075     MCE_ERAT_ERROR_INDETERMINATE = 0,
0076     MCE_ERAT_ERROR_PARITY = 1,
0077     MCE_ERAT_ERROR_MULTIHIT = 2,
0078 };
0079 
0080 enum MCE_TlbErrorType {
0081     MCE_TLB_ERROR_INDETERMINATE = 0,
0082     MCE_TLB_ERROR_PARITY = 1,
0083     MCE_TLB_ERROR_MULTIHIT = 2,
0084 };
0085 
0086 enum MCE_UserErrorType {
0087     MCE_USER_ERROR_INDETERMINATE = 0,
0088     MCE_USER_ERROR_TLBIE = 1,
0089     MCE_USER_ERROR_SCV = 2,
0090 };
0091 
0092 enum MCE_RaErrorType {
0093     MCE_RA_ERROR_INDETERMINATE = 0,
0094     MCE_RA_ERROR_IFETCH = 1,
0095     MCE_RA_ERROR_IFETCH_FOREIGN = 2,
0096     MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 3,
0097     MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 4,
0098     MCE_RA_ERROR_LOAD = 5,
0099     MCE_RA_ERROR_STORE = 6,
0100     MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 7,
0101     MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 8,
0102     MCE_RA_ERROR_LOAD_STORE_FOREIGN = 9,
0103 };
0104 
0105 enum MCE_LinkErrorType {
0106     MCE_LINK_ERROR_INDETERMINATE = 0,
0107     MCE_LINK_ERROR_IFETCH_TIMEOUT = 1,
0108     MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2,
0109     MCE_LINK_ERROR_LOAD_TIMEOUT = 3,
0110     MCE_LINK_ERROR_STORE_TIMEOUT = 4,
0111     MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5,
0112 };
0113 
0114 struct machine_check_event {
0115     enum MCE_Version    version:8;
0116     u8          in_use;
0117     enum MCE_Severity   severity:8;
0118     enum MCE_Initiator  initiator:8;
0119     enum MCE_ErrorType  error_type:8;
0120     enum MCE_ErrorClass error_class:8;
0121     enum MCE_Disposition    disposition:8;
0122     bool            sync_error;
0123     u16         cpu;
0124     u64         gpr3;
0125     u64         srr0;
0126     u64         srr1;
0127     union {
0128         struct {
0129             enum MCE_UeErrorType ue_error_type:8;
0130             u8      effective_address_provided;
0131             u8      physical_address_provided;
0132             u8      ignore_event;
0133             u8      reserved_1[4];
0134             u64     effective_address;
0135             u64     physical_address;
0136             u8      reserved_2[8];
0137         } ue_error;
0138 
0139         struct {
0140             enum MCE_SlbErrorType slb_error_type:8;
0141             u8      effective_address_provided;
0142             u8      reserved_1[6];
0143             u64     effective_address;
0144             u8      reserved_2[16];
0145         } slb_error;
0146 
0147         struct {
0148             enum MCE_EratErrorType erat_error_type:8;
0149             u8      effective_address_provided;
0150             u8      reserved_1[6];
0151             u64     effective_address;
0152             u8      reserved_2[16];
0153         } erat_error;
0154 
0155         struct {
0156             enum MCE_TlbErrorType tlb_error_type:8;
0157             u8      effective_address_provided;
0158             u8      reserved_1[6];
0159             u64     effective_address;
0160             u8      reserved_2[16];
0161         } tlb_error;
0162 
0163         struct {
0164             enum MCE_UserErrorType user_error_type:8;
0165             u8      effective_address_provided;
0166             u8      reserved_1[6];
0167             u64     effective_address;
0168             u8      reserved_2[16];
0169         } user_error;
0170 
0171         struct {
0172             enum MCE_RaErrorType ra_error_type:8;
0173             u8      effective_address_provided;
0174             u8      reserved_1[6];
0175             u64     effective_address;
0176             u8      reserved_2[16];
0177         } ra_error;
0178 
0179         struct {
0180             enum MCE_LinkErrorType link_error_type:8;
0181             u8      effective_address_provided;
0182             u8      reserved_1[6];
0183             u64     effective_address;
0184             u8      reserved_2[16];
0185         } link_error;
0186     } u;
0187 };
0188 
0189 struct mce_error_info {
0190     enum MCE_ErrorType error_type:8;
0191     union {
0192         enum MCE_UeErrorType ue_error_type:8;
0193         enum MCE_SlbErrorType slb_error_type:8;
0194         enum MCE_EratErrorType erat_error_type:8;
0195         enum MCE_TlbErrorType tlb_error_type:8;
0196         enum MCE_UserErrorType user_error_type:8;
0197         enum MCE_RaErrorType ra_error_type:8;
0198         enum MCE_LinkErrorType link_error_type:8;
0199     } u;
0200     enum MCE_Severity   severity:8;
0201     enum MCE_Initiator  initiator:8;
0202     enum MCE_ErrorClass error_class:8;
0203     bool            sync_error;
0204     bool            ignore_event;
0205 };
0206 
0207 #define MAX_MC_EVT  10
0208 
0209 struct mce_info {
0210     int mce_nest_count;
0211     struct machine_check_event mce_event[MAX_MC_EVT];
0212     /* Queue for delayed MCE events. */
0213     int mce_queue_count;
0214     struct machine_check_event mce_event_queue[MAX_MC_EVT];
0215     /* Queue for delayed MCE UE events. */
0216     int mce_ue_count;
0217     struct machine_check_event  mce_ue_event_queue[MAX_MC_EVT];
0218 };
0219 
0220 /* Release flags for get_mce_event() */
0221 #define MCE_EVENT_RELEASE   true
0222 #define MCE_EVENT_DONTRELEASE   false
0223 
0224 struct pt_regs;
0225 struct notifier_block;
0226 
0227 extern void save_mce_event(struct pt_regs *regs, long handled,
0228                struct mce_error_info *mce_err, uint64_t nip,
0229                uint64_t addr, uint64_t phys_addr);
0230 extern int get_mce_event(struct machine_check_event *mce, bool release);
0231 extern void release_mce_event(void);
0232 extern void machine_check_queue_event(void);
0233 extern void machine_check_print_event_info(struct machine_check_event *evt,
0234                        bool user_mode, bool in_guest);
0235 unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr);
0236 extern void mce_common_process_ue(struct pt_regs *regs,
0237                   struct mce_error_info *mce_err);
0238 void mce_irq_work_queue(void);
0239 int mce_register_notifier(struct notifier_block *nb);
0240 int mce_unregister_notifier(struct notifier_block *nb);
0241 
0242 #ifdef CONFIG_PPC_BOOK3S_64
0243 void mce_run_irq_context_handlers(void);
0244 #else
0245 static inline void mce_run_irq_context_handlers(void) { };
0246 #endif /* CONFIG_PPC_BOOK3S_64 */
0247 
0248 #ifdef CONFIG_PPC_BOOK3S_64
0249 void set_mce_pending_irq_work(void);
0250 void clear_mce_pending_irq_work(void);
0251 #endif /* CONFIG_PPC_BOOK3S_64 */
0252 
0253 #ifdef CONFIG_PPC_BOOK3S_64
0254 void flush_and_reload_slb(void);
0255 void flush_erat(void);
0256 long __machine_check_early_realmode_p7(struct pt_regs *regs);
0257 long __machine_check_early_realmode_p8(struct pt_regs *regs);
0258 long __machine_check_early_realmode_p9(struct pt_regs *regs);
0259 long __machine_check_early_realmode_p10(struct pt_regs *regs);
0260 #endif /* CONFIG_PPC_BOOK3S_64 */
0261 
0262 #ifdef CONFIG_PPC_BOOK3S_64
0263 void mce_init(void);
0264 #else
0265 static inline void mce_init(void) { };
0266 #endif /* CONFIG_PPC_BOOK3S_64 */
0267 
0268 #endif /* __ASM_PPC64_MCE_H__ */