[RFC PATCH v1 16/16] WIP: fixup! s390/unwind_user/sframe: Enable HAVE_UNWIND_USER_SFRAME
From: Jens Remus <hidden>
Date: 2025-07-10 16:36:13
Also in:
bpf, lkml
Subsystem:
s390 architecture, the rest, userspace stack unwinding · Maintainers:
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Linus Torvalds, Josh Poimboeuf, Steven Rostedt
Add s390-specific SFrame format definitions. Note that SFRAME_ABI_*
(and thus SFRAME_ABI_S390_ENDIAN_BIG) is currently unused.
Include <asm/unwind_user_sframe.h> after "sframe.h" to make those
s390-specific definitions available to architecture-specific unwind
user sframe code, particularly the s390-specific one.
Use the s390-specific definitions in the s390-specific unwind user
sframe code to get rid of all the magic numbers.
Signed-off-by: Jens Remus <redacted>
---
Notes (jremus):
Alternatively the s390-specific definitions could also be added to the
s390-specific unwind user sframe header. The current implementation
follows Binutils approach to have all SFrame format definitions in one
central header file.
arch/s390/include/asm/unwind_user_sframe.h | 8 ++++----
kernel/unwind/sframe.c | 2 +-
kernel/unwind/sframe.h | 16 ++++++++++++++++
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/arch/s390/include/asm/unwind_user_sframe.h b/arch/s390/include/asm/unwind_user_sframe.h
index 2216e6921fd8..e5139cc2ba5a 100644
--- a/arch/s390/include/asm/unwind_user_sframe.h
+++ b/arch/s390/include/asm/unwind_user_sframe.h@@ -7,16 +7,16 @@ static inline s32 arch_sframe_cfa_offset_decode(s32 offset) { - return (offset << 3) + 160; + return SFRAME_V2_S390X_CFA_OFFSET_DECODE(offset); } static inline void arch_sframe_set_frame_reginfo( struct unwind_user_reginfo *reginfo, s32 offset) { - if (offset & 1) { + if (SFRAME_V2_S390X_OFFSET_IS_REGNUM(offset)) { reginfo->loc = UNWIND_USER_LOC_REG; - reginfo->regnum = offset >> 1; + reginfo->regnum = SFRAME_V2_S390X_OFFSET_DECODE_REGNUM(offset); } else if (offset) { reginfo->loc = UNWIND_USER_LOC_STACK; reginfo->frame_off = offset;
@@ -27,7 +27,7 @@ static inline void arch_sframe_set_frame_reginfo( static inline s32 arch_sframe_sp_val_off(void) { - return -160; + return SFRAME_S390X_SP_VAL_OFFSET; } #define sframe_cfa_offset_decode arch_sframe_cfa_offset_decode
diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c
index e8658401a286..cd82de310c58 100644
--- a/kernel/unwind/sframe.c
+++ b/kernel/unwind/sframe.c@@ -12,11 +12,11 @@ #include <linux/mm.h> #include <linux/string_helpers.h> #include <linux/sframe.h> -#include <asm/unwind_user_sframe.h> #include <linux/unwind_user_types.h> #include "sframe.h" #include "sframe_debug.h" +#include <asm/unwind_user_sframe.h> struct sframe_fre { unsigned int size;
diff --git a/kernel/unwind/sframe.h b/kernel/unwind/sframe.h
index e9bfccfaf5b4..3e60b6e30b51 100644
--- a/kernel/unwind/sframe.h
+++ b/kernel/unwind/sframe.h@@ -17,6 +17,7 @@ #define SFRAME_ABI_AARCH64_ENDIAN_BIG 1 #define SFRAME_ABI_AARCH64_ENDIAN_LITTLE 2 #define SFRAME_ABI_AMD64_ENDIAN_LITTLE 3 +#define SFRAME_ABI_S390X_ENDIAN_BIG 4 /* s390 64-bit (s390x) */ #define SFRAME_FDE_TYPE_PCINC 0 #define SFRAME_FDE_TYPE_PCMASK 1
@@ -68,4 +69,19 @@ struct sframe_fde { #define SFRAME_FRE_OFFSET_SIZE(data) ((data >> 5) & 0x3) #define SFRAME_FRE_MANGLED_RA_P(data) ((data >> 7) & 0x1) +/* s390 64-bit (s390x) */ + +#define SFRAME_S390X_SP_VAL_OFFSET (-160) + +#define SFRAME_S390X_CFA_OFFSET_ADJUSTMENT SFRAME_S390X_SP_VAL_OFFSET +#define SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR 8 +#define SFRAME_V2_S390X_CFA_OFFSET_DECODE(offset) \ + (((offset) * SFRAME_S390X_CFA_OFFSET_ALIGNMENT_FACTOR) \ + - SFRAME_S390X_CFA_OFFSET_ADJUSTMENT) + +#define SFRAME_V2_S390X_OFFSET_IS_REGNUM(offset) \ + ((offset) & 1) +#define SFRAME_V2_S390X_OFFSET_DECODE_REGNUM(offset) \ + ((offset) >> 1) + #endif /* _SFRAME_H */
--
2.48.1