From owner-svn-src-user@FreeBSD.ORG Thu Jul 8 04:04:27 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8474106564A; Thu, 8 Jul 2010 04:04:27 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC0718FC12; Thu, 8 Jul 2010 04:04:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6844RYR097671; Thu, 8 Jul 2010 04:04:27 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6844R4s097669; Thu, 8 Jul 2010 04:04:27 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201007080404.o6844R4s097669@svn.freebsd.org> From: Juli Mallett Date: Thu, 8 Jul 2010 04:04:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209791 - user/jmallett/octeon/sys/mips/mips X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2010 04:04:28 -0000 Author: jmallett Date: Thu Jul 8 04:04:27 2010 New Revision: 209791 URL: http://svn.freebsd.org/changeset/base/209791 Log: o) Allow changing trap_debug at runtime and set it to 0 by default if TRAP_DEBUG is defined. o) Crash user programs that try to access kernel addresses rather than kindly fixing them up as though they were misaligned and rather than generating kernel-level addresses errors and eventually panicking by trying to access addresses that are outright invalid, crash the user program. Modified: user/jmallett/octeon/sys/mips/mips/trap.c Modified: user/jmallett/octeon/sys/mips/mips/trap.c ============================================================================== --- user/jmallett/octeon/sys/mips/mips/trap.c Thu Jul 8 03:41:57 2010 (r209790) +++ user/jmallett/octeon/sys/mips/mips/trap.c Thu Jul 8 04:04:27 2010 (r209791) @@ -96,7 +96,9 @@ __FBSDID("$FreeBSD$"); #ifdef TRAP_DEBUG -int trap_debug = 1; +int trap_debug = 0; +SYSCTL_INT(_machdep, OID_AUTO, trap_debug, CTLFLAG_RW, + &trap_debug, 0, "Debug information on all traps"); #endif static void log_illegal_instruction(const char *, struct trapframe *); @@ -555,7 +557,10 @@ dofault: case T_ADDR_ERR_LD + T_USER: /* misaligned or kseg access */ case T_ADDR_ERR_ST + T_USER: /* misaligned or kseg access */ - if (allow_unaligned_acc) { + if (trapframe->badvaddr < 0 || + trapframe->badvaddr >= VM_MAXUSER_ADDRESS) { + msg = "ADDRESS_SPACE_ERR"; + } else if (allow_unaligned_acc) { int mode; if (type == (T_ADDR_ERR_LD + T_USER)) @@ -566,8 +571,10 @@ dofault: access_type = emulate_unaligned_access(trapframe, mode); if (access_type != 0) goto out; + msg = "ALIGNMENT_FIX_ERR"; + } else { + msg = "ADDRESS_ERR"; } - msg = "ADDRESS_ERR"; /* FALL THROUGH */ @@ -674,7 +681,9 @@ dofault: #endif } #ifdef TRAP_DEBUG - printf("SYSCALL #%d pid:%u\n", code, p->p_pid); + if (trap_debug) { + printf("SYSCALL #%d pid:%u\n", code, p->p_pid); + } #endif if (p->p_sysent->sv_mask) @@ -711,8 +720,10 @@ dofault: } } #ifdef TRAP_DEBUG - for (i = 0; i < nargs; i++) { - printf("args[%d] = %#jx\n", i, (intmax_t)args[i]); + if (trap_debug) { + for (i = 0; i < nargs; i++) { + printf("args[%d] = %#jx\n", i, (intmax_t)args[i]); + } } #endif #ifdef SYSCALL_TRACING @@ -924,8 +935,10 @@ dofault: case T_ADDR_ERR_LD: /* misaligned access */ case T_ADDR_ERR_ST: /* misaligned access */ #ifdef TRAP_DEBUG - printf("+++ ADDR_ERR: type = %d, badvaddr = %#jx\n", type, - (intmax_t)trapframe->badvaddr); + if (trap_debug) { + printf("+++ ADDR_ERR: type = %d, badvaddr = %#jx\n", type, + (intmax_t)trapframe->badvaddr); + } #endif /* Only allow emulation on a user address */ if (allow_unaligned_acc && @@ -971,9 +984,10 @@ err: printf("kernel mode)\n"); #ifdef TRAP_DEBUG - printf("badvaddr = %#jx, pc = %#jx, ra = %#jx, sr = %#jxx\n", - (intmax_t)trapframe->badvaddr, (intmax_t)trapframe->pc, (intmax_t)trapframe->ra, - (intmax_t)trapframe->sr); + if (trap_debug) + printf("badvaddr = %#jx, pc = %#jx, ra = %#jx, sr = %#jxx\n", + (intmax_t)trapframe->badvaddr, (intmax_t)trapframe->pc, (intmax_t)trapframe->ra, + (intmax_t)trapframe->sr); #endif #ifdef KDB