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