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