From owner-p4-projects@FreeBSD.ORG Mon Jun 9 03:11:33 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 55287106567E; Mon, 9 Jun 2008 03:11:32 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 766F3106567A for ; Mon, 9 Jun 2008 03:11:32 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 629218FC19 for ; Mon, 9 Jun 2008 03:11:32 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m593BW71051494 for ; Mon, 9 Jun 2008 03:11:32 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m593BWpV051492 for perforce@freebsd.org; Mon, 9 Jun 2008 03:11:32 GMT (envelope-from jb@freebsd.org) Date: Mon, 9 Jun 2008 03:11:32 GMT Message-Id: <200806090311.m593BWpV051492@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 143159 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jun 2008 03:11:33 -0000 http://perforce.freebsd.org/chv.cgi?CH=143159 Change 143159 by jb@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 @@ -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.