PERFORCE change 143159 for review
John Birrell
jb at FreeBSD.org
Mon Jun 9 03:11:33 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143159
Change 143159 by jb at freebsd3 on 2008/06/09 03:11:29
Add the exception handling hooks for the DTrace Function Boundary
Trace Provider (fbt).
Affected files ...
.. //depot/projects/dtrace6/src/sys/i386/i386/exception.s#2 edit
Differences ...
==== //depot/projects/dtrace6/src/sys/i386/i386/exception.s#2 (text+ko) ====
@@ -31,6 +31,7 @@
*/
#include "opt_apic.h"
+#include "opt_kdtrace.h"
#include "opt_npx.h"
#include <machine/asmacros.h>
@@ -40,7 +41,24 @@
#include "assym.s"
#define SEL_RPL_MASK 0x0003
+#define GSEL_KPL 0x0020 /* GSEL(GCODE_SEL, SEL_KPL) */
+
+#ifdef KDTRACE_HOOKS
+ .bss
+ .globl dtrace_invop_jump_addr
+ .align 4
+ .type dtrace_invop_jump_addr, @object
+ .size dtrace_invop_jump_addr, 4
+dtrace_invop_jump_addr:
+ .zero 4
+ .globl dtrace_invop_calltrap_addr
+ .align 4
+ .type dtrace_invop_calltrap_addr, @object
+ .size dtrace_invop_calltrap_addr, 4
+dtrace_invop_calltrap_addr:
+ .zero 8
+#endif
.text
/*****************************************************************************/
@@ -86,8 +104,10 @@
pushl $0; TRAP(T_OFLOW)
IDTVEC(bnd)
pushl $0; TRAP(T_BOUND)
+#ifndef KDTRACE_HOOKS
IDTVEC(ill)
pushl $0; TRAP(T_PRIVINFLT)
+#endif
IDTVEC(dna)
pushl $0; TRAP(T_DNA)
IDTVEC(fpusegm)
@@ -145,6 +165,45 @@
jmp doreti
/*
+ * Privileged instruction fault.
+ */
+#ifdef KDTRACE_HOOKS
+ SUPERALIGN_TEXT
+IDTVEC(ill)
+ /* Check if there is no DTrace hook registered. */
+ cmpl $0,dtrace_invop_jump_addr
+ je norm_ill
+
+ /* Check if this is a user fault. */
+ cmpl $GSEL_KPL, 4(%esp) /* Check the code segment. */
+
+ /* If so, just handle it as a normal trap. */
+ jne norm_ill
+
+ /*
+ * This is a kernel instruction fault that might have been caused
+ * by a DTrace provider.
+ */
+ pushal /* Push all registers onto the stack. */
+
+ /*
+ * Set our jump address for the jump back in the event that
+ * the exception wasn't caused by DTrace at all.
+ */
+ movl $norm_ill, dtrace_invop_calltrap_addr
+
+ /* Jump to the code hooked in by DTrace. */
+ jmpl *dtrace_invop_jump_addr
+
+ /*
+ * Process the instruction fault in the normal way.
+ */
+norm_ill:
+ pushl $0
+ TRAP(T_PRIVINFLT)
+#endif
+
+/*
* SYSCALL CALL GATE (old entry point for a.out binaries)
*
* The intersegment call has been set up to specify one dummy parameter.
More information about the p4-projects
mailing list