Skip to content

Commit e0ffcf3

Browse files
committed
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 c9bfb46 ("s390/perf: obtain sie_block from the right address"). Reviewed-by: Nico Boehr <[email protected]> Tested-by: Nico Boehr <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent f037acb commit e0ffcf3

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

arch/s390/include/asm/stacktrace.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ static inline bool on_stack(struct stack_info *info,
3939
* Kernel uses the packed stack layout (-mpacked-stack).
4040
*/
4141
struct stack_frame {
42-
unsigned long empty[9];
42+
union {
43+
unsigned long empty[9];
44+
struct {
45+
unsigned long sie_control_block;
46+
unsigned long sie_savearea;
47+
unsigned long sie_reason;
48+
unsigned long sie_flags;
49+
};
50+
};
4351
unsigned long gprs[10];
4452
unsigned long back_chain;
4553
};

arch/s390/kernel/asm-offsets.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ int main(void)
5858
OFFSET(__SF_BACKCHAIN, stack_frame, back_chain);
5959
OFFSET(__SF_GPRS, stack_frame, gprs);
6060
OFFSET(__SF_EMPTY, stack_frame, empty[0]);
61-
OFFSET(__SF_SIE_CONTROL, stack_frame, empty[1]);
62-
OFFSET(__SF_SIE_SAVEAREA, stack_frame, empty[2]);
63-
OFFSET(__SF_SIE_REASON, stack_frame, empty[3]);
64-
OFFSET(__SF_SIE_FLAGS, stack_frame, empty[4]);
61+
OFFSET(__SF_SIE_CONTROL, stack_frame, sie_control_block);
62+
OFFSET(__SF_SIE_SAVEAREA, stack_frame, sie_savearea);
63+
OFFSET(__SF_SIE_REASON, stack_frame, sie_reason);
64+
OFFSET(__SF_SIE_FLAGS, stack_frame, sie_flags);
6565
DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame));
6666
BLANK();
6767
/* idle data offsets */

arch/s390/kernel/perf_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
3030
if (!stack)
3131
return NULL;
3232

33-
return (struct kvm_s390_sie_block *)stack->empty[1];
33+
return (struct kvm_s390_sie_block *)stack->sie_control_block;
3434
}
3535

3636
static bool is_in_guest(struct pt_regs *regs)

0 commit comments

Comments
 (0)