Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jan 2018 20:47:03 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r327472 - in head/sys: amd64/amd64 i386/i386
Message-ID:  <201801012047.w01Kl3Kq040165@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Jan  1 20:47:03 2018
New Revision: 327472
URL: https://svnweb.freebsd.org/changeset/base/327472

Log:
  Avoid re-check of usermode condition.
  
  It does not change anything in the behavior of trap_pfault(), while
  eliminating obfuscation of jumping to the code which checks for the
  condition reversed of the goto cause.  Also avoid force initialize the
  rv variable, since it is now only accessed after storing vm_fault()
  return value.
  
  Reviewed by:	alc
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D13725

Modified:
  head/sys/amd64/amd64/trap.c
  head/sys/i386/i386/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Mon Jan  1 20:39:12 2018	(r327471)
+++ head/sys/amd64/amd64/trap.c	Mon Jan  1 20:47:03 2018	(r327472)
@@ -608,7 +608,6 @@ trap_pfault(struct trapframe *frame, int usermode)
 	td = curthread;
 	p = td->td_proc;
 	eva = frame->tf_addr;
-	rv = 0;
 
 	if (__predict_false((td->td_pflags & TDP_NOFAULTING) != 0)) {
 		/*
@@ -660,7 +659,7 @@ trap_pfault(struct trapframe *frame, int usermode)
 		 * Don't allow user-mode faults in kernel address space.
 		 */
 		if (usermode)
-			goto nogo;
+			return (SIGSEGV);
 
 		map = kernel_map;
 	} else {
@@ -715,7 +714,6 @@ trap_pfault(struct trapframe *frame, int usermode)
 #endif
 		return (0);
 	}
-nogo:
 	if (!usermode) {
 		if (td->td_intr_nesting_level == 0 &&
 		    curpcb->pcb_onfault != NULL) {

Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c	Mon Jan  1 20:39:12 2018	(r327471)
+++ head/sys/i386/i386/trap.c	Mon Jan  1 20:47:03 2018	(r327472)
@@ -744,7 +744,6 @@ trap_pfault(struct trapframe *frame, int usermode, vm_
 
 	td = curthread;
 	p = td->td_proc;
-	rv = 0;
 
 	if (__predict_false((td->td_pflags & TDP_NOFAULTING) != 0)) {
 		/*
@@ -805,7 +804,7 @@ trap_pfault(struct trapframe *frame, int usermode, vm_
 			return (-2);
 #endif
 		if (usermode)
-			goto nogo;
+			return (SIGSEGV);
 
 		map = kernel_map;
 	} else {
@@ -862,7 +861,6 @@ trap_pfault(struct trapframe *frame, int usermode, vm_
 #endif
 		return (0);
 	}
-nogo:
 	if (!usermode) {
 		if (td->td_intr_nesting_level == 0 &&
 		    curpcb->pcb_onfault != NULL) {



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