aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-04-08 16:49:36 +1000
committerStewart Smith <stewart@linux.ibm.com>2018-04-18 20:23:07 -0500
commitad0941960bd045644f6834d6e711bedbde3c29c8 (patch)
treefd9ce3232321c2a2e531252ed456dc9616cf2eb8 /include
parentc4fd54bf413e74146e74ed173b358b88f25ece3d (diff)
downloadskiboot-ad0941960bd045644f6834d6e711bedbde3c29c8.zip
skiboot-ad0941960bd045644f6834d6e711bedbde3c29c8.tar.gz
skiboot-ad0941960bd045644f6834d6e711bedbde3c29c8.tar.bz2
core/stack: backtrace unwind basic OPAL call details
Put OPAL callers' r1 into the stack back chain, and then use that to unwind back to the OPAL entry frame (as opposed to boot entry, which has a 0 back chain). >From there, dump the OPAL call token and the caller's r1. A backtrace looks like this: CPU 0000 Backtrace: S: 0000000031c03ba0 R: 000000003001a548 ._abort+0x4c S: 0000000031c03c20 R: 000000003001baac .opal_run_pollers+0x3c S: 0000000031c03ca0 R: 000000003001bcbc .opal_poll_events+0xc4 S: 0000000031c03d20 R: 00000000300051dc opal_entry+0x12c --- OPAL call entry token: 0xa caller R1: 0xc0000000006d3b90 --- This is pretty basic for the moment, but it does give you the bottom of the Linux stack. It will allow some interesting improvements in future. First, with the eframe, all the call's parameters can be printed out as well. The ___backtrace / ___print_backtrace API needs to be reworked in order to support this, but it's otherwise very simple (see opal_trace_entry()). Second, it will allow Linux's stack to be passed back to Linux via a debugging opal call. This will allow Linux's BUG() or xmon to also print the Linux back trace in case of a NMI or MCE or watchdog lockup that hits in OPAL. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'include')
-rw-r--r--include/stack.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/include/stack.h b/include/stack.h
index df08ac1..4d3e504 100644
--- a/include/stack.h
+++ b/include/stack.h
@@ -49,6 +49,7 @@
#ifndef __ASSEMBLY__
#include <stdint.h>
+#include <opal-api.h>
/* This is the struct used to save GPRs etc.. on OPAL entry
* and from some exceptions. It is not always entirely populated
@@ -108,13 +109,31 @@ struct bt_entry {
extern void *boot_stack_top;
/* Create a backtrace */
-extern void __backtrace(struct bt_entry *entries, unsigned int *count);
+void ___backtrace(struct bt_entry *entries, unsigned int *count,
+ unsigned long r1,
+ unsigned long *token, unsigned long *r1_caller);
+static inline void __backtrace(struct bt_entry *entries, unsigned int *count)
+{
+ unsigned long token, r1_caller;
+
+ ___backtrace(entries, count,
+ (unsigned long)__builtin_frame_address(0),
+ &token, &r1_caller);
+}
/* Convert a backtrace to ASCII */
-extern void __print_backtrace(unsigned int pir, struct bt_entry *entries,
- unsigned int count, char *out_buf,
+extern void ___print_backtrace(unsigned int pir, struct bt_entry *entries,
+ unsigned int count, unsigned long token,
+ unsigned long r1_caller, char *out_buf,
unsigned int *len, bool symbols);
+static inline void __print_backtrace(unsigned int pir, struct bt_entry *entries,
+ unsigned int count, char *out_buf,
+ unsigned int *len, bool symbols)
+{
+ ___print_backtrace(pir, entries, count, OPAL_LAST + 1, 0, out_buf, len, symbols);
+}
+
/* For use by debug code, create and print backtrace, uses a static buffer */
extern void backtrace(void);