Module Name: src
Committed By: thorpej
Date: Mon May 24 21:00:12 UTC 2021
Modified Files:
src/sys/arch/alpha/alpha: machdep.c
src/sys/arch/alpha/include: mcontext.h
Log Message:
Add _UC_SETSTACK / _UC_CLRSTACK handling. Fixes the t_sigaltstack test
on alpha.
To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/include/mcontext.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/alpha/alpha/machdep.c
diff -u src/sys/arch/alpha/alpha/machdep.c:1.371 src/sys/arch/alpha/alpha/machdep.c:1.372
--- src/sys/arch/alpha/alpha/machdep.c:1.371 Wed May 5 15:36:17 2021
+++ src/sys/arch/alpha/alpha/machdep.c Mon May 24 21:00:12 2021
@@ -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 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
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 @@ cpu_setmcontext(struct lwp *l, const mco
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. */
@@ -1896,6 +1900,13 @@ cpu_setmcontext(struct lwp *l, const mco
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);
}
Index: src/sys/arch/alpha/include/mcontext.h
diff -u src/sys/arch/alpha/include/mcontext.h:1.10 src/sys/arch/alpha/include/mcontext.h:1.11
--- src/sys/arch/alpha/include/mcontext.h:1.10 Fri Dec 27 00:32:16 2019
+++ src/sys/arch/alpha/include/mcontext.h Mon May 24 21:00:12 2021
@@ -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 @@ typedef struct {
/* 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])