Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2007 22:38:18 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 131264 for review
Message-ID:  <200712192238.lBJMcIwB065123@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=131264

Change 131264 by jb@jb_freebsd1 on 2007/12/19 22:37:51

	Reset these to match CVS for now. Some of the code here
	relies on CDDL headers that Sun won't relicense. This means
	that the code will have to be part of the dtrace module
	and hooked in when that is loaded.

Affected files ...

.. //depot/projects/dtrace/src/sys/i386/i386/exception.s#13 edit
.. //depot/projects/dtrace/src/sys/i386/i386/trap.c#23 edit

Differences ...

==== //depot/projects/dtrace/src/sys/i386/i386/exception.s#13 (text+ko) ====

@@ -34,13 +34,6 @@
  * $FreeBSD: src/sys/i386/i386/exception.s,v 1.118 2007/12/07 08:20:16 jkoshy Exp $
  */
 
-/*
- * The DTrace parts of this file are:
- *
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
 #include "opt_apic.h"
 #include "opt_hwpmc_hooks.h"
 #include "opt_npx.h"
@@ -48,12 +41,10 @@
 #include <machine/asmacros.h>
 #include <machine/psl.h>
 #include <machine/trap.h>
-#include <machine/dtrace_asm.h>
 
 #include "assym.s"
 
 #define	SEL_RPL_MASK	0x0003
-#define	GSEL_KPL	0x0020	/* GSEL(GCODE_SEL, SEL_KPL) */
 
 	.text
 #ifdef HWPMC_HOOKS
@@ -104,6 +95,8 @@
 	pushl $0; TRAP(T_OFLOW)
 IDTVEC(bnd)
 	pushl $0; TRAP(T_BOUND)
+IDTVEC(ill)
+	pushl $0; TRAP(T_PRIVINFLT)
 IDTVEC(dna)
 	pushl $0; TRAP(T_DNA)
 IDTVEC(fpusegm)
