From owner-svn-src-head@FreeBSD.ORG Mon Mar 12 05:28:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3E2C4106564A; Mon, 12 Mar 2012 05:28:03 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1063F8FC14; Mon, 12 Mar 2012 05:28:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2C5S2EI044751; Mon, 12 Mar 2012 05:28:02 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2C5S2I4044749; Mon, 12 Mar 2012 05:28:02 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201203120528.q2C5S2I4044749@svn.freebsd.org> From: Alan Cox Date: Mon, 12 Mar 2012 05:28:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232851 - head/sys/i386/i386 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2012 05:28:03 -0000 Author: alc Date: Mon Mar 12 05:28:02 2012 New Revision: 232851 URL: http://svn.freebsd.org/changeset/base/232851 Log: Simplify the error checking in one branch of trap_pfault() and update the nearby comment. Correct the style of two return statements in trap_pfault(). Merge a comment from amd64's trap_pfault(). Modified: head/sys/i386/i386/trap.c Modified: head/sys/i386/i386/trap.c ============================================================================== --- head/sys/i386/i386/trap.c Mon Mar 12 03:47:30 2012 (r232850) +++ head/sys/i386/i386/trap.c Mon Mar 12 05:28:02 2012 (r232851) @@ -797,7 +797,7 @@ trap_pfault(frame, usermode, eva) vm_offset_t eva; { vm_offset_t va; - struct vmspace *vm = NULL; + struct vmspace *vm; vm_map_t map; int rv = 0; vm_prot_t ftype; @@ -816,7 +816,7 @@ trap_pfault(frame, usermode, eva) */ #if defined(I586_CPU) && !defined(NO_F00F_HACK) if ((eva == (unsigned int)&idt[6]) && has_f00f_bug) - return -2; + return (-2); #endif if (usermode) goto nogo; @@ -824,17 +824,21 @@ trap_pfault(frame, usermode, eva) map = kernel_map; } else { /* - * This is a fault on non-kernel virtual memory. - * vm is initialized above to NULL. If curproc is NULL - * or curproc->p_vmspace is NULL the fault is fatal. + * This is a fault on non-kernel virtual memory. If either + * p or p->p_vmspace is NULL, then the fault is fatal. */ - if (p != NULL) - vm = p->p_vmspace; - - if (vm == NULL) + if (p == NULL || (vm = p->p_vmspace) == NULL) goto nogo; map = &vm->vm_map; + + /* + * When accessing a user-space address, kernel must be + * ready to accept the page fault, and provide a + * handling routine. Since accessing the address + * without the handler is a bug, do not try to handle + * it normally, and panic immediately. + */ if (!usermode && (td->td_intr_nesting_level != 0 || PCPU_GET(curpcb)->pcb_onfault == NULL)) { trap_fatal(frame, eva); @@ -889,8 +893,7 @@ nogo: trap_fatal(frame, eva); return (-1); } - - return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV); + return ((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV); } static void