svn commit: r232851 - head/sys/i386/i386
Alan Cox
alc at FreeBSD.org
Mon Mar 12 05:28:03 UTC 2012
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
More information about the svn-src-head
mailing list