summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2014-10-29 13:42:27 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2014-10-29 13:42:27 +0000
commitfe79ff1a7cf43f76ee0680c2d86c8f74f5dedfba (patch)
treefa4c4028034610833ce776e728a8e05acb770d22
parent4cb2977128e29a56f5ade6cf77ea86418190f20e (diff)
downloadillumos-joyent-fe79ff1a7cf43f76ee0680c2d86c8f74f5dedfba.tar.gz
OS-3484 lxbrand 64bit core dumps in _ti_bind_guard
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/clone.c10
-rw-r--r--usr/src/uts/common/brand/lx/os/lx_brand.c13
-rw-r--r--usr/src/uts/common/brand/lx/sys/lx_brand.h1
3 files changed, 24 insertions, 0 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/clone.c b/usr/src/lib/brand/lx/lx_brand/common/clone.c
index 40415cd0e1..0ac49f7455 100644
--- a/usr/src/lib/brand/lx/lx_brand/common/clone.c
+++ b/usr/src/lib/brand/lx/lx_brand/common/clone.c
@@ -159,7 +159,12 @@ lx_exit(uintptr_t p1)
/*
* This thread is exiting. Restore the state of the thread to
* what it was before we started running linux code.
+ * For 64-bit code, since we know we are unwinding the stack back to
+ * lx_init, we need to unwind the syscall mode flag "stack" as well.
*/
+#if defined(_LP64)
+ (void) syscall(SYS_brand, B_UNWIND_NTV_SYSC_FLAG);
+#endif
(void) setcontext(&lx_tsd->lxtsd_exit_context);
/*
@@ -204,7 +209,12 @@ lx_group_exit(uintptr_t p1)
/*
* This thread is exiting. Restore the state of the thread to
* what it was before we started running linux code.
+ * For 64-bit code, since we know we are unwinding the stack back to
+ * lx_init, we need to unwind the syscall mode flag "stack" as well.
*/
+#if defined(_LP64)
+ (void) syscall(SYS_brand, B_UNWIND_NTV_SYSC_FLAG);
+#endif
(void) setcontext(&lx_tsd->lxtsd_exit_context);
/*
diff --git a/usr/src/uts/common/brand/lx/os/lx_brand.c b/usr/src/uts/common/brand/lx/os/lx_brand.c
index 58ebdb3110..75dc26e701 100644
--- a/usr/src/uts/common/brand/lx/os/lx_brand.c
+++ b/usr/src/uts/common/brand/lx/os/lx_brand.c
@@ -1103,6 +1103,19 @@ lx_brandsys(int cmd, int64_t *rval, uintptr_t arg1, uintptr_t arg2,
#endif /* amd64 */
return (getsetcontext(SETCONTEXT, (void *)arg1));
+ case B_UNWIND_NTV_SYSC_FLAG:
+#if defined(__amd64)
+ /*
+ * Used when exiting to support the setcontext back to the
+ * getcontext we performed in lx_init. We need to unwin
+ * whatever signal state is in br_scms since we are exiting.
+ * This sets us up for the B_SIGNAL_RETURN from lx_setcontext.
+ */
+ lwpd = ttolxlwp(curthread);
+ lwpd->br_scms = 1;
+#endif
+ return (0);
+
default:
ike_call = cmd - B_IKE_SYSCALL;
if (ike_call > 0 && ike_call <= LX_N_IKE_FUNCS) {
diff --git a/usr/src/uts/common/brand/lx/sys/lx_brand.h b/usr/src/uts/common/brand/lx/sys/lx_brand.h
index 2ecaf27691..431c4cf2ab 100644
--- a/usr/src/uts/common/brand/lx/sys/lx_brand.h
+++ b/usr/src/uts/common/brand/lx/sys/lx_brand.h
@@ -94,6 +94,7 @@ extern "C" {
#define B_STORE_ARGS 137
#define B_CLR_NTV_SYSC_FLAG 138
#define B_SIGNAL_RETURN 139
+#define B_UNWIND_NTV_SYSC_FLAG 140
#define B_IKE_SYSCALL 192