changeset 13919:e721e2fa45d8

3463 agent lwp clobbers amd64 abi stack redzone Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Garrett D'Amore <garrett@damore.org>
author Joshua M. Clulow <jmc@joyent.com>
date Fri, 11 Jan 2013 08:35:07 -0800
parents 4f2ce6c1a90c
children 91e6d0c446e5
files usr/src/lib/libproc/common/Psyscall.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libproc/common/Psyscall.c	Fri Jan 04 23:29:21 2013 -0500
+++ b/usr/src/lib/libproc/common/Psyscall.c	Fri Jan 11 08:35:07 2013 -0800
@@ -22,8 +22,9 @@
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
+/*
+ * Copyright (c) 2013, Joyent Inc. All rights reserved.
+ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -352,6 +353,16 @@
 #ifdef _LP64
 	if (model == PR_MODEL_LP64) {
 		sp = P->status.pr_lwp.pr_reg[R_SP] + STACK_BIAS;
+#if defined(__amd64)
+		/*
+		 * To offset the expense of computerised subtraction, the AMD64
+		 * ABI allows a process the use of a 128-byte area beyond the
+		 * location pointed to by %rsp.  We must advance the agent's
+		 * stack pointer by at least the size of this region or else it
+		 * may corrupt this temporary storage.
+		 */
+		sp -= STACK_RESERVE64;
+#endif
 		sp = PSTACK_ALIGN64(sp);
 	} else {
 #endif