summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/aim
diff options
context:
space:
mode:
authorjhibbits <jhibbits@FreeBSD.org>2014-01-15 05:19:37 +0000
committerjhibbits <jhibbits@FreeBSD.org>2014-01-15 05:19:37 +0000
commitb1391adbae9577879c598fce281eb1179d26142f (patch)
tree4f4aad2d0495e4af20e1796de50d77105fd6f2b6 /sys/powerpc/aim
parent44cab258a2754ab2d2c9af0fabd9cd6bda591fb9 (diff)
downloadFreeBSD-src-b1391adbae9577879c598fce281eb1179d26142f.zip
FreeBSD-src-b1391adbae9577879c598fce281eb1179d26142f.tar.gz
MFC r256543,r259245,r259421,r259668,r259674
r256543: Add fasttrap for PowerPC. This is the last piece of the DTrace/ppc puzzle. It's incomplete, it doesn't contain full instruction emulation, but it should be sufficient for most cases. r259245,r259421: (FBT) FBT now does work fully on PowerPC. Save r3 before using it for the trap check, else we end up saving the new r3, containing the trap instruction encoding (0x7c810808), and restoring it back with the frame on return. This caused it to panic on my ppc32 machine. r259668,r259674: Fix a typo in the FBT code.
Diffstat (limited to 'sys/powerpc/aim')
-rw-r--r--sys/powerpc/aim/trap.c18
-rw-r--r--sys/powerpc/aim/trap_subr32.S18
-rw-r--r--sys/powerpc/aim/trap_subr64.S16
3 files changed, 44 insertions, 8 deletions
diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c
index d31e47b..41e1a79 100644
--- a/sys/powerpc/aim/trap.c
+++ b/sys/powerpc/aim/trap.c
@@ -175,6 +175,9 @@ trap(struct trapframe *frame)
{
struct thread *td;
struct proc *p;
+#ifdef KDTRACE_HOOKS
+ uint32_t inst;
+#endif
int sig, type, user;
u_int ucode;
ksiginfo_t ksi;
@@ -279,9 +282,18 @@ trap(struct trapframe *frame)
case EXC_PGM:
/* Identify the trap reason */
- if (frame->srr1 & EXC_PGM_TRAP)
+ if (frame->srr1 & EXC_PGM_TRAP) {
+#ifdef KDTRACE_HOOKS
+ inst = fuword32((const void *)frame->srr0);
+ if (inst == 0x0FFFDDDD && dtrace_pid_probe_ptr != NULL) {
+ struct reg regs;
+ fill_regs(td, &regs);
+ (*dtrace_pid_probe_ptr)(&regs);
+ break;
+ }
+#endif
sig = SIGTRAP;
- else if (ppc_instr_emulate(frame) == 0)
+ } else if (ppc_instr_emulate(frame) == 0)
frame->srr0 += 4;
else
sig = SIGILL;
@@ -299,7 +311,7 @@ trap(struct trapframe *frame)
#ifdef KDTRACE_HOOKS
case EXC_PGM:
if (frame->srr1 & EXC_PGM_TRAP) {
- if (*(uintptr_t *)frame->srr0 == 0x7c810808) {
+ if (*(uint32_t *)frame->srr0 == 0x7c810808) {
if (dtrace_invop_jump_addr != NULL) {
dtrace_invop_jump_addr(frame);
return;
diff --git a/sys/powerpc/aim/trap_subr32.S b/sys/powerpc/aim/trap_subr32.S
index d137fd4..80fa893 100644
--- a/sys/powerpc/aim/trap_subr32.S
+++ b/sys/powerpc/aim/trap_subr32.S
@@ -882,8 +882,8 @@ CNAME(dblow):
mfcr %r29 /* save CR in r29 */
mfsrr1 %r1
mtcr %r1
- bf 17,1f /* branch if privileged */
-
+ bf 17,2f /* branch if privileged */
+1:
/* Unprivileged case */
mtcr %r29 /* put the condition register back */
mfsprg2 %r29 /* ... and r29 */
@@ -892,7 +892,19 @@ CNAME(dblow):
li %r1, 0 /* How to get the vector from LR */
bla generictrap /* and we look like a generic trap */
-1:
+2:
+#ifdef KDTRACE_HOOKS
+ /* Privileged, so drop to KDB */
+ mfsrr0 %r1
+ mtsprg3 %r3
+ lwz %r1,0(%r1)
+ /* Check if it's a DTrace trap. */
+ li %r3,0x0808
+ addis %r3,%r3,0x7c81
+ cmplw %cr0,%r3,%r1
+ mfsprg3 %r3
+ beq %cr0,1b
+#endif
/* Privileged, so drop to KDB */
GET_CPUINFO(%r1)
stw %r28,(PC_DBSAVE+CPUSAVE_R28)(%r1) /* free r28 */
diff --git a/sys/powerpc/aim/trap_subr64.S b/sys/powerpc/aim/trap_subr64.S
index 8550227..16185f6 100644
--- a/sys/powerpc/aim/trap_subr64.S
+++ b/sys/powerpc/aim/trap_subr64.S
@@ -788,8 +788,9 @@ CNAME(dblow):
mfcr %r29 /* save CR in r29 */
mfsrr1 %r1
mtcr %r1
- bf 17,1f /* branch if privileged */
+ bf 17,2f /* branch if privileged */
+1:
/* Unprivileged case */
mtcr %r29 /* put the condition register back */
mfsprg2 %r29 /* ... and r29 */
@@ -798,8 +799,19 @@ CNAME(dblow):
li %r1, 0 /* How to get the vector from LR */
bla generictrap /* and we look like a generic trap */
-1:
+2:
+#ifdef KDTRACE_HOOKS
/* Privileged, so drop to KDB */
+ mfsrr0 %r1
+ mtsprg3 %r3
+ lwz %r1,0(%r1)
+ /* Check if it's a DTrace trap. */
+ li %r3,0x0808
+ addis %r3,%r3,0x7c81
+ cmplw %cr0,%r3,%r1
+ mfsprg3 %r3
+ beq %cr0,1b
+#endif
GET_CPUINFO(%r1)
std %r27,(PC_DBSAVE+CPUSAVE_R27)(%r1) /* free r27 */
std %r28,(PC_DBSAVE+CPUSAVE_R28)(%r1) /* free r28 */
OpenPOWER on IntegriCloud