[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250710163522.3195293-17-jremus@linux.ibm.com>
Date: Thu, 10 Jul 2025 18:35:22 +0200
From: Jens Remus <jremus@...ux.ibm.com>
To: linux-kernel@...r.kernel.org, linux-trace-kernel@...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>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...nel.org>,
Jiri Olsa <jolsa@...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>,
Jens Axboe <axboe@...nel.dk>, Florian Weimer <fweimer@...hat.com>,
Sam James <sam@...too.org>
Subject: [RFC PATCH v1 16/16] WIP: fixup! s390/unwind_user/sframe: Enable HAVE_UNWIND_USER_SFRAME
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 <jremus@...ux.ibm.com>
---
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
Powered by blists - more mailing lists