trap.c revision 266019
1/*-
2 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
3 * Copyright (C) 1995, 1996 TooLs GmbH.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 *    must display the following acknowledgement:
16 *	This product includes software developed by TooLs GmbH.
17 * 4. The name of TooLs GmbH may not be used to endorse or promote products
18 *    derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * $NetBSD: trap.c,v 1.58 2002/03/04 04:07:35 dbj Exp $
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: stable/10/sys/powerpc/aim/trap.c 266019 2014-05-14 14:08:45Z ian $");
36
37#include "opt_kdtrace.h"
38
39#include <sys/param.h>
40#include <sys/kdb.h>
41#include <sys/proc.h>
42#include <sys/ktr.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/pioctl.h>
46#include <sys/ptrace.h>
47#include <sys/reboot.h>
48#include <sys/syscall.h>
49#include <sys/sysent.h>
50#include <sys/systm.h>
51#include <sys/uio.h>
52#include <sys/signalvar.h>
53#include <sys/vmmeter.h>
54
55#include <security/audit/audit.h>
56
57#include <vm/vm.h>
58#include <vm/pmap.h>
59#include <vm/vm_extern.h>
60#include <vm/vm_param.h>
61#include <vm/vm_kern.h>
62#include <vm/vm_map.h>
63#include <vm/vm_page.h>
64
65#include <machine/_inttypes.h>
66#include <machine/altivec.h>
67#include <machine/cpu.h>
68#include <machine/db_machdep.h>
69#include <machine/fpu.h>
70#include <machine/frame.h>
71#include <machine/pcb.h>
72#include <machine/pmap.h>
73#include <machine/psl.h>
74#include <machine/trap.h>
75#include <machine/spr.h>
76#include <machine/sr.h>
77
78static void	trap_fatal(struct trapframe *frame);
79static void	printtrap(u_int vector, struct trapframe *frame, int isfatal,
80		    int user);
81static int	trap_pfault(struct trapframe *frame, int user);
82static int	fix_unaligned(struct thread *td, struct trapframe *frame);
83static int	handle_onfault(struct trapframe *frame);
84static void	syscall(struct trapframe *frame);
85
86#ifdef __powerpc64__
87       void	handle_kernel_slb_spill(int, register_t, register_t);
88static int	handle_user_slb_spill(pmap_t pm, vm_offset_t addr);
89extern int	n_slbs;
90#endif
91
92struct powerpc_exception {
93	u_int	vector;
94	char	*name;
95};
96
97#ifdef KDTRACE_HOOKS
98#include <sys/dtrace_bsd.h>
99
100/*
101 * This is a hook which is initialised by the dtrace module
102 * to handle traps which might occur during DTrace probe
103 * execution.
104 */
105dtrace_trap_func_t	dtrace_trap_func;
106
107dtrace_doubletrap_func_t	dtrace_doubletrap_func;
108
109/*
110 * This is a hook which is initialised by the systrace module
111 * when it is loaded. This keeps the DTrace syscall provider
112 * implementation opaque.
113 */
114systrace_probe_func_t	systrace_probe_func;
115
116/*
117 * These hooks are necessary for the pid and usdt providers.
118 */
119dtrace_pid_probe_ptr_t		dtrace_pid_probe_ptr;
120dtrace_return_probe_ptr_t	dtrace_return_probe_ptr;
121int (*dtrace_invop_jump_addr)(struct trapframe *);
122#endif
123
124static struct powerpc_exception powerpc_exceptions[] = {
125	{ 0x0100, "system reset" },
126	{ 0x0200, "machine check" },
127	{ 0x0300, "data storage interrupt" },
128	{ 0x0380, "data segment exception" },
129	{ 0x0400, "instruction storage interrupt" },
130	{ 0x0480, "instruction segment exception" },
131	{ 0x0500, "external interrupt" },
132	{ 0x0600, "alignment" },
133	{ 0x0700, "program" },
134	{ 0x0800, "floating-point unavailable" },
135	{ 0x0900, "decrementer" },
136	{ 0x0c00, "system call" },
137	{ 0x0d00, "trace" },
138	{ 0x0e00, "floating-point assist" },
139	{ 0x0f00, "performance monitoring" },
140	{ 0x0f20, "altivec unavailable" },
141	{ 0x1000, "instruction tlb miss" },
142	{ 0x1100, "data load tlb miss" },
143	{ 0x1200, "data store tlb miss" },
144	{ 0x1300, "instruction breakpoint" },
145	{ 0x1400, "system management" },
146	{ 0x1600, "altivec assist" },
147	{ 0x1700, "thermal management" },
148	{ 0x2000, "run mode/trace" },
149	{ 0x3000, NULL }
150};
151
152static const char *
153trapname(u_int vector)
154{
155	struct	powerpc_exception *pe;
156
157	for (pe = powerpc_exceptions; pe->vector != 0x3000; pe++) {
158		if (pe->vector == vector)
159			return (pe->name);
160	}
161
162	return ("unknown");
163}
164
165void
166trap(struct trapframe *frame)
167{
168	struct thread	*td;
169	struct proc	*p;
170#ifdef KDTRACE_HOOKS
171	uint32_t inst;
172#endif
173	int		sig, type, user;
174	u_int		ucode;
175	ksiginfo_t	ksi;
176
177	PCPU_INC(cnt.v_trap);
178
179	td = curthread;
180	p = td->td_proc;
181
182	type = ucode = frame->exc;
183	sig = 0;
184	user = frame->srr1 & PSL_PR;
185
186	CTR3(KTR_TRAP, "trap: %s type=%s (%s)", td->td_name,
187	    trapname(type), user ? "user" : "kernel");
188
189#ifdef KDTRACE_HOOKS
190	/*
191	 * A trap can occur while DTrace executes a probe. Before
192	 * executing the probe, DTrace blocks re-scheduling and sets
193	 * a flag in it's per-cpu flags to indicate that it doesn't
194	 * want to fault. On returning from the probe, the no-fault
195	 * flag is cleared and finally re-scheduling is enabled.
196	 *
197	 * If the DTrace kernel module has registered a trap handler,
198	 * call it and if it returns non-zero, assume that it has
199	 * handled the trap and modified the trap frame so that this
200	 * function can return normally.
201	 */
202	/*
203	 * XXXDTRACE: add pid probe handler here (if ever)
204	 */
205	if (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame, type))
206		return;
207#endif
208
209	if (user) {
210		td->td_pticks = 0;
211		td->td_frame = frame;
212		if (td->td_ucred != p->p_ucred)
213			cred_update_thread(td);
214
215		/* User Mode Traps */
216		switch (type) {
217		case EXC_RUNMODETRC:
218		case EXC_TRC:
219			frame->srr1 &= ~PSL_SE;
220			sig = SIGTRAP;
221			break;
222
223#ifdef __powerpc64__
224		case EXC_ISE:
225		case EXC_DSE:
226			if (handle_user_slb_spill(&p->p_vmspace->vm_pmap,
227			    (type == EXC_ISE) ? frame->srr0 :
228			    frame->cpu.aim.dar) != 0)
229				sig = SIGSEGV;
230			break;
231#endif
232		case EXC_DSI:
233		case EXC_ISI:
234			sig = trap_pfault(frame, 1);
235			break;
236
237		case EXC_SC:
238			syscall(frame);
239			break;
240
241		case EXC_FPU:
242			KASSERT((td->td_pcb->pcb_flags & PCB_FPU) != PCB_FPU,
243			    ("FPU already enabled for thread"));
244			enable_fpu(td);
245			break;
246
247		case EXC_VEC:
248			KASSERT((td->td_pcb->pcb_flags & PCB_VEC) != PCB_VEC,
249			    ("Altivec already enabled for thread"));
250			enable_vec(td);
251			break;
252
253		case EXC_VECAST_G4:
254		case EXC_VECAST_G5:
255			/*
256			 * We get a VPU assist exception for IEEE mode
257			 * vector operations on denormalized floats.
258			 * Emulating this is a giant pain, so for now,
259			 * just switch off IEEE mode and treat them as
260			 * zero.
261			 */
262
263			save_vec(td);
264			td->td_pcb->pcb_vec.vscr |= ALTIVEC_VSCR_NJ;
265			enable_vec(td);
266			break;
267
268		case EXC_ALI:
269			if (fix_unaligned(td, frame) != 0)
270				sig = SIGBUS;
271			else
272				frame->srr0 += 4;
273			break;
274
275		case EXC_PGM:
276			/* Identify the trap reason */
277			if (frame->srr1 & EXC_PGM_TRAP) {
278#ifdef KDTRACE_HOOKS
279				inst = fuword32((const void *)frame->srr0);
280				if (inst == 0x0FFFDDDD && dtrace_pid_probe_ptr != NULL) {
281					struct reg regs;
282					fill_regs(td, &regs);
283					(*dtrace_pid_probe_ptr)(&regs);
284					break;
285				}
286#endif
287 				sig = SIGTRAP;
288			} else {
289				sig = ppc_instr_emulate(frame, td->td_pcb);
290			}
291			break;
292
293		default:
294			trap_fatal(frame);
295		}
296	} else {
297		/* Kernel Mode Traps */
298
299		KASSERT(cold || td->td_ucred != NULL,
300		    ("kernel trap doesn't have ucred"));
301		switch (type) {
302#ifdef KDTRACE_HOOKS
303		case EXC_PGM:
304			if (frame->srr1 & EXC_PGM_TRAP) {
305				if (*(uint32_t *)frame->srr0 == 0x7c810808) {
306					if (dtrace_invop_jump_addr != NULL) {
307						dtrace_invop_jump_addr(frame);
308						return;
309					}
310				}
311			}
312			break;
313#endif
314#ifdef __powerpc64__
315		case EXC_DSE:
316			if ((frame->cpu.aim.dar & SEGMENT_MASK) == USER_ADDR) {
317				__asm __volatile ("slbmte %0, %1" ::
318					"r"(td->td_pcb->pcb_cpu.aim.usr_vsid),
319					"r"(USER_SLB_SLBE));
320				return;
321			}
322			break;
323#endif
324		case EXC_DSI:
325			if (trap_pfault(frame, 0) == 0)
326 				return;
327			break;
328		case EXC_MCHK:
329			if (handle_onfault(frame))
330 				return;
331			break;
332		default:
333			break;
334		}
335		trap_fatal(frame);
336	}
337
338	if (sig != 0) {
339		if (p->p_sysent->sv_transtrap != NULL)
340			sig = (p->p_sysent->sv_transtrap)(sig, type);
341		ksiginfo_init_trap(&ksi);
342		ksi.ksi_signo = sig;
343		ksi.ksi_code = (int) ucode; /* XXX, not POSIX */
344		/* ksi.ksi_addr = ? */
345		ksi.ksi_trapno = type;
346		trapsignal(td, &ksi);
347	}
348
349	userret(td, frame);
350}
351
352static void
353trap_fatal(struct trapframe *frame)
354{
355
356	printtrap(frame->exc, frame, 1, (frame->srr1 & PSL_PR));
357#ifdef KDB
358	if ((debugger_on_panic || kdb_active) &&
359	    kdb_trap(frame->exc, 0, frame))
360		return;
361#endif
362	panic("%s trap", trapname(frame->exc));
363}
364
365static void
366printtrap(u_int vector, struct trapframe *frame, int isfatal, int user)
367{
368
369	printf("\n");
370	printf("%s %s trap:\n", isfatal ? "fatal" : "handled",
371	    user ? "user" : "kernel");
372	printf("\n");
373	printf("   exception       = 0x%x (%s)\n", vector, trapname(vector));
374	switch (vector) {
375	case EXC_DSE:
376	case EXC_DSI:
377		printf("   virtual address = 0x%" PRIxPTR "\n",
378		    frame->cpu.aim.dar);
379		printf("   dsisr           = 0x%" PRIxPTR "\n",
380		    frame->cpu.aim.dsisr);
381		break;
382	case EXC_ISE:
383	case EXC_ISI:
384		printf("   virtual address = 0x%" PRIxPTR "\n", frame->srr0);
385		break;
386	}
387	printf("   srr0            = 0x%" PRIxPTR "\n", frame->srr0);
388	printf("   srr1            = 0x%" PRIxPTR "\n", frame->srr1);
389	printf("   lr              = 0x%" PRIxPTR "\n", frame->lr);
390	printf("   curthread       = %p\n", curthread);
391	if (curthread != NULL)
392		printf("          pid = %d, comm = %s\n",
393		    curthread->td_proc->p_pid, curthread->td_name);
394	printf("\n");
395}
396
397/*
398 * Handles a fatal fault when we have onfault state to recover.  Returns
399 * non-zero if there was onfault recovery state available.
400 */
401static int
402handle_onfault(struct trapframe *frame)
403{
404	struct		thread *td;
405	faultbuf	*fb;
406
407	td = curthread;
408	fb = td->td_pcb->pcb_onfault;
409	if (fb != NULL) {
410		frame->srr0 = (*fb)[0];
411		frame->fixreg[1] = (*fb)[1];
412		frame->fixreg[2] = (*fb)[2];
413		frame->fixreg[3] = 1;
414		frame->cr = (*fb)[3];
415		bcopy(&(*fb)[4], &frame->fixreg[13],
416		    19 * sizeof(register_t));
417		return (1);
418	}
419	return (0);
420}
421
422int
423cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
424{
425	struct proc *p;
426	struct trapframe *frame;
427	caddr_t	params;
428	size_t argsz;
429	int error, n, i;
430
431	p = td->td_proc;
432	frame = td->td_frame;
433
434	sa->code = frame->fixreg[0];
435	params = (caddr_t)(frame->fixreg + FIRSTARG);
436	n = NARGREG;
437
438	if (sa->code == SYS_syscall) {
439		/*
440		 * code is first argument,
441		 * followed by actual args.
442		 */
443		sa->code = *(register_t *) params;
444		params += sizeof(register_t);
445		n -= 1;
446	} else if (sa->code == SYS___syscall) {
447		/*
448		 * Like syscall, but code is a quad,
449		 * so as to maintain quad alignment
450		 * for the rest of the args.
451		 */
452		if (SV_PROC_FLAG(p, SV_ILP32)) {
453			params += sizeof(register_t);
454			sa->code = *(register_t *) params;
455			params += sizeof(register_t);
456			n -= 2;
457		} else {
458			sa->code = *(register_t *) params;
459			params += sizeof(register_t);
460			n -= 1;
461		}
462	}
463
464 	if (p->p_sysent->sv_mask)
465		sa->code &= p->p_sysent->sv_mask;
466	if (sa->code >= p->p_sysent->sv_size)
467		sa->callp = &p->p_sysent->sv_table[0];
468	else
469		sa->callp = &p->p_sysent->sv_table[sa->code];
470
471	sa->narg = sa->callp->sy_narg;
472
473	if (SV_PROC_FLAG(p, SV_ILP32)) {
474		argsz = sizeof(uint32_t);
475
476		for (i = 0; i < n; i++)
477			sa->args[i] = ((u_register_t *)(params))[i] &
478			    0xffffffff;
479	} else {
480		argsz = sizeof(uint64_t);
481
482		for (i = 0; i < n; i++)
483			sa->args[i] = ((u_register_t *)(params))[i];
484	}
485
486	if (sa->narg > n)
487		error = copyin(MOREARGS(frame->fixreg[1]), sa->args + n,
488			       (sa->narg - n) * argsz);
489	else
490		error = 0;
491
492#ifdef __powerpc64__
493	if (SV_PROC_FLAG(p, SV_ILP32) && sa->narg > n) {
494		/* Expand the size of arguments copied from the stack */
495
496		for (i = sa->narg; i >= n; i--)
497			sa->args[i] = ((uint32_t *)(&sa->args[n]))[i-n];
498	}
499#endif
500
501	if (error == 0) {
502		td->td_retval[0] = 0;
503		td->td_retval[1] = frame->fixreg[FIRSTARG + 1];
504	}
505	return (error);
506}
507
508#include "../../kern/subr_syscall.c"
509
510void
511syscall(struct trapframe *frame)
512{
513	struct thread *td;
514	struct syscall_args sa;
515	int error;
516
517	td = curthread;
518	td->td_frame = frame;
519
520#ifdef __powerpc64__
521	/*
522	 * Speculatively restore last user SLB segment, which we know is
523	 * invalid already, since we are likely to do copyin()/copyout().
524	 */
525	__asm __volatile ("slbmte %0, %1; isync" ::
526            "r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
527#endif
528
529	error = syscallenter(td, &sa);
530	syscallret(td, error, &sa);
531}
532
533#ifdef __powerpc64__
534/* Handle kernel SLB faults -- runs in real mode, all seat belts off */
535void
536handle_kernel_slb_spill(int type, register_t dar, register_t srr0)
537{
538	struct slb *slbcache;
539	uint64_t slbe, slbv;
540	uint64_t esid, addr;
541	int i;
542
543	addr = (type == EXC_ISE) ? srr0 : dar;
544	slbcache = PCPU_GET(slb);
545	esid = (uintptr_t)addr >> ADDR_SR_SHFT;
546	slbe = (esid << SLBE_ESID_SHIFT) | SLBE_VALID;
547
548	/* See if the hardware flushed this somehow (can happen in LPARs) */
549	for (i = 0; i < n_slbs; i++)
550		if (slbcache[i].slbe == (slbe | (uint64_t)i))
551			return;
552
553	/* Not in the map, needs to actually be added */
554	slbv = kernel_va_to_slbv(addr);
555	if (slbcache[USER_SLB_SLOT].slbe == 0) {
556		for (i = 0; i < n_slbs; i++) {
557			if (i == USER_SLB_SLOT)
558				continue;
559			if (!(slbcache[i].slbe & SLBE_VALID))
560				goto fillkernslb;
561		}
562
563		if (i == n_slbs)
564			slbcache[USER_SLB_SLOT].slbe = 1;
565	}
566
567	/* Sacrifice a random SLB entry that is not the user entry */
568	i = mftb() % n_slbs;
569	if (i == USER_SLB_SLOT)
570		i = (i+1) % n_slbs;
571
572fillkernslb:
573	/* Write new entry */
574	slbcache[i].slbv = slbv;
575	slbcache[i].slbe = slbe | (uint64_t)i;
576
577	/* Trap handler will restore from cache on exit */
578}
579
580static int
581handle_user_slb_spill(pmap_t pm, vm_offset_t addr)
582{
583	struct slb *user_entry;
584	uint64_t esid;
585	int i;
586
587	esid = (uintptr_t)addr >> ADDR_SR_SHFT;
588
589	PMAP_LOCK(pm);
590	user_entry = user_va_to_slb_entry(pm, addr);
591
592	if (user_entry == NULL) {
593		/* allocate_vsid auto-spills it */
594		(void)allocate_user_vsid(pm, esid, 0);
595	} else {
596		/*
597		 * Check that another CPU has not already mapped this.
598		 * XXX: Per-thread SLB caches would be better.
599		 */
600		for (i = 0; i < pm->pm_slb_len; i++)
601			if (pm->pm_slb[i] == user_entry)
602				break;
603
604		if (i == pm->pm_slb_len)
605			slb_insert_user(pm, user_entry);
606	}
607	PMAP_UNLOCK(pm);
608
609	return (0);
610}
611#endif
612
613static int
614trap_pfault(struct trapframe *frame, int user)
615{
616	vm_offset_t	eva, va;
617	struct		thread *td;
618	struct		proc *p;
619	vm_map_t	map;
620	vm_prot_t	ftype;
621	int		rv;
622	register_t	user_sr;
623
624	td = curthread;
625	p = td->td_proc;
626	if (frame->exc == EXC_ISI) {
627		eva = frame->srr0;
628		ftype = VM_PROT_EXECUTE;
629		if (frame->srr1 & SRR1_ISI_PFAULT)
630			ftype |= VM_PROT_READ;
631	} else {
632		eva = frame->cpu.aim.dar;
633		if (frame->cpu.aim.dsisr & DSISR_STORE)
634			ftype = VM_PROT_WRITE;
635		else
636			ftype = VM_PROT_READ;
637	}
638
639	if (user) {
640		map = &p->p_vmspace->vm_map;
641	} else {
642		if ((eva >> ADDR_SR_SHFT) == (USER_ADDR >> ADDR_SR_SHFT)) {
643			if (p->p_vmspace == NULL)
644				return (SIGSEGV);
645
646			map = &p->p_vmspace->vm_map;
647
648			user_sr = td->td_pcb->pcb_cpu.aim.usr_segm;
649			eva &= ADDR_PIDX | ADDR_POFF;
650			eva |= user_sr << ADDR_SR_SHFT;
651		} else {
652			map = kernel_map;
653		}
654	}
655	va = trunc_page(eva);
656
657	if (map != kernel_map) {
658		/*
659		 * Keep swapout from messing with us during this
660		 *	critical time.
661		 */
662		PROC_LOCK(p);
663		++p->p_lock;
664		PROC_UNLOCK(p);
665
666		/* Fault in the user page: */
667		rv = vm_fault(map, va, ftype, VM_FAULT_NORMAL);
668
669		PROC_LOCK(p);
670		--p->p_lock;
671		PROC_UNLOCK(p);
672		/*
673		 * XXXDTRACE: add dtrace_doubletrap_func here?
674		 */
675	} else {
676		/*
677		 * Don't have to worry about process locking or stacks in the
678		 * kernel.
679		 */
680		rv = vm_fault(map, va, ftype, VM_FAULT_NORMAL);
681	}
682
683	if (rv == KERN_SUCCESS)
684		return (0);
685
686	if (!user && handle_onfault(frame))
687		return (0);
688
689	return (SIGSEGV);
690}
691
692/*
693 * For now, this only deals with the particular unaligned access case
694 * that gcc tends to generate.  Eventually it should handle all of the
695 * possibilities that can happen on a 32-bit PowerPC in big-endian mode.
696 */
697
698static int
699fix_unaligned(struct thread *td, struct trapframe *frame)
700{
701	struct thread	*fputhread;
702	int		indicator, reg;
703	double		*fpr;
704
705	indicator = EXC_ALI_OPCODE_INDICATOR(frame->cpu.aim.dsisr);
706
707	switch (indicator) {
708	case EXC_ALI_LFD:
709	case EXC_ALI_STFD:
710		reg = EXC_ALI_RST(frame->cpu.aim.dsisr);
711		fpr = &td->td_pcb->pcb_fpu.fpr[reg];
712		fputhread = PCPU_GET(fputhread);
713
714		/* Juggle the FPU to ensure that we've initialized
715		 * the FPRs, and that their current state is in
716		 * the PCB.
717		 */
718		if (fputhread != td) {
719			if (fputhread)
720				save_fpu(fputhread);
721			enable_fpu(td);
722		}
723		save_fpu(td);
724
725		if (indicator == EXC_ALI_LFD) {
726			if (copyin((void *)frame->cpu.aim.dar, fpr,
727			    sizeof(double)) != 0)
728				return -1;
729			enable_fpu(td);
730		} else {
731			if (copyout(fpr, (void *)frame->cpu.aim.dar,
732			    sizeof(double)) != 0)
733				return -1;
734		}
735		return 0;
736		break;
737	}
738
739	return -1;
740}
741
742