[RFC PATCH v3 12/17] unwind_user/sframe: Enable archs with encoded SFrame CFA offsets

Jens Remus
2025-12-08T17:16:44Z

Enable architectures, such as s390, which store SFrame CFA offset values
encoded, to e.g. make (better) use of unsigned 8-bit SFrame offsets.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---

Notes (jremus):
Changes in RFC v2:
- Rename generic_sframe_cfa_offset_decode() to
sframe_cfa_offset_decode(). (Josh)

include/asm-generic/unwind_user_sframe.h | 8 ++++++++
kernel/unwind/sframe.c | 1 +
2 files changed, 9 insertions(+)

diff --git a/include/asm-generic/unwind_user_sframe.h b/include/asm-generic/unwind_user_sframe.h
index fd71d6b1916b..ec68a77551f0 100644
--- a/include/asm-generic/unwind_user_sframe.h
+++ b/include/asm-generic/unwind_user_sframe.h
@@ -10,6 +10,14 @@
#define SFRAME_SP_OFFSET 0
#endif

+#ifndef sframe_cfa_offset_decode
+static inline s32 sframe_cfa_offset_decode(s32 offset)
+{
+ return offset;
+}
+#define sframe_cfa_offset_decode sframe_cfa_offset_decode
+#endif
+
#ifndef sframe_init_reginfo
static inline void
sframe_init_reginfo(struct unwind_user_reginfo *reginfo, s32 offset)
diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c
index 45cd7380ac38..92f770fc21f6 100644
--- a/kernel/unwind/sframe.c
+++ b/kernel/unwind/sframe.c
@@ -226,6 +226,7 @@ static __always_inline int __read_fre(struct sframe_section *sec,

UNSAFE_GET_USER_INC(cfa_off, cur, offset_size, Efault);
offset_count--;
+ cfa_off = sframe_cfa_offset_decode(cfa_off);

ra_off = sec->ra_off;
if (!ra_off && offset_count) {
--
2.51.0