@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.371 2021/05/05 15:36:17 thorpej Exp $ */
+/* $NetBSD: machdep.c,v 1.372 2021/05/24 21:00:12 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2019, 2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.371 2021/05/05 15:36:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.372 2021/05/24 21:00:12 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1525,6 +1525,8 @@
frame.sf_uc.uc_flags = _UC_SIGMASK;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_link = l->l_ctxlink;
+ frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
+ ? _UC_SETSTACK : _UC_CLRSTACK;
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
cpu_getmcontext(l, &frame.sf_uc.uc_mcontext, &frame.sf_uc.uc_flags);
@@ -1885,8 +1887,10 @@
frame->tf_regs[FRAME_PC] = gr[_REG_PC];
frame->tf_regs[FRAME_PS] = gr[_REG_PS];
}
+
if (flags & _UC_TLSBASE)
lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_UNIQUE]);
+
/* Restore floating point register context, if any. */
if (flags & _UC_FPU) {
/* If we have an FP register context, get rid of it. */
@@ -1895,6 +1899,13 @@
sizeof (pcb->pcb_fp));
l->l_md.md_flags = mcp->__fpregs.__fp_fpcr & MDLWP_FP_C;
}
+
+ mutex_enter(l->l_proc->p_lock);
+ if (flags & _UC_SETSTACK)
+ l->l_sigstk.ss_flags |= SS_ONSTACK;
+ if (flags & _UC_CLRSTACK)
+ l->l_sigstk.ss_flags &= ~SS_ONSTACK;
+ mutex_exit(l->l_proc->p_lock);
return (0);
}
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.10 2019/12/27 00:32:16 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.11 2021/05/24 21:00:12 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -94,6 +94,8 @@
/* Machine-dependent uc_flags */
#define _UC_TLSBASE 0x20 /* valid process-unique value in _REG_UNIQUE */
+#define _UC_SETSTACK 0x00010000
+#define _UC_CLRSTACK 0x00020000
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S6])