@@ -160,162 +153,6 @@
 	jmp	doreti
 
 /*
- * Privileged instruction fault.
- */
-	SUPERALIGN_TEXT
-IDTVEC(ill)
-	/*
-	 * DTrace uses invalid instructions to hook itself into
-	 * the executable code. A privileged instruction fault in
-	 * kernel code probably is the result of a 'Function Boundary
-	 * Tracing' (FBT) or 'Statically Defined Tracing' (SDT)
-	 * probe.
-	 *
-	 * Check if there is an invalid instruction function registered.
-	 * (see trap.c for the global variable referenced)
-	 */
-	cmpl	$0, (dtrace_invop_func)
-
-	/* If not, just handle it as a normal trap. */
-	jz	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. */
-
-	/*
-	 * Setup the stack to contain the arguments to:
-	 * int dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax);
-	 */
-	pushl	%eax			/* Push %eax -- may contain the return value. */
-	pushl	%esp			/* Push the stack pointer. */
-	addl	$48, (%esp)		/* Adjust to incoming args. */
-	pushl	40(%esp)		/* Push the calling EIP. */
-
-	/* Call the registered function (dtrace_invop). */
-	call	*dtrace_invop_func	/* Call the registered function. */
-
-ALTENTRY(dtrace_invop_callsite)
-	/*
-	 * Drop the arguments to dtrace_invop from the stack, leaving
-	 * the registers.
-	 */
-	addl	$12, %esp
-
-	/* Process according to the return value from dtrace_invop. */
-	cmpl	$DTRACE_INVOP_PUSHL_EBP, %eax
-	je	__dtrace_invop_pushl_ebp
-	cmpl	$DTRACE_INVOP_POPL_EBP, %eax
-	je	__dtrace_invop_popl_ebp
-	cmpl	$DTRACE_INVOP_LEAVE, %eax
-	je	__dtrace_invop_leave
-	cmpl	$DTRACE_INVOP_NOP, %eax
-	je	__dtrace_invop_nop
-
-	/*
-	 * The registered DTrace invalid instruction functions didn't
-	 * match the fault address to a probe, so process the trap in
-	 * the normal way.
-	 &/
-	 * normal way because the registered DTrace invalid instruction
-	 * functions didn't match it to a probe.
-	 */
-	jmp	norm_ill
-
-	/* case DTRACE_INVOP_PUSHL_EBP: */
-__dtrace_invop_pushl_ebp:
-	/*
-	 * We must emulate a "pushl %ebp".  To do this, we pull the stack
-	 * down 4 bytes, and then store the base pointer.
-	 */
-	popal
-	subl	$4, %esp		/* make room for %ebp */
-	pushl	%eax			/* push temp */
-	movl	8(%esp), %eax		/* load calling EIP */
-	incl	%eax			/* increment over LOCK prefix */
-	movl	%eax, 4(%esp)		/* store calling EIP */
-	movl	12(%esp), %eax		/* load calling CS */
-	movl	%eax, 8(%esp)		/* store calling CS */
-	movl	16(%esp), %eax		/* load calling EFLAGS */
-	movl	%eax, 12(%esp)		/* store calling EFLAGS */
-	movl	%ebp, 16(%esp)		/* push %ebp */
-	popl	%eax			/* pop off temp */
-	iret				/* return from interrupt */
-
-	/* case DTRACE_INVOP_POPL_EBP: */
-__dtrace_invop_popl_ebp:
-	/*
-	 * We must emulate a "popl %ebp".  To do this, we do the opposite of
-	 * the above:  we remove the %ebp from the stack, and squeeze up the
-	 * saved state from the trap.
-	 */
-	popal
-	pushl	%eax			/* push temp */
-	movl	16(%esp), %ebp		/* pop %ebp */
-	movl	12(%esp), %eax		/* load calling EFLAGS */
-	movl	%eax, 16(%esp)		/* store calling EFLAGS */
-	movl	8(%esp), %eax		/* load calling CS */
-	movl	%eax, 12(%esp)		/* store calling CS */
-	movl	4(%esp), %eax		/* load calling EIP */
-	incl	%eax			/* increment over LOCK prefix */
-	movl	%eax, 8(%esp)		/* store calling EIP */
-	popl	%eax			/* pop off temp */
-	addl	$4, %esp		/* adjust stack pointer */
-	iret				/* return from interrupt */
-
-	/* case DTRACE_INVOP_LEAVE: */
-__dtrace_invop_leave:
-	/*
-	 * We must emulate a "leave", which is the same as a "movl %ebp, %esp"
-	 * followed by a "popl %ebp".  This looks similar to the above, but
-	 * requires two temporaries:  one for the new base pointer, and one
-	 * for the staging register.
-	 */
-	popal
-	pushl	%eax			/* push temp */
-	pushl	%ebx			/* push temp */
-	movl	%ebp, %ebx		/* set temp to old %ebp */
-	movl	(%ebx), %ebp		/* pop %ebp */
-	movl	16(%esp), %eax		/* load calling EFLAGS */
-	movl	%eax, (%ebx)		/* store calling EFLAGS */
-	movl	12(%esp), %eax		/* load calling CS */
-	movl	%eax, -4(%ebx)		/* store calling CS */
-	movl	8(%esp), %eax		/* load calling EIP */
-	incl	%eax			/* increment over LOCK prefix */
-	movl	%eax, -8(%ebx)		/* store calling EIP */
-	movl	%ebx, -4(%esp)		/* temporarily store new %esp */
-	popl	%ebx			/* pop off temp */
-	popl	%eax			/* pop off temp */
-	movl	-12(%esp), %esp		/* set stack pointer */
-	subl	$8, %esp		/* adjust for three pushes, one pop */
-	iret				/* return from interrupt */
-
-	/* case DTRACE_INVOP_NOP: */
-__dtrace_invop_nop:
-	/*
-	 * We must emulate a "nop".  This is obviously not hard:  we need only
-	 * advance the %eip by one.
-	 */
-	popal
-	incl	(%esp)
-	iret
-
-norm_ill:
-	/*
-	 * Process the instruction fault in the normal way.
-	 */
-	pushl $0
-	TRAP(T_PRIVINFLT)
-
-/*
  * SYSCALL CALL GATE (old entry point for a.out binaries)
  *
  * The intersegment call has been set up to specify one dummy parameter.

==== //depot/projects/dtrace/src/sys/i386/i386/trap.c#23 (text+ko) ====

@@ -102,30 +102,6 @@
 #include <machine/clock.h>
 #endif
 
-/*
- * These are hooks which are  initialised by the dtrace module
- * when it is loaded. This keeps the DTrace implementation
- * opaque.
- *
- * All that the trap() function below needs to determine
- * is how many instruction bytes to offset the instruction
- * pointer before returning from a trap that occured durin a
- * 'no-fault' DTrace probe.
- */
-dtrace_instr_size_func_t	dtrace_instr_size_func;
-
-/*
- * This hook handles invalid opcodes.
- */
-dtrace_invop_func_t	dtrace_invop_func;
-
-/*
- * This is a hook which is initialised by the systrace module
- * when it is loaded. This keeps the DTrace syscall provider
- * implementation opaque. 
- */
-systrace_probe_func_t	systrace_probe_func;
-
 extern void trap(struct trapframe *frame);
 extern void syscall(struct trapframe *frame);
 
