10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_ASYNC_H 280Sstevel@tonic-gate #define _SYS_ASYNC_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/privregs.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifndef _ASM 390Sstevel@tonic-gate 400Sstevel@tonic-gate #include <sys/errorq.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * The async_flt structure is used to record all pertinent information about 440Sstevel@tonic-gate * an asynchronous CPU or bus-related memory error. Typically, the structure 450Sstevel@tonic-gate * is initialized by a high-level interrupt or trap handler, and then enqueued 460Sstevel@tonic-gate * for later processing. Separate queues are maintained for correctable and 470Sstevel@tonic-gate * uncorrectable errors. The current CPU module determines the size of the 480Sstevel@tonic-gate * queue elements, so that it may declare a CPU-specific fault structure 490Sstevel@tonic-gate * which contains a struct async_flt as its first member. Each async_flt also 500Sstevel@tonic-gate * contains a callback function (flt_func) that is invoked by the processing 510Sstevel@tonic-gate * code in order to actually log messages when the event is dequeued. This 520Sstevel@tonic-gate * function may be called from a softint, from trap() as part of AST handling 530Sstevel@tonic-gate * before the victim thread returns to userland, or as part of panic(). As 540Sstevel@tonic-gate * such, the flt_func should basically only be calling cmn_err (but NOT with 550Sstevel@tonic-gate * the CE_PANIC flag). It must not call panic(), acquire locks, or block. 560Sstevel@tonic-gate * The owner of the event is responsible for determining whether the event is 570Sstevel@tonic-gate * fatal; if so, the owner should set flt_panic and panic() after enqueuing 580Sstevel@tonic-gate * the event. The event will then be dequeued and logged as part of panic 590Sstevel@tonic-gate * processing. If flt_panic is not set, the queue function will schedule a 600Sstevel@tonic-gate * soft interrupt to process the event. 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate 630Sstevel@tonic-gate struct async_flt; 640Sstevel@tonic-gate typedef void (*async_func_t)(struct async_flt *, char *); 650Sstevel@tonic-gate 660Sstevel@tonic-gate struct async_flt { 670Sstevel@tonic-gate uint64_t flt_id; /* gethrtime() at time of fault */ 680Sstevel@tonic-gate uint64_t flt_stat; /* async fault status register */ 690Sstevel@tonic-gate uint64_t flt_addr; /* async fault address register */ 700Sstevel@tonic-gate caddr_t flt_pc; /* program counter from error trap */ 710Sstevel@tonic-gate async_func_t flt_func; /* logging function */ 720Sstevel@tonic-gate uint_t flt_bus_id; /* hardware bus id# of cpu/sbus/pci */ 730Sstevel@tonic-gate uint_t flt_inst; /* software instance of cpu/sbus/pci */ 740Sstevel@tonic-gate ushort_t flt_status; /* error information */ 750Sstevel@tonic-gate ushort_t flt_synd; /* ECC syndrome */ 760Sstevel@tonic-gate uchar_t flt_in_memory; /* fault occurred in memory if != 0 */ 770Sstevel@tonic-gate uchar_t flt_class; /* fault class (cpu or bus) */ 780Sstevel@tonic-gate uchar_t flt_prot; /* type of fault protection (if any) */ 790Sstevel@tonic-gate uchar_t flt_priv; /* fault occurred in kernel if != 0 */ 800Sstevel@tonic-gate uchar_t flt_panic; /* fault caused owner to panic() */ 810Sstevel@tonic-gate uchar_t flt_tl; /* fault occurred at TL > 0 */ 820Sstevel@tonic-gate uchar_t flt_core; /* fault occurred during core() dump */ 830Sstevel@tonic-gate uchar_t flt_pad; /* reserved for future use */ 840Sstevel@tonic-gate uint64_t flt_disp; /* error disposition information */ 850Sstevel@tonic-gate uint64_t flt_payload; /* ereport payload information */ 860Sstevel@tonic-gate char *flt_erpt_class; /* ereport class string */ 870Sstevel@tonic-gate }; 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 900Sstevel@tonic-gate * Bus nexus drivers can use the bus_func_register() interface to register 910Sstevel@tonic-gate * callback functions for error handling and panic handling. The handler 920Sstevel@tonic-gate * functions should be registered and unregistered from driver attach and 930Sstevel@tonic-gate * detach context, where it is safe to perform a sleeping allocation. The 940Sstevel@tonic-gate * callbacks themselves can be invoked from panic, or from the CPU module's 950Sstevel@tonic-gate * asynchronous trap handler at high PIL. As such, these routines may only 960Sstevel@tonic-gate * test for errors and enqueue async_flt events. They may not grab adaptive 970Sstevel@tonic-gate * locks, call panic(), or invoke bus_func_register() or bus_func_unregister(). 980Sstevel@tonic-gate * Each callback function should return one of the BF_* return status values 990Sstevel@tonic-gate * below. The bus_func_invoke() function calls all the registered handlers of 1000Sstevel@tonic-gate * the specified type, and returns the maximum of their return values (e.g. 1010Sstevel@tonic-gate * BF_FATAL if any callback returned BF_FATAL). If any callback returns 1020Sstevel@tonic-gate * BF_FATAL, the system will panic at the end of callback processing. 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate typedef uint_t (*busfunc_t)(void *); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #define BF_TYPE_UE 1 /* check for uncorrectable errors */ 1080Sstevel@tonic-gate #define BF_TYPE_ERRDIS 2 /* disable error detection */ 1090Sstevel@tonic-gate #define BF_TYPE_RESINTR 3 /* reset interrupts */ 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate #define BF_NONE 0 /* no errors were detected */ 1120Sstevel@tonic-gate #define BF_NONFATAL 1 /* one or more non-fatal errors found */ 1130Sstevel@tonic-gate #define BF_FATAL 2 /* one or more fatal errors found */ 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate typedef struct bus_func_desc { 1160Sstevel@tonic-gate int bf_type; /* type of function (see above) */ 1170Sstevel@tonic-gate busfunc_t bf_func; /* function to call */ 1180Sstevel@tonic-gate void *bf_arg; /* function argument */ 1190Sstevel@tonic-gate struct bus_func_desc *bf_next; /* pointer to next registered desc */ 1200Sstevel@tonic-gate } bus_func_desc_t; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate extern void bus_func_register(int, busfunc_t, void *); 1230Sstevel@tonic-gate extern void bus_func_unregister(int, busfunc_t, void *); 1240Sstevel@tonic-gate extern void bus_async_log_err(struct async_flt *); 1250Sstevel@tonic-gate extern uint_t bus_func_invoke(int); 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate extern void ecc_cpu_call(struct async_flt *, char *, int); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate extern void ce_scrub(struct async_flt *); 1300Sstevel@tonic-gate extern void ecc_page_zero(void *); 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate extern void error_init(void); 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate extern int ce_verbose_memory; 1350Sstevel@tonic-gate extern int ce_verbose_other; 1360Sstevel@tonic-gate extern int ce_show_data; 1370Sstevel@tonic-gate extern int ce_debug; 1380Sstevel@tonic-gate extern int ue_debug; 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate extern int aft_verbose; 1410Sstevel@tonic-gate extern int aft_panic; 1420Sstevel@tonic-gate extern int aft_testfatal; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate extern struct async_flt panic_aflt; 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate extern errorq_t *ce_queue; 1470Sstevel@tonic-gate extern errorq_t *ue_queue; 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate #endif /* !_ASM */ 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * ECC or parity error status for async_flt.flt_status. 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate #define ECC_C_TRAP 0x0001 /* Trap 0x63 Corrected ECC Error */ 1550Sstevel@tonic-gate #define ECC_I_TRAP 0x0002 /* Trap 0x0A Instr Access Error */ 1560Sstevel@tonic-gate #define ECC_ECACHE 0x0004 /* Ecache ECC Error */ 1570Sstevel@tonic-gate #define ECC_IOBUS 0x0008 /* Pci or sysio ECC Error */ 1580Sstevel@tonic-gate #define ECC_INTERMITTENT 0x0010 /* Intermittent ECC Error */ 1590Sstevel@tonic-gate #define ECC_PERSISTENT 0x0020 /* Persistent ECC Error */ 1600Sstevel@tonic-gate #define ECC_STICKY 0x0040 /* Sticky ECC Error */ 1610Sstevel@tonic-gate #define ECC_D_TRAP 0x0080 /* Trap 0x32 Data Access Error */ 1620Sstevel@tonic-gate #define ECC_F_TRAP 0x0100 /* Cheetah Trap 0x70 Fast ECC Error */ 1630Sstevel@tonic-gate #define ECC_DP_TRAP 0x0200 /* Cheetah+ Trap 0x71 D$ Parity Error */ 1640Sstevel@tonic-gate #define ECC_IP_TRAP 0x0400 /* Cheetah+ Trap 0x72 I$ Parity Error */ 1650Sstevel@tonic-gate #define ECC_ITLB_TRAP 0x0800 /* Panther ITLB Parity Error */ 1660Sstevel@tonic-gate #define ECC_DTLB_TRAP 0x1000 /* Panther DTLB Parity Error */ 1670Sstevel@tonic-gate #define ECC_IO_CE 0x2000 /* Pci or sysio CE */ 1680Sstevel@tonic-gate #define ECC_IO_UE 0x4000 /* Pci or sysio UE */ 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* 1710Sstevel@tonic-gate * Trap type numbers corresponding to the fault types defined above. 1720Sstevel@tonic-gate */ 1730Sstevel@tonic-gate #define TRAP_TYPE_ECC_I 0x0A 1740Sstevel@tonic-gate #define TRAP_TYPE_ECC_D 0x32 1750Sstevel@tonic-gate #define TRAP_TYPE_ECC_F 0x70 1760Sstevel@tonic-gate #define TRAP_TYPE_ECC_C 0x63 1770Sstevel@tonic-gate #define TRAP_TYPE_ECC_DP 0x71 1780Sstevel@tonic-gate #define TRAP_TYPE_ECC_IP 0x72 1790Sstevel@tonic-gate #define TRAP_TYPE_ECC_ITLB 0x08 1800Sstevel@tonic-gate #define TRAP_TYPE_ECC_DTLB 0x30 1810Sstevel@tonic-gate #define TRAP_TYPE_UNKNOWN 0 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* 1840Sstevel@tonic-gate * Fault classes for async_flt.flt_class. 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate #define BUS_FAULT 0 /* originating from bus drivers */ 1870Sstevel@tonic-gate #define CPU_FAULT 1 /* originating from CPUs */ 1880Sstevel@tonic-gate #define RECIRC_BUS_FAULT 2 /* scheduled diagnostic */ 1890Sstevel@tonic-gate #define RECIRC_CPU_FAULT 3 /* scheduled diagnostic */ 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate /* 1920Sstevel@tonic-gate * Invalid or unknown physical address for async_flt.flt_addr. 1930Sstevel@tonic-gate */ 1940Sstevel@tonic-gate #define AFLT_INV_ADDR (-1ULL) 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate /* 1970Sstevel@tonic-gate * Fault protection values for async_flt.flt_prot. The async error handling 1980Sstevel@tonic-gate * code may be able to recover from errors when kernel code has explicitly 1990Sstevel@tonic-gate * protected itself using one of the mechanisms specified here. 2000Sstevel@tonic-gate */ 2010Sstevel@tonic-gate #define AFLT_PROT_NONE 0 /* no protection active */ 2020Sstevel@tonic-gate #define AFLT_PROT_ACCESS 1 /* on_trap OT_DATA_ACCESS protection */ 2030Sstevel@tonic-gate #define AFLT_PROT_EC 2 /* on_trap OT_DATA_EC protection */ 2040Sstevel@tonic-gate #define AFLT_PROT_COPY 3 /* t_lofault protection (ucopy, etc.) */ 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate /* 2070Sstevel@tonic-gate * These flags are used to indicate the validity of certain data based on 2080Sstevel@tonic-gate * the various overwrite priority features of the AFSR/AFAR: 2090Sstevel@tonic-gate * AFAR, ESYND and MSYND, each of which have different overwrite priorities. 2100Sstevel@tonic-gate * 2110Sstevel@tonic-gate * Given a specific afsr error bit and the entire afsr, there are three cases: 2120Sstevel@tonic-gate * INVALID: The specified bit is lower overwrite priority than some other 2130Sstevel@tonic-gate * error bit which is on in the afsr (or IVU/IVC). 2140Sstevel@tonic-gate * VALID: The specified bit is higher priority than all other error bits 2150Sstevel@tonic-gate * which are on in the afsr. 2160Sstevel@tonic-gate * AMBIGUOUS: Another error bit (or bits) of equal priority to the specified 2170Sstevel@tonic-gate * bit is on in the afsr. 2180Sstevel@tonic-gate * 2190Sstevel@tonic-gate * NB: The domain-to-SC communications depend on these values. If they are 2200Sstevel@tonic-gate * changed, plat_ecc_unum.[ch] must be updated to match. 2210Sstevel@tonic-gate */ 2220Sstevel@tonic-gate #define AFLT_STAT_INVALID 0 /* higher priority afsr bit is on */ 2230Sstevel@tonic-gate #define AFLT_STAT_VALID 1 /* this is highest priority afsr bit */ 2240Sstevel@tonic-gate #define AFLT_STAT_AMBIGUOUS 2 /* two afsr bits of equal priority */ 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate /* 2270Sstevel@tonic-gate * Maximum length of unum string. 2280Sstevel@tonic-gate */ 2290Sstevel@tonic-gate #define UNUM_NAMLEN 60 2300Sstevel@tonic-gate 231*1186Sayznaga /* 232*1186Sayznaga * Maximum length of a DIMM serial id string + null 233*1186Sayznaga */ 234*1186Sayznaga #define DIMM_SERIAL_ID_LEN 16 235*1186Sayznaga 2360Sstevel@tonic-gate #ifdef __cplusplus 2370Sstevel@tonic-gate } 2380Sstevel@tonic-gate #endif 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate #endif /* _SYS_ASYNC_H */ 241