Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Jul 2017 20:44:01 +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: r320619 - head/sys/kern
Message-ID:  <201707032044.v63Ki1BY098753@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Jul  3 20:44:01 2017
New Revision: 320619
URL: https://svnweb.freebsd.org/changeset/base/320619

Log:
  Resolve confusion between different error code spaces.
  
  The vm_map_fixed() and vm_map_stack() VM functions return Mach error
  codes.  Convert them into errno values before returning result from
  exec_new_vmspace().
  
  While there, modernize the comment and do minor style adjustments.
  
  Reviewed by:	alc
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/kern/kern_exec.c

Modified: head/sys/kern/kern_exec.c
==============================================================================
--- head/sys/kern/kern_exec.c	Mon Jul  3 20:36:58 2017	(r320618)
+++ head/sys/kern/kern_exec.c	Mon Jul  3 20:44:01 2017	(r320619)
@@ -1054,9 +1054,9 @@ exec_unmap_first_page(struct image_params *imgp)
 }
 
 /*
- * Destroy old address space, and allocate a new stack
- *	The new stack is only SGROWSIZ large because it is grown
- *	automatically in trap.c.
+ * Destroy old address space, and allocate a new stack.
+ *	The new stack is only sgrowsiz large because it is grown
+ *	automatically on a page fault.
  */
 int
 exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
@@ -1112,9 +1112,9 @@ exec_new_vmspace(struct image_params *imgp, struct sys
 		    VM_PROT_READ | VM_PROT_EXECUTE,
 		    VM_PROT_READ | VM_PROT_EXECUTE,
 		    MAP_INHERIT_SHARE | MAP_ACC_NO_CHARGE);
-		if (error) {
+		if (error != KERN_SUCCESS) {
 			vm_object_deallocate(obj);
-			return (error);
+			return (vm_mmap_to_errno(error));
 		}
 	}
 
@@ -1138,10 +1138,9 @@ exec_new_vmspace(struct image_params *imgp, struct sys
 	stack_addr = sv->sv_usrstack - ssiz;
 	error = vm_map_stack(map, stack_addr, (vm_size_t)ssiz,
 	    obj != NULL && imgp->stack_prot != 0 ? imgp->stack_prot :
-		sv->sv_stackprot,
-	    VM_PROT_ALL, MAP_STACK_GROWS_DOWN);
-	if (error)
-		return (error);
+	    sv->sv_stackprot, VM_PROT_ALL, MAP_STACK_GROWS_DOWN);
+	if (error != KERN_SUCCESS)
+		return (vm_mmap_to_errno(error));
 
 	/*
 	 * vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they



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