From 3384f135e90f96a7697a85c33081e46c0a0f415d Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Mon, 23 May 2022 14:42:40 +0200 Subject: s390: generate register offsets into pt_regs automatically Use asm offsets method to generate register offsets into pt_regs, instead of open-coding at several places. Reviewed-by: Alexander Gordeev Signed-off-by: Heiko Carstens --- arch/s390/kernel/asm-offsets.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'arch/s390/kernel/asm-offsets.c') diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index 7c74f0e17e5a..1e37cad44561 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -32,6 +32,22 @@ int main(void) /* pt_regs offsets */ OFFSET(__PT_PSW, pt_regs, psw); OFFSET(__PT_GPRS, pt_regs, gprs); + OFFSET(__PT_R0, pt_regs, gprs[0]); + OFFSET(__PT_R1, pt_regs, gprs[1]); + OFFSET(__PT_R2, pt_regs, gprs[2]); + OFFSET(__PT_R3, pt_regs, gprs[3]); + OFFSET(__PT_R4, pt_regs, gprs[4]); + OFFSET(__PT_R5, pt_regs, gprs[5]); + OFFSET(__PT_R6, pt_regs, gprs[6]); + OFFSET(__PT_R7, pt_regs, gprs[7]); + OFFSET(__PT_R8, pt_regs, gprs[8]); + OFFSET(__PT_R9, pt_regs, gprs[9]); + OFFSET(__PT_R10, pt_regs, gprs[10]); + OFFSET(__PT_R11, pt_regs, gprs[11]); + OFFSET(__PT_R12, pt_regs, gprs[12]); + OFFSET(__PT_R13, pt_regs, gprs[13]); + OFFSET(__PT_R14, pt_regs, gprs[14]); + OFFSET(__PT_R15, pt_regs, gprs[15]); OFFSET(__PT_ORIG_GPR2, pt_regs, orig_gpr2); OFFSET(__PT_FLAGS, pt_regs, flags); OFFSET(__PT_CR1, pt_regs, cr1); -- cgit v1.2.3 From f037acb41dc9fc0f00521685b3250226d6f9b437 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Mon, 30 May 2022 14:09:24 +0200 Subject: s390/stack: merge empty stack frame slots Merge empty1 and empty2 arrays within the stack frame to one single array. This is possible since with commit 42b01a553a56 ("s390: always use the packed stack layout") the alternative stack frame layout is gone. Reviewed-by: Nico Boehr Reviewed-by: Alexander Gordeev Signed-off-by: Heiko Carstens --- arch/s390/include/asm/stacktrace.h | 3 +-- arch/s390/kernel/asm-offsets.c | 10 +++++----- arch/s390/kernel/perf_event.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'arch/s390/kernel/asm-offsets.c') diff --git a/arch/s390/include/asm/stacktrace.h b/arch/s390/include/asm/stacktrace.h index f8500191993d..7e0e15bee18d 100644 --- a/arch/s390/include/asm/stacktrace.h +++ b/arch/s390/include/asm/stacktrace.h @@ -39,8 +39,7 @@ static inline bool on_stack(struct stack_info *info, * Kernel uses the packed stack layout (-mpacked-stack). */ struct stack_frame { - unsigned long empty1[5]; - unsigned int empty2[8]; + unsigned long empty[9]; unsigned long gprs[10]; unsigned long back_chain; }; diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index 1e37cad44561..0e10d7ff4203 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -57,11 +57,11 @@ int main(void) /* stack_frame offsets */ OFFSET(__SF_BACKCHAIN, stack_frame, back_chain); OFFSET(__SF_GPRS, stack_frame, gprs); - OFFSET(__SF_EMPTY, stack_frame, empty1[0]); - OFFSET(__SF_SIE_CONTROL, stack_frame, empty1[1]); - OFFSET(__SF_SIE_SAVEAREA, stack_frame, empty1[2]); - OFFSET(__SF_SIE_REASON, stack_frame, empty1[3]); - OFFSET(__SF_SIE_FLAGS, stack_frame, empty1[4]); + OFFSET(__SF_EMPTY, stack_frame, empty[0]); + OFFSET(__SF_SIE_CONTROL, stack_frame, empty[1]); + OFFSET(__SF_SIE_SAVEAREA, stack_frame, empty[2]); + OFFSET(__SF_SIE_REASON, stack_frame, empty[3]); + OFFSET(__SF_SIE_FLAGS, stack_frame, empty[4]); DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame)); BLANK(); /* idle data offsets */ diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c index a7f8db73984b..e259ff1f5ad3 100644 --- a/arch/s390/kernel/perf_event.c +++ b/arch/s390/kernel/perf_event.c @@ -30,7 +30,7 @@ static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs) if (!stack) return NULL; - return (struct kvm_s390_sie_block *)stack->empty1[1]; + return (struct kvm_s390_sie_block *)stack->empty[1]; } static bool is_in_guest(struct pt_regs *regs) -- cgit v1.2.3 From e0ffcf3fe18e0310221461c08969edec2cc7628c Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Mon, 30 May 2022 14:20:50 +0200 Subject: s390/stack: add union to reflect kvm stack slot usages Add a union which describes how the empty stack slots are being used by kvm and perf. This should help to avoid another bug like the one which was fixed with commit c9bfb460c3e4 ("s390/perf: obtain sie_block from the right address"). Reviewed-by: Nico Boehr Tested-by: Nico Boehr Signed-off-by: Heiko Carstens --- arch/s390/include/asm/stacktrace.h | 10 +++++++++- arch/s390/kernel/asm-offsets.c | 8 ++++---- arch/s390/kernel/perf_event.c | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'arch/s390/kernel/asm-offsets.c') diff --git a/arch/s390/include/asm/stacktrace.h b/arch/s390/include/asm/stacktrace.h index 7e0e15bee18d..b23c658dce77 100644 --- a/arch/s390/include/asm/stacktrace.h +++ b/arch/s390/include/asm/stacktrace.h @@ -39,7 +39,15 @@ static inline bool on_stack(struct stack_info *info, * Kernel uses the packed stack layout (-mpacked-stack). */ struct stack_frame { - unsigned long empty[9]; + union { + unsigned long empty[9]; + struct { + unsigned long sie_control_block; + unsigned long sie_savearea; + unsigned long sie_reason; + unsigned long sie_flags; + }; + }; unsigned long gprs[10]; unsigned long back_chain; }; diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index 0e10d7ff4203..d8ce965c0a97 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -58,10 +58,10 @@ int main(void) OFFSET(__SF_BACKCHAIN, stack_frame, back_chain); OFFSET(__SF_GPRS, stack_frame, gprs); OFFSET(__SF_EMPTY, stack_frame, empty[0]); - OFFSET(__SF_SIE_CONTROL, stack_frame, empty[1]); - OFFSET(__SF_SIE_SAVEAREA, stack_frame, empty[2]); - OFFSET(__SF_SIE_REASON, stack_frame, empty[3]); - OFFSET(__SF_SIE_FLAGS, stack_frame, empty[4]); + OFFSET(__SF_SIE_CONTROL, stack_frame, sie_control_block); + OFFSET(__SF_SIE_SAVEAREA, stack_frame, sie_savearea); + OFFSET(__SF_SIE_REASON, stack_frame, sie_reason); + OFFSET(__SF_SIE_FLAGS, stack_frame, sie_flags); DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame)); BLANK(); /* idle data offsets */ diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c index e259ff1f5ad3..c27321cb0969 100644 --- a/arch/s390/kernel/perf_event.c +++ b/arch/s390/kernel/perf_event.c @@ -30,7 +30,7 @@ static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs) if (!stack) return NULL; - return (struct kvm_s390_sie_block *)stack->empty[1]; + return (struct kvm_s390_sie_block *)stack->sie_control_block; } static bool is_in_guest(struct pt_regs *regs) -- cgit v1.2.3