3 * Copyright IBM Corp. 2005
4 * Author(s): Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
7 #include <linux/oprofile.h>
9 #include <asm/processor.h> /* for struct stack_frame */
12 __show_trace(unsigned int *depth
, unsigned long sp
,
13 unsigned long low
, unsigned long high
)
15 struct stack_frame
*sf
;
19 sp
= sp
& PSW_ADDR_INSN
;
20 if (sp
< low
|| sp
> high
- sizeof(*sf
))
22 sf
= (struct stack_frame
*) sp
;
24 oprofile_add_trace(sf
->gprs
[8] & PSW_ADDR_INSN
);
26 /* Follow the backchain. */
29 sp
= sf
->back_chain
& PSW_ADDR_INSN
;
32 if (sp
<= low
|| sp
> high
- sizeof(*sf
))
34 sf
= (struct stack_frame
*) sp
;
36 oprofile_add_trace(sf
->gprs
[8] & PSW_ADDR_INSN
);
43 /* Zero backchain detected, check for interrupt frame. */
44 sp
= (unsigned long) (sf
+ 1);
45 if (sp
<= low
|| sp
> high
- sizeof(*regs
))
47 regs
= (struct pt_regs
*) sp
;
49 oprofile_add_trace(sf
->gprs
[8] & PSW_ADDR_INSN
);
56 void s390_backtrace(struct pt_regs
* const regs
, unsigned int depth
)
59 struct stack_frame
* head_sf
;
64 head
= regs
->gprs
[15];
65 head_sf
= (struct stack_frame
*)head
;
67 if (!head_sf
->back_chain
)
70 head
= head_sf
->back_chain
;
72 head
= __show_trace(&depth
, head
, S390_lowcore
.async_stack
- ASYNC_SIZE
,
73 S390_lowcore
.async_stack
);
75 __show_trace(&depth
, head
, S390_lowcore
.thread_info
,
76 S390_lowcore
.thread_info
+ THREAD_SIZE
);