Module Name: src
Committed By: rin
Date: Sun Jun 21 00:00:27 UTC 2020
Modified Files:
src/sys/arch/powerpc/include: mcontext.h
src/sys/arch/powerpc/powerpc: sig_machdep.c
Log Message:
Fix SS_ONSTACK, which seems like broken since switched to siginfo.
Found by tests/lib/libc/sys/t_sigaltstack, which passes now, while
no other tests are not falling newly.
XXX
Shouldn't we turn _UC_{SET,CLR}STACK into MI?
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/powerpc/include/mcontext.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/powerpc/powerpc/sig_machdep.c
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/powerpc/include/mcontext.h
diff -u src/sys/arch/powerpc/include/mcontext.h:1.18 src/sys/arch/powerpc/include/mcontext.h:1.19
--- src/sys/arch/powerpc/include/mcontext.h:1.18 Thu Feb 15 15:53:56 2018
+++ src/sys/arch/powerpc/include/mcontext.h Sun Jun 21 00:00:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.18 2018/02/15 15:53:56 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.19 2020/06/21 00:00:27 rin Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -131,6 +131,8 @@ typedef struct {
#define _UC_POWERPC_VEC 0x00010000 /* Vector Register File valid */
#define _UC_POWERPC_SPE 0x00020000 /* Vector Register File valid */
#define _UC_TLSBASE 0x00080000 /* thread context valid in R2 */
+#define _UC_SETSTACK 0x00100000
+#define _UC_CLRSTACK 0x00200000
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_R1])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R31])
Index: src/sys/arch/powerpc/powerpc/sig_machdep.c
diff -u src/sys/arch/powerpc/powerpc/sig_machdep.c:1.48 src/sys/arch/powerpc/powerpc/sig_machdep.c:1.49
--- src/sys/arch/powerpc/powerpc/sig_machdep.c:1.48 Sat Apr 11 09:15:23 2020
+++ src/sys/arch/powerpc/powerpc/sig_machdep.c Sun Jun 21 00:00:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sig_machdep.c,v 1.48 2020/04/11 09:15:23 rin Exp $ */
+/* $NetBSD: sig_machdep.c,v 1.49 2020/06/21 00:00:27 rin Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.48 2020/04/11 09:15:23 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.49 2020/06/21 00:00:27 rin Exp $");
#include "opt_ppcarch.h"
#include "opt_altivec.h"
@@ -91,6 +91,8 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
/* Save register context. */
memset(&uc, 0, sizeof(uc));
uc.uc_flags = _UC_SIGMASK;
+ uc.uc_flags |= (ss->ss_flags & SS_ONSTACK) ?
+ _UC_SETSTACK : _UC_CLRSTACK;
uc.uc_sigmask = *mask;
uc.uc_link = l->l_ctxlink;
sendsig_reset(l, ksi->ksi_signo);
@@ -199,6 +201,7 @@ cpu_setmcontext(struct lwp *l, const mco
{
struct trapframe * const tf = l->l_md.md_utf;
const __greg_t * const gr = mcp->__gregs;
+ struct proc * const p = l->l_proc;
int error;
/* Restore GPR context, if any. */
@@ -261,6 +264,13 @@ cpu_setmcontext(struct lwp *l, const mco
vec_restore_from_mcontext(l, mcp);
#endif
+ mutex_enter(p->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(p->p_lock);
+
return (0);
}