xref: /titanic_53/usr/src/uts/sun4/sys/async.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_ASYNC_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_ASYNC_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/privregs.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
35*7c478bd9Sstevel@tonic-gate extern "C" {
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include <sys/errorq.h>
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * The async_flt structure is used to record all pertinent information about
44*7c478bd9Sstevel@tonic-gate  * an asynchronous CPU or bus-related memory error.  Typically, the structure
45*7c478bd9Sstevel@tonic-gate  * is initialized by a high-level interrupt or trap handler, and then enqueued
46*7c478bd9Sstevel@tonic-gate  * for later processing.  Separate queues are maintained for correctable and
47*7c478bd9Sstevel@tonic-gate  * uncorrectable errors.  The current CPU module determines the size of the
48*7c478bd9Sstevel@tonic-gate  * queue elements, so that it may declare a CPU-specific fault structure
49*7c478bd9Sstevel@tonic-gate  * which contains a struct async_flt as its first member.  Each async_flt also
50*7c478bd9Sstevel@tonic-gate  * contains a callback function (flt_func) that is invoked by the processing
51*7c478bd9Sstevel@tonic-gate  * code in order to actually log messages when the event is dequeued.  This
52*7c478bd9Sstevel@tonic-gate  * function may be called from a softint, from trap() as part of AST handling
53*7c478bd9Sstevel@tonic-gate  * before the victim thread returns to userland, or as part of panic().  As
54*7c478bd9Sstevel@tonic-gate  * such, the flt_func should basically only be calling cmn_err (but NOT with
55*7c478bd9Sstevel@tonic-gate  * the CE_PANIC flag).  It must not call panic(), acquire locks, or block.
56*7c478bd9Sstevel@tonic-gate  * The owner of the event is responsible for determining whether the event is
57*7c478bd9Sstevel@tonic-gate  * fatal; if so, the owner should set flt_panic and panic() after enqueuing
58*7c478bd9Sstevel@tonic-gate  * the event.  The event will then be dequeued and logged as part of panic
59*7c478bd9Sstevel@tonic-gate  * processing.  If flt_panic is not set, the queue function will schedule a
60*7c478bd9Sstevel@tonic-gate  * soft interrupt to process the event.
61*7c478bd9Sstevel@tonic-gate  */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate struct async_flt;
64*7c478bd9Sstevel@tonic-gate typedef void (*async_func_t)(struct async_flt *, char *);
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate struct async_flt {
67*7c478bd9Sstevel@tonic-gate 	uint64_t	flt_id;		/* gethrtime() at time of fault */
68*7c478bd9Sstevel@tonic-gate 	uint64_t	flt_stat;	/* async fault status register */
69*7c478bd9Sstevel@tonic-gate 	uint64_t	flt_addr;	/* async fault address register */
70*7c478bd9Sstevel@tonic-gate 	caddr_t		flt_pc;		/* program counter from error trap */
71*7c478bd9Sstevel@tonic-gate 	async_func_t	flt_func;	/* logging function */
72*7c478bd9Sstevel@tonic-gate 	uint_t		flt_bus_id;	/* hardware bus id# of cpu/sbus/pci */
73*7c478bd9Sstevel@tonic-gate 	uint_t		flt_inst;	/* software instance of cpu/sbus/pci */
74*7c478bd9Sstevel@tonic-gate 	ushort_t	flt_status;	/* error information */
75*7c478bd9Sstevel@tonic-gate 	ushort_t	flt_synd;	/* ECC syndrome */
76*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_in_memory;	/* fault occurred in memory if != 0 */
77*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_class;	/* fault class (cpu or bus) */
78*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_prot;	/* type of fault protection (if any) */
79*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_priv;	/* fault occurred in kernel if != 0 */
80*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_panic;	/* fault caused owner to panic() */
81*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_tl;		/* fault occurred at TL > 0 */
82*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_core;	/* fault occurred during core() dump */
83*7c478bd9Sstevel@tonic-gate 	uchar_t		flt_pad;	/* reserved for future use */
84*7c478bd9Sstevel@tonic-gate 	uint64_t	flt_disp;	/* error disposition information */
85*7c478bd9Sstevel@tonic-gate 	uint64_t	flt_payload;	/* ereport payload information */
86*7c478bd9Sstevel@tonic-gate 	char		*flt_erpt_class; /* ereport class string */
87*7c478bd9Sstevel@tonic-gate };
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate /*
90*7c478bd9Sstevel@tonic-gate  * Bus nexus drivers can use the bus_func_register() interface to register
91*7c478bd9Sstevel@tonic-gate  * callback functions for error handling and panic handling.  The handler
92*7c478bd9Sstevel@tonic-gate  * functions should be registered and unregistered from driver attach and
93*7c478bd9Sstevel@tonic-gate  * detach context, where it is safe to perform a sleeping allocation.  The
94*7c478bd9Sstevel@tonic-gate  * callbacks themselves can be invoked from panic, or from the CPU module's
95*7c478bd9Sstevel@tonic-gate  * asynchronous trap handler at high PIL.  As such, these routines may only
96*7c478bd9Sstevel@tonic-gate  * test for errors and enqueue async_flt events.  They may not grab adaptive
97*7c478bd9Sstevel@tonic-gate  * locks, call panic(), or invoke bus_func_register() or bus_func_unregister().
98*7c478bd9Sstevel@tonic-gate  * Each callback function should return one of the BF_* return status values
99*7c478bd9Sstevel@tonic-gate  * below.  The bus_func_invoke() function calls all the registered handlers of
100*7c478bd9Sstevel@tonic-gate  * the specified type, and returns the maximum of their return values (e.g.
101*7c478bd9Sstevel@tonic-gate  * BF_FATAL if any callback returned BF_FATAL).  If any callback returns
102*7c478bd9Sstevel@tonic-gate  * BF_FATAL, the system will panic at the end of callback processing.
103*7c478bd9Sstevel@tonic-gate  */
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate typedef	uint_t (*busfunc_t)(void *);
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate #define	BF_TYPE_UE		1	/* check for uncorrectable errors */
108*7c478bd9Sstevel@tonic-gate #define	BF_TYPE_ERRDIS		2	/* disable error detection */
109*7c478bd9Sstevel@tonic-gate #define	BF_TYPE_RESINTR		3	/* reset interrupts */
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #define	BF_NONE			0	/* no errors were detected */
112*7c478bd9Sstevel@tonic-gate #define	BF_NONFATAL		1	/* one or more non-fatal errors found */
113*7c478bd9Sstevel@tonic-gate #define	BF_FATAL		2	/* one or more fatal errors found */
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate typedef struct bus_func_desc {
116*7c478bd9Sstevel@tonic-gate 	int bf_type;			/* type of function (see above) */
117*7c478bd9Sstevel@tonic-gate 	busfunc_t bf_func;		/* function to call */
118*7c478bd9Sstevel@tonic-gate 	void *bf_arg;			/* function argument */
119*7c478bd9Sstevel@tonic-gate 	struct bus_func_desc *bf_next;	/* pointer to next registered desc */
120*7c478bd9Sstevel@tonic-gate } bus_func_desc_t;
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate extern void bus_func_register(int, busfunc_t, void *);
123*7c478bd9Sstevel@tonic-gate extern void bus_func_unregister(int, busfunc_t, void *);
124*7c478bd9Sstevel@tonic-gate extern void bus_async_log_err(struct async_flt *);
125*7c478bd9Sstevel@tonic-gate extern uint_t bus_func_invoke(int);
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate extern void ecc_cpu_call(struct async_flt *, char *, int);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate extern void ce_scrub(struct async_flt *);
130*7c478bd9Sstevel@tonic-gate extern void ecc_page_zero(void *);
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate extern void error_init(void);
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate extern	int	ce_verbose_memory;
135*7c478bd9Sstevel@tonic-gate extern	int	ce_verbose_other;
136*7c478bd9Sstevel@tonic-gate extern	int	ce_show_data;
137*7c478bd9Sstevel@tonic-gate extern	int	ce_debug;
138*7c478bd9Sstevel@tonic-gate extern	int	ue_debug;
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate extern	int	aft_verbose;
141*7c478bd9Sstevel@tonic-gate extern	int	aft_panic;
142*7c478bd9Sstevel@tonic-gate extern	int	aft_testfatal;
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate extern struct async_flt panic_aflt;
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate extern errorq_t *ce_queue;
147*7c478bd9Sstevel@tonic-gate extern errorq_t *ue_queue;
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate  * ECC or parity error status for async_flt.flt_status.
153*7c478bd9Sstevel@tonic-gate  */
154*7c478bd9Sstevel@tonic-gate #define	ECC_C_TRAP		0x0001	/* Trap 0x63 Corrected ECC Error */
155*7c478bd9Sstevel@tonic-gate #define	ECC_I_TRAP		0x0002	/* Trap 0x0A Instr Access Error */
156*7c478bd9Sstevel@tonic-gate #define	ECC_ECACHE		0x0004	/* Ecache ECC Error */
157*7c478bd9Sstevel@tonic-gate #define	ECC_IOBUS		0x0008	/* Pci or sysio ECC Error */
158*7c478bd9Sstevel@tonic-gate #define	ECC_INTERMITTENT	0x0010	/* Intermittent ECC Error */
159*7c478bd9Sstevel@tonic-gate #define	ECC_PERSISTENT		0x0020	/* Persistent ECC Error */
160*7c478bd9Sstevel@tonic-gate #define	ECC_STICKY		0x0040	/* Sticky ECC Error */
161*7c478bd9Sstevel@tonic-gate #define	ECC_D_TRAP		0x0080	/* Trap 0x32 Data Access Error */
162*7c478bd9Sstevel@tonic-gate #define	ECC_F_TRAP		0x0100	/* Cheetah Trap 0x70 Fast ECC Error */
163*7c478bd9Sstevel@tonic-gate #define	ECC_DP_TRAP		0x0200	/* Cheetah+ Trap 0x71 D$ Parity Error */
164*7c478bd9Sstevel@tonic-gate #define	ECC_IP_TRAP		0x0400	/* Cheetah+ Trap 0x72 I$ Parity Error */
165*7c478bd9Sstevel@tonic-gate #define	ECC_ITLB_TRAP		0x0800	/* Panther ITLB Parity Error */
166*7c478bd9Sstevel@tonic-gate #define	ECC_DTLB_TRAP		0x1000	/* Panther DTLB Parity Error */
167*7c478bd9Sstevel@tonic-gate #define	ECC_IO_CE		0x2000	/* Pci or sysio CE */
168*7c478bd9Sstevel@tonic-gate #define	ECC_IO_UE		0x4000	/* Pci or sysio UE */
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate /*
171*7c478bd9Sstevel@tonic-gate  * Trap type numbers corresponding to the fault types defined above.
172*7c478bd9Sstevel@tonic-gate  */
173*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_I		0x0A
174*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_D		0x32
175*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_F		0x70
176*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_C		0x63
177*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_DP	0x71
178*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_IP	0x72
179*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_ITLB	0x08
180*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_ECC_DTLB	0x30
181*7c478bd9Sstevel@tonic-gate #define	TRAP_TYPE_UNKNOWN	0
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate /*
184*7c478bd9Sstevel@tonic-gate  * Fault classes for async_flt.flt_class.
185*7c478bd9Sstevel@tonic-gate  */
186*7c478bd9Sstevel@tonic-gate #define	BUS_FAULT		0	/* originating from bus drivers */
187*7c478bd9Sstevel@tonic-gate #define	CPU_FAULT		1	/* originating from CPUs */
188*7c478bd9Sstevel@tonic-gate #define	RECIRC_BUS_FAULT	2	/* scheduled diagnostic */
189*7c478bd9Sstevel@tonic-gate #define	RECIRC_CPU_FAULT	3	/* scheduled diagnostic */
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate /*
192*7c478bd9Sstevel@tonic-gate  * Invalid or unknown physical address for async_flt.flt_addr.
193*7c478bd9Sstevel@tonic-gate  */
194*7c478bd9Sstevel@tonic-gate #define	AFLT_INV_ADDR	(-1ULL)
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate /*
197*7c478bd9Sstevel@tonic-gate  * Fault protection values for async_flt.flt_prot.  The async error handling
198*7c478bd9Sstevel@tonic-gate  * code may be able to recover from errors when kernel code has explicitly
199*7c478bd9Sstevel@tonic-gate  * protected itself using one of the mechanisms specified here.
200*7c478bd9Sstevel@tonic-gate  */
201*7c478bd9Sstevel@tonic-gate #define	AFLT_PROT_NONE		0	/* no protection active */
202*7c478bd9Sstevel@tonic-gate #define	AFLT_PROT_ACCESS	1	/* on_trap OT_DATA_ACCESS protection */
203*7c478bd9Sstevel@tonic-gate #define	AFLT_PROT_EC		2	/* on_trap OT_DATA_EC protection */
204*7c478bd9Sstevel@tonic-gate #define	AFLT_PROT_COPY		3	/* t_lofault protection (ucopy, etc.) */
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate /*
207*7c478bd9Sstevel@tonic-gate  * These flags are used to indicate the validity of certain data based on
208*7c478bd9Sstevel@tonic-gate  * the various overwrite priority features of the AFSR/AFAR:
209*7c478bd9Sstevel@tonic-gate  * AFAR, ESYND and MSYND, each of which have different overwrite priorities.
210*7c478bd9Sstevel@tonic-gate  *
211*7c478bd9Sstevel@tonic-gate  * Given a specific afsr error bit and the entire afsr, there are three cases:
212*7c478bd9Sstevel@tonic-gate  *   INVALID:	The specified bit is lower overwrite priority than some other
213*7c478bd9Sstevel@tonic-gate  *		error bit which is on in the afsr (or IVU/IVC).
214*7c478bd9Sstevel@tonic-gate  *   VALID:	The specified bit is higher priority than all other error bits
215*7c478bd9Sstevel@tonic-gate  *		which are on in the afsr.
216*7c478bd9Sstevel@tonic-gate  *   AMBIGUOUS: Another error bit (or bits) of equal priority to the specified
217*7c478bd9Sstevel@tonic-gate  *		bit is on in the afsr.
218*7c478bd9Sstevel@tonic-gate  *
219*7c478bd9Sstevel@tonic-gate  * NB: The domain-to-SC communications depend on these values. If they are
220*7c478bd9Sstevel@tonic-gate  * changed, plat_ecc_unum.[ch] must be updated to match.
221*7c478bd9Sstevel@tonic-gate  */
222*7c478bd9Sstevel@tonic-gate #define	AFLT_STAT_INVALID	0	/* higher priority afsr bit is on */
223*7c478bd9Sstevel@tonic-gate #define	AFLT_STAT_VALID		1	/* this is highest priority afsr bit */
224*7c478bd9Sstevel@tonic-gate #define	AFLT_STAT_AMBIGUOUS	2	/* two afsr bits of equal priority */
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate /*
227*7c478bd9Sstevel@tonic-gate  * Maximum length of unum string.
228*7c478bd9Sstevel@tonic-gate  */
229*7c478bd9Sstevel@tonic-gate #define	UNUM_NAMLEN	60
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
232*7c478bd9Sstevel@tonic-gate }
233*7c478bd9Sstevel@tonic-gate #endif
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_ASYNC_H */
236