summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-05-14 04:57:55 +0000
committerian <ian@FreeBSD.org>2014-05-14 04:57:55 +0000
commit4a602a895785693d5def6282dbd784066341e805 (patch)
tree93e1dc02422784a7958c97bfd024009d3b8817ff /sys/powerpc
parent9277bb1a2b74a398eb2fd572785d2d6db451d8c1 (diff)
downloadFreeBSD-src-4a602a895785693d5def6282dbd784066341e805.zip
FreeBSD-src-4a602a895785693d5def6282dbd784066341e805.tar.gz
MFC r258259, r258798, r259010
Unify handling of illegal instruction faults between AIM and Book-E. Make uart_cpu_powerpc work on both FDT and OFW systems. Fix debug printfs in FPU_EMU to compile on powerpc64 and enable it for powerpc64.
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/aim/trap.c25
-rw-r--r--sys/powerpc/booke/trap.c17
-rw-r--r--sys/powerpc/fpu/fpu_emu.c21
-rw-r--r--sys/powerpc/include/trap.h2
-rw-r--r--sys/powerpc/powerpc/exec_machdep.c38
5 files changed, 57 insertions, 46 deletions
diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c
index d234ba2..025b5cf 100644
--- a/sys/powerpc/aim/trap.c
+++ b/sys/powerpc/aim/trap.c
@@ -80,7 +80,6 @@ static void printtrap(u_int vector, struct trapframe *frame, int isfatal,
int user);
static int trap_pfault(struct trapframe *frame, int user);
static int fix_unaligned(struct thread *td, struct trapframe *frame);
-static int ppc_instr_emulate(struct trapframe *frame);
static int handle_onfault(struct trapframe *frame);
static void syscall(struct trapframe *frame);
@@ -292,10 +291,9 @@ trap(struct trapframe *frame)
}
#endif
sig = SIGTRAP;
- } else if (ppc_instr_emulate(frame) == 0)
- frame->srr0 += 4;
- else
- sig = SIGILL;
+ } else {
+ sig = ppc_instr_emulate(frame, td->td_pcb);
+ }
break;
default:
@@ -800,20 +798,3 @@ fix_unaligned(struct thread *td, struct trapframe *frame)
return -1;
}
-static int
-ppc_instr_emulate(struct trapframe *frame)
-{
- uint32_t instr;
- int reg;
-
- instr = fuword32((void *)frame->srr0);
-
- if ((instr & 0xfc1fffff) == 0x7c1f42a6) { /* mfpvr */
- reg = (instr & ~0xfc1fffff) >> 21;
- frame->fixreg[reg] = mfpvr();
- return (0);
- }
-
- return (-1);
-}
-
diff --git a/sys/powerpc/booke/trap.c b/sys/powerpc/booke/trap.c
index 72c4f47..dc84ede 100644
--- a/sys/powerpc/booke/trap.c
+++ b/sys/powerpc/booke/trap.c
@@ -71,10 +71,6 @@ __FBSDID("$FreeBSD$");
#include <machine/trap.h>
#include <machine/spr.h>
-#ifdef FPU_EMU
-#include <powerpc/fpu/fpu_extern.h>
-#endif
-
#define FAULTBUF_LR 0
#define FAULTBUF_R1 1
#define FAULTBUF_R2 2
@@ -193,18 +189,7 @@ trap(struct trapframe *frame)
break;
case EXC_PGM: /* Program exception */
-#ifdef FPU_EMU
- if (!(td->td_pcb->pcb_flags & PCB_FPREGS)) {
- bzero(&td->td_pcb->pcb_fpu,
- sizeof(td->td_pcb->pcb_fpu));
- td->td_pcb->pcb_flags |= PCB_FPREGS;
- }
- sig = fpu_emulate(frame,
- (struct fpreg *)&td->td_pcb->pcb_fpu);
-#else
- /* XXX SIGILL for non-trap instructions. */
- sig = SIGTRAP;
-#endif
+ sig = ppc_instr_emulate(frame, td->td_pcb);
break;
default:
diff --git a/sys/powerpc/fpu/fpu_emu.c b/sys/powerpc/fpu/fpu_emu.c
index 33c1f74..610c0ea 100644
--- a/sys/powerpc/fpu/fpu_emu.c
+++ b/sys/powerpc/fpu/fpu_emu.c
@@ -326,8 +326,10 @@ fpu_execute(struct trapframe *tf, struct fpemu *fe, union instr *insn)
/* Store as integer */
ra = instr.i_x.i_ra;
rb = instr.i_x.i_rb;
- DPRINTF(FPE_INSN, ("reg %d has %x reg %d has %x\n",
- ra, tf->fixreg[ra], rb, tf->fixreg[rb]));
+ DPRINTF(FPE_INSN,
+ ("reg %d has %jx reg %d has %jx\n",
+ ra, (uintmax_t)tf->fixreg[ra], rb,
+ (uintmax_t)tf->fixreg[rb]));
addr = tf->fixreg[rb];
if (ra != 0)
@@ -356,8 +358,9 @@ fpu_execute(struct trapframe *tf, struct fpemu *fe, union instr *insn)
/* calculate EA of load/store */
ra = instr.i_x.i_ra;
rb = instr.i_x.i_rb;
- DPRINTF(FPE_INSN, ("reg %d has %x reg %d has %x\n",
- ra, tf->fixreg[ra], rb, tf->fixreg[rb]));
+ DPRINTF(FPE_INSN, ("reg %d has %jx reg %d has %jx\n",
+ ra, (uintmax_t)tf->fixreg[ra], rb,
+ (uintmax_t)tf->fixreg[rb]));
addr = tf->fixreg[rb];
if (ra != 0)
addr += tf->fixreg[ra];
@@ -373,8 +376,9 @@ fpu_execute(struct trapframe *tf, struct fpemu *fe, union instr *insn)
/* calculate EA of load/store */
ra = instr.i_d.i_ra;
addr = instr.i_d.i_d;
- DPRINTF(FPE_INSN, ("reg %d has %x displ %x\n",
- ra, tf->fixreg[ra], addr));
+ DPRINTF(FPE_INSN, ("reg %d has %jx displ %jx\n",
+ ra, (uintmax_t)tf->fixreg[ra],
+ (uintmax_t)addr));
if (ra != 0)
addr += tf->fixreg[ra];
rt = instr.i_d.i_rt;
@@ -420,7 +424,7 @@ fpu_execute(struct trapframe *tf, struct fpemu *fe, union instr *insn)
return (0);
#ifdef notyet
} else if (instr.i_any.i_opcd == OPC_load_st_62) {
- /* These are 64-bit extenstions */
+ /* These are 64-bit extensions */
return (NOTFPU);
#endif
} else if (instr.i_any.i_opcd == OPC_sp_fp_59 ||
@@ -784,7 +788,8 @@ fpu_execute(struct trapframe *tf, struct fpemu *fe, union instr *insn)
/* Move fpu condition codes to cr[1] */
tf->cr &= ~(0xf0000000>>bf);
tf->cr |= (cond>>bf);
- DPRINTF(FPE_INSN, ("fpu_execute: cr[%d] (cr=%x) <= %x\n", bf/4, tf->cr, cond));
+ DPRINTF(FPE_INSN, ("fpu_execute: cr[%d] (cr=%jx) <= %x\n",
+ bf/4, (uintmax_t)tf->cr, cond));
}
((int *)&fs->fpscr)[1] = fsr;
diff --git a/sys/powerpc/include/trap.h b/sys/powerpc/include/trap.h
index d8462cf..89f5966 100644
--- a/sys/powerpc/include/trap.h
+++ b/sys/powerpc/include/trap.h
@@ -122,7 +122,9 @@
#ifndef LOCORE
struct trapframe;
+struct pcb;
void trap(struct trapframe *);
+int ppc_instr_emulate(struct trapframe *, struct pcb *);
#endif
#endif /* _POWERPC_TRAP_H_ */
diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 4b4be6c..acacb3d 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -58,6 +58,7 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
+#include "opt_fpu_emu.h"
#include <sys/param.h>
#include <sys/proc.h>
@@ -92,6 +93,10 @@ __FBSDID("$FreeBSD$");
#include <machine/trap.h>
#include <machine/vmparam.h>
+#ifdef FPU_EMU
+#include <powerpc/fpu/fpu_extern.h>
+#endif
+
#ifdef COMPAT_FREEBSD32
#include <compat/freebsd32/freebsd32_signal.h>
#include <compat/freebsd32/freebsd32_util.h>
@@ -1038,3 +1043,36 @@ cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
td->td_retval[1] = 0;
}
+int
+ppc_instr_emulate(struct trapframe *frame, struct pcb *pcb)
+{
+ uint32_t instr;
+ int reg, sig;
+
+ instr = fuword32((void *)frame->srr0);
+ sig = SIGILL;
+
+ if ((instr & 0xfc1fffff) == 0x7c1f42a6) { /* mfpvr */
+ reg = (instr & ~0xfc1fffff) >> 21;
+ frame->fixreg[reg] = mfpvr();
+ frame->srr0 += 4;
+ return (0);
+ }
+
+ if ((instr & 0xfc000ffe) == 0x7c0004ac) { /* various sync */
+ powerpc_sync(); /* Do a heavy-weight sync */
+ frame->srr0 += 4;
+ return (0);
+ }
+
+#ifdef FPU_EMU
+ if (!(pcb->pcb_flags & PCB_FPREGS)) {
+ bzero(&pcb->pcb_fpu, sizeof(pcb->pcb_fpu));
+ pcb->pcb_flags |= PCB_FPREGS;
+ }
+ sig = fpu_emulate(frame, (struct fpreg *)&pcb->pcb_fpu);
+#endif
+
+ return (sig);
+}
+
OpenPOWER on IntegriCloud