@@ -242,66 +218,6 @@
 	    goto out;
 #endif
 
-	/*
-	 * A trap can occur while DTrace executes a probe. Before
-	 * executing the probe, DTrace blocks re-scheduling and sets
-	 * a flag in it's per-cpu flags to indicate that it doesn't
-	 * want to fault. On returning from the the probe, the no-fault
-	 * flag is cleared and finally re-scheduling is enabled.
-	 *
-	 * Check if DTrace has enabled 'no-fault' mode:
-	 *
-	 */
-	if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
-		/*
-		 * When the dtrace module was loaded (or initialised
-		 * if linked into the kernel), it should have set it's
-		 * machine dependent instruction size function pointer
-		 * for use here. If not, the trap will just end up
-		 * being processed as a panic like any other.
-		 */
-		if (dtrace_instr_size_func != NULL) {
-			/*
-			 * There are only a couple of trap types that
-			 * are expected. All the rest will be handled
-			 * in the usual way.
-			 */
-			switch (type) {
-			/* General protection fault. */
-			case T_PROTFLT:
-				/* Flag an illegal operation. */
-				cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
-
-				/*
-				 * Offset the instruction pointer
-				 * to the instruction following the
-				 * one casing the fault.
-				 */
-				frame.tf_eip += (*dtrace_instr_size_func)((u_char *) frame.tf_eip);
-				goto out;
-			/* Page fault. */
-			case T_PAGEFLT:
-				/* Flag a bad address. */
-				cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
-				cpu_core[curcpu].cpuc_dtrace_illval = rcr2();
-
-				/*
-				 * Offset the instruction pointer
-				 * to the instruction following the
-				 * one casing the fault.
-				 */
-				frame.tf_eip += (*dtrace_instr_size_func)((u_char *) frame.tf_eip);
-				goto out;
-			default:
-				/*
-				 * Handle all other traps in the usual
-				 * way.
-				 */
-				break;
-			}
-		}
-	}
-
 	if ((frame->tf_eflags & PSL_I) == 0) {
 		/*
 		 * Buggy application or kernel code has disabled
@@ -1114,30 +1030,9 @@
 
 		PTRACESTOP_SC(p, td, S_PT_SCE);
 
-		/*
-		 * If the systrace module has registered it's probe
-		 * callback and if there is a probe active for the
-		 * syscall 'entry', process the probe.
-		 */
-		if (systrace_probe_func != NULL && callp->sy_entry != 0)
-			(*systrace_probe_func)(callp->sy_entry, code, callp,
-			    args);
-
 		AUDIT_SYSCALL_ENTER(code, td);
 		error = (*callp->sy_call)(td, args);
 		AUDIT_SYSCALL_EXIT(error, td);
-
-		/* Save the error return variable for DTrace to reference. */
-		td->td_errno = error;
-
-		/*
-		 * If the systrace module has registered it's probe
-		 * callback and if there is a probe active for the
-		 * syscall 'return', process the probe.
-		 */
-		if (systrace_probe_func != NULL && callp->sy_return != 0)
-			(*systrace_probe_func)(callp->sy_return, code, callp,
-			    args);
 	}
 
 	switch (error) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712192238.lBJMcIwB065123>