xref: /illumos-gate/usr/src/uts/sun4v/sys/error.h (revision c65ebfc7045424bd04a6c7719a27b0ad3399ad54)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_ERROR_H
27 #define	_ERROR_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Resumable and Non-resumable queues
35  */
36 #define	CPU_RQ_ENTRIES		64
37 #define	MAX_CPU_RQ_ENTRIES	128
38 
39 #define	CPU_NRQ_ENTRIES		4
40 #define	MAX_CPU_NRQ_ENTRIES	4
41 
42 #define	Q_ENTRY_SIZE		64
43 
44 #define	CPU_RQ_SIZE		(CPU_RQ_ENTRIES * Q_ENTRY_SIZE)
45 #define	CPU_NRQ_SIZE		(CPU_NRQ_ENTRIES * Q_ENTRY_SIZE)
46 
47 /*
48  * Sun4v Error Report error Descriptor describes the type of the error
49  */
50 #define	ERRH_DESC_UNDEFINED	0	/* Undefined */
51 #define	ERRH_DESC_UCOR_RE	1	/* Uncorrected resumable error */
52 #define	ERRH_DESC_PR_NRE	2	/* Precise non-resumable error */
53 #define	ERRH_DESC_DEF_NRE	3	/* Deferred non-resumalbe error */
54 #define	ERRH_DESC_WARN_RE	4	/* Power-off for vBSC HostShutdown() */
55 #define	ERRH_DESC_USER_DCORE	5	/* User initiated panic */
56 #define	ERRH_DESC_SP		6	/* SP state change */
57 
58 /*
59  * Sun4v Error Report Error Attributes specifies the attributes of the error
60  */
61 #define	ERRH_ATTR_CPU		0x00000001
62 #define	ERRH_ATTR_MEM		0x00000002
63 #define	ERRH_ATTR_PIO		0x00000004
64 #define	ERRH_ATTR_IRF		0x00000008	/* Integer register file */
65 /* Floating-point register file */
66 #define	ERRH_ATTR_FRF		0x00000010
67 #define	ERRH_ATTR_SHUT		0x00000020	/* Shutdown request */
68 #define	ERRH_ATTR_ASR		0x00000040	/* Sun4v ASR */
69 #define	ERRH_ATTR_ASI		0x00000080	/* Sun4v ASI */
70 #define	ERRH_ATTR_PREG		0x00000100	/* Sun4v Privileged Register */
71 #define	ERRH_ATTR_RQF		0x80000000	/* Resumablee Queue Full */
72 
73 /*
74  * For Execution mode
75  */
76 #define	ERRH_MODE_MASK		0x03000000
77 #define	ERRH_MODE_SHIFT		24
78 #define	ERRH_MODE_UNKNOWN	0
79 #define	ERRH_MODE_USER		1
80 #define	ERRH_MODE_PRIV		2
81 
82 /*
83  * For SP (Service Processor) state change
84  */
85 #define	ERRH_SP_MASK		0x00000600
86 #define	ERRH_SP_SHIFT		9
87 #define	ERRH_SP_FAULTED		0	/* Physically present but faulted SP */
88 #define	ERRH_SP_AVAILABLE	1
89 #define	ERRH_SP_NOT_PRESENT	2	/* SP is not physically present */
90 
91 /*
92  * ASR register number
93  */
94 #define	ASR_REG_VALID		0x8000	/* Valid bit for register field */
95 #define	ASR_REG_TICK		0x17	/* Tick Compare Register */
96 
97 /*
98  * For the second argument passed to process_nonresumable_error(), it is
99  * an uint64_t. The upper 32 bits are reserved for various flags, the
100  * lower 32 bits are used to pass the "current tl-1". Right now only bit
101  * 32 in the upper 32 bits is being used as user's fill/spill flag.
102  * If bit 32 is set, it means the first error in the error
103  * queue happened in user fill/spill trap and it needs to be handled
104  * differently.
105  *
106  * -Argument 2 of process_nonresumable_error()
107  *    ----------------------------------------------
108  *    |  reserved        |x|  current_tl - 1       |
109  *    ----------------------------------------------
110  *    63                 32 31                     0
111  * x - bit 32, user fill/spill trap flag
112  */
113 #define	ERRH_U_SPILL_FILL		0x100000000
114 #define	ERRH_U_SPILL_FILL_SHIFT		32
115 #define	ERRH_TL_MASK			0xffffffff
116 
117 #ifndef	_ASM
118 /*
119  * For debug print out
120  */
121 #define	ER_SZ_IN_EXT_WORD	(Q_ENTRY_SIZE / sizeof (uint64_t))
122 
123 /*
124  * Sun4v Error Report record
125  */
126 typedef	struct {
127 	uint64_t	ehdl;		/* Unique error handle */
128 	uint64_t	stick;		/* Value of the %STICK register */
129 	uint32_t	desc;		/* Error Descriptor */
130 	uint32_t	attr;		/* error attributes bit field */
131 	uint64_t	ra;		/* Real address */
132 	uint32_t	sz;		/* Size of affected mem region */
133 	uint16_t	cpuid;		/* Virtual ID of the affected CPU */
134 	uint16_t	secs;		/* Seconds */
135 	uint8_t		asi;		/* ASI */
136 	uint8_t		rsvd;		/* Padding for ASI */
137 	uint16_t	reg;		/* Value of the ASR register number */
138 } errh_er_t;
139 
140 typedef struct errh_async_flt {
141 	struct async_flt 	cmn_asyncflt;	/* common fault structure */
142 	errh_er_t		errh_er;	/* sun4v er record */
143 } errh_async_flt_t;
144 
145 /*
146  * Global functions
147  */
148 void mem_scrub(uint64_t, uint64_t);
149 void errh_cpu_run_bus_error_handlers(struct async_flt *, int);
150 void error_init(void);
151 void cpu_async_log_err(void *);
152 void cpu_ce_log_err(struct async_flt *);
153 void cpu_ue_log_err(struct async_flt *);
154 uint64_t mem_sync(caddr_t, size_t);
155 
156 #endif	/* _ASM */
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* _ERROR_H */
163