151 greg_t oldpc;
152 int mstate;
153 char *badaddr;
154 faultcode_t res;
155 enum fault_type fault_type;
156 enum seg_rw rw;
157 uintptr_t lofault;
158 label_t *onfault;
159 int instr;
160 int iskernel;
161 int watchcode;
162 int watchpage;
163 extern faultcode_t pagefault(caddr_t, enum fault_type,
164 enum seg_rw, int);
165 #ifdef sun4v
166 extern boolean_t tick_stick_emulation_active;
167 #endif /* sun4v */
168
169 CPU_STATS_ADDQ(CPU, sys, trap, 1);
170
171 #ifdef SF_ERRATA_23 /* call causes illegal-insn */
172 ASSERT((curthread->t_schedflag & TS_DONT_SWAP) ||
173 (type == T_UNIMP_INSTR));
174 #else
175 ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
176 #endif /* SF_ERRATA_23 */
177
178 if (USERMODE(rp->r_tstate) || (type & T_USER)) {
179 /*
180 * Set lwp_state before trying to acquire any
181 * adaptive lock
182 */
183 ASSERT(lwp != NULL);
184 lwp->lwp_state = LWP_SYS;
185 /*
186 * Set up the current cred to use during this trap. u_cred
187 * no longer exists. t_cred is used instead.
188 * The current process credential applies to the thread for
189 * the entire trap. If trapping from the kernel, this
190 * should already be set up.
191 */
192 if (curthread->t_cred != p->p_cred) {
193 cred_t *oldcred = curthread->t_cred;
194 /*
195 * DTrace accesses t_cred in probe context. t_cred
196 * must always be either NULL, or point to a valid,
197 * allocated cred structure.
1354 * Note that the T_UNIMP_INSTR case does not call simulate_unimp(),
1355 * because the simulator only simulates multiply and divide instructions,
1356 * which would not cause floating point traps in the first place.
1357 * XXX - Supervisor mode floating point traps?
1358 */
1359 void
1360 fpu_trap(struct regs *rp, caddr_t addr, uint32_t type, uint32_t code)
1361 {
1362 proc_t *p = ttoproc(curthread);
1363 klwp_id_t lwp = ttolwp(curthread);
1364 k_siginfo_t siginfo;
1365 uint_t op3, fault = 0;
1366 int mstate;
1367 char *badaddr;
1368 kfpu_t *fp;
1369 struct fpq *pfpq;
1370 uint32_t inst;
1371 utrap_handler_t *utrapp;
1372
1373 CPU_STATS_ADDQ(CPU, sys, trap, 1);
1374
1375 ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
1376
1377 if (USERMODE(rp->r_tstate)) {
1378 /*
1379 * Set lwp_state before trying to acquire any
1380 * adaptive lock
1381 */
1382 ASSERT(lwp != NULL);
1383 lwp->lwp_state = LWP_SYS;
1384 /*
1385 * Set up the current cred to use during this trap. u_cred
1386 * no longer exists. t_cred is used instead.
1387 * The current process credential applies to the thread for
1388 * the entire trap. If trapping from the kernel, this
1389 * should already be set up.
1390 */
1391 if (curthread->t_cred != p->p_cred) {
1392 cred_t *oldcred = curthread->t_cred;
1393 /*
1394 * DTrace accesses t_cred in probe context. t_cred
1395 * must always be either NULL, or point to a valid,
|
151 greg_t oldpc;
152 int mstate;
153 char *badaddr;
154 faultcode_t res;
155 enum fault_type fault_type;
156 enum seg_rw rw;
157 uintptr_t lofault;
158 label_t *onfault;
159 int instr;
160 int iskernel;
161 int watchcode;
162 int watchpage;
163 extern faultcode_t pagefault(caddr_t, enum fault_type,
164 enum seg_rw, int);
165 #ifdef sun4v
166 extern boolean_t tick_stick_emulation_active;
167 #endif /* sun4v */
168
169 CPU_STATS_ADDQ(CPU, sys, trap, 1);
170
171 if (USERMODE(rp->r_tstate) || (type & T_USER)) {
172 /*
173 * Set lwp_state before trying to acquire any
174 * adaptive lock
175 */
176 ASSERT(lwp != NULL);
177 lwp->lwp_state = LWP_SYS;
178 /*
179 * Set up the current cred to use during this trap. u_cred
180 * no longer exists. t_cred is used instead.
181 * The current process credential applies to the thread for
182 * the entire trap. If trapping from the kernel, this
183 * should already be set up.
184 */
185 if (curthread->t_cred != p->p_cred) {
186 cred_t *oldcred = curthread->t_cred;
187 /*
188 * DTrace accesses t_cred in probe context. t_cred
189 * must always be either NULL, or point to a valid,
190 * allocated cred structure.
1347 * Note that the T_UNIMP_INSTR case does not call simulate_unimp(),
1348 * because the simulator only simulates multiply and divide instructions,
1349 * which would not cause floating point traps in the first place.
1350 * XXX - Supervisor mode floating point traps?
1351 */
1352 void
1353 fpu_trap(struct regs *rp, caddr_t addr, uint32_t type, uint32_t code)
1354 {
1355 proc_t *p = ttoproc(curthread);
1356 klwp_id_t lwp = ttolwp(curthread);
1357 k_siginfo_t siginfo;
1358 uint_t op3, fault = 0;
1359 int mstate;
1360 char *badaddr;
1361 kfpu_t *fp;
1362 struct fpq *pfpq;
1363 uint32_t inst;
1364 utrap_handler_t *utrapp;
1365
1366 CPU_STATS_ADDQ(CPU, sys, trap, 1);
1367
1368 if (USERMODE(rp->r_tstate)) {
1369 /*
1370 * Set lwp_state before trying to acquire any
1371 * adaptive lock
1372 */
1373 ASSERT(lwp != NULL);
1374 lwp->lwp_state = LWP_SYS;
1375 /*
1376 * Set up the current cred to use during this trap. u_cred
1377 * no longer exists. t_cred is used instead.
1378 * The current process credential applies to the thread for
1379 * the entire trap. If trapping from the kernel, this
1380 * should already be set up.
1381 */
1382 if (curthread->t_cred != p->p_cred) {
1383 cred_t *oldcred = curthread->t_cred;
1384 /*
1385 * DTrace accesses t_cred in probe context. t_cred
1386 * must always be either NULL, or point to a valid,
|