[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260127153331.2902504-6-jremus@linux.ibm.com>
Date: Tue, 27 Jan 2026 16:33:31 +0100
From: Jens Remus <jremus@...ux.ibm.com>
To: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
linux-s390@...r.kernel.org, bpf@...r.kernel.org, x86@...nel.org,
Steven Rostedt <rostedt@...nel.org>
Cc: Jens Remus <jremus@...ux.ibm.com>, Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Ilya Leoshkevich <iii@...ux.ibm.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...nel.org>,
Jiri Olsa <jolsa@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andrii Nakryiko <andrii@...nel.org>,
Indu Bhagat <indu.bhagat@...cle.com>,
"Jose E. Marchesi" <jemarch@....org>,
Beau Belgrave <beaub@...ux.microsoft.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Florian Weimer <fweimer@...hat.com>, Kees Cook <kees@...nel.org>,
"Carlos O'Donell" <codonell@...hat.com>, Sam James <sam@...too.org>,
Dylan Hatch <dylanbhatch@...gle.com>
Subject: [RFC PATCH v1 5/5] s390/unwind_user: Enable signal frame unwinding of user space
Provide a s390-specific implementation of unwind_user_signal_next(),
that unwinds from a (RT) signal frame.
Signed-off-by: Jens Remus <jremus@...ux.ibm.com>
---
arch/s390/include/asm/unwind_user.h | 57 +++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/arch/s390/include/asm/unwind_user.h b/arch/s390/include/asm/unwind_user.h
index a7b97ea01c26..8f5524a24ae1 100644
--- a/arch/s390/include/asm/unwind_user.h
+++ b/arch/s390/include/asm/unwind_user.h
@@ -7,6 +7,7 @@
#include <linux/types.h>
#include <asm/asm-offsets.h>
#include <asm/fpu.h>
+#include <asm/sigframe.h>
#include <asm/stacktrace.h>
#include <linux/unwind_user_types.h>
@@ -67,6 +68,62 @@ static inline int arch_unwind_user_get_reg(unsigned long *val,
}
#define unwind_user_get_reg arch_unwind_user_get_reg
+#define SVC_OPCODE 0x0a
+#define INSN_SVC_SIGRETURN ((SVC_OPCODE << 8) | __NR_sigreturn)
+#define INSN_SVC_RT_SIGRETURN ((SVC_OPCODE << 8) | __NR_rt_sigreturn)
+
+static inline int unwind_user_signal_next(struct unwind_user_state *state)
+{
+ unsigned short insn;
+ const _sigregs __user *sr;
+ unsigned long sp, fp, ra;
+
+ /* ABI requires IP to be 2-byte aligned. */
+ if (state->ip & 1)
+ return -EINVAL;
+
+ if (__get_user(insn, (unsigned short __user *)state->ip))
+ return -EINVAL;
+
+ /*
+ * A signal frame has the instruction pointer pointing to
+ * svc $__NR_sigreturn or svc $__NR_rt_sigreturn
+ */
+ switch (insn) {
+ case INSN_SVC_SIGRETURN:
+ /* New-style non-RT frame. */
+ const struct sigframe __user *sf;
+
+ sf = (struct sigframe __user *)state->sp;
+ if (__get_user(sr, (_sigregs __user **)&sf->sc.sregs))
+ return -EINVAL;
+ break;
+ case INSN_SVC_RT_SIGRETURN:
+ /* New-style RT frame. */
+ const struct rt_sigframe __user *rt_sf;
+
+ rt_sf = (struct rt_sigframe __user *)state->sp;
+ sr = (_sigregs __user *)&rt_sf->uc.uc_mcontext;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (__get_user(sp, (unsigned long __user *)&sr->regs.gprs[15]))
+ return -EINVAL;
+ if (__get_user(fp, (unsigned long __user *)&sr->regs.gprs[11]))
+ return -EINVAL;
+ if (__get_user(ra, (unsigned long __user *)&sr->regs.psw.addr))
+ return -EINVAL;
+
+ state->ip = ra;
+ state->sp = sp;
+ state->fp = fp;
+ state->topmost = false;
+ return 0;
+}
+#define unwind_user_signal_next unwind_user_signal_next
+
#endif /* CONFIG_UNWIND_USER */
#ifdef CONFIG_HAVE_UNWIND_USER_FP
--
2.51.0
Powered by blists - more mailing lists