aboutsummaryrefslogtreecommitdiff
path: root/core/stack.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-26SPDX-ify all skiboot codeStewart Smith1-14/+4
Use Software Package Data Exchange (SPDX) to indicate license for each file that is unique to skiboot. At the same time, ensure the (C) who and years are correct. See https://spdx.org/ Signed-off-by: Stewart Smith <stewart@linux.ibm.com> [oliver: Added a few missing files] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
2019-06-13sparse: fix bt_lock should be staticStewart Smith1-1/+1
Fix this sparse warning: core/stack.c:123:13: warning: symbol 'bt_lock' was not declared. Should it be static? Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-03-28core/stack: Rename backtrace functions, get rid of wrappersAndrew Donnellan1-6/+7
Rename ___backtrace() to backtrace_create() and ___print_backtrace() to backtrace_print(). Get rid of __backtrace() and __print_backtrace() wrappers. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-03-28core/stack: Convert stack check code to not use backtrace wrapperAndrew Donnellan1-5/+5
We're about to get rid of __backtrace() and __print_backtrace(), convert the stack check code to not use them. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-03-28core/stack: Store PIR in ___backtrace()Andrew Donnellan1-3/+3
In ___backtrace(), store the current PIR in the metadata struct, rather than relying on the caller to do it. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-03-28core/stack: Define a backtrace metadata structAndrew Donnellan1-27/+26
Every time we take a backtrace, we have to store the number of entries, the OPAL API token, r1 caller and PIR values. Rather than defining these and passing them around all over the place, let's throw them in a struct. Define a struct, struct bt_metadata, to store these details, and convert ___backtrace() and ___print_backtrace() to use it. We change the wrapper functions __backtrace() and __print_backtrace() to call ___backtrace()/___print_backtrace() with struct bt_metadata, but don't change their parameter profiles for now - we'll do that later. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2019-03-28core/stack: Remove r1 argument from ___backtrace()Andrew Donnellan1-4/+2
___backtrace() is always called with r1 = __builtin_frame_address(0), and it's unlikely we're going to need it to do something else any time soon, so simplify the API by removing the parameter. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-09-20skiboot.lds.S: move read-write data after the end of symbol mapNicholas Piggin1-2/+0
This also tidies up linker script symbol declarations and adds _rodata_mem symbol for the next change to use. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-18core/opal: Emergency stack for re-entryNicholas Piggin1-2/+11
This detects OPAL being re-entered by the OS, and switches to an emergency stack if it was. This protects the firmware's main stack from re-entrancy and allows the OS to use NMI facilities for crash / debug functionality. Further nested re-entry will destroy the previous emergency stack and prevent returning, but those should be rare cases. This stack is sized at 16kB, which doubles the size of CPU stacks, so as not to introduce a regression in primary stack size. The 16kB stack originally had a 4kB machine check stack at the top, which was removed by 80eee1946 ("opal: Remove machine check interrupt patching in OPAL."). So it is possible the size could be tightened again, but that would require further analysis. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
2018-04-18core/stack: backtrace unwind basic OPAL call detailsNicholas Piggin1-7/+26
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>
2018-02-08core/utils: add snprintf_symbolNicholas Piggin1-13/+4
get_symbol is difficult to use. Add snprintf_symbol helper which prints a symbol into a buffer with length, and returns the number of bytes used, similarly to snprintf. Use this in the stack dumping code rather than open-coding it. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-12-20lock: Add additional lock auditing codeBenjamin Herrenschmidt1-0/+1
Keep track of lock owner name and replace lock_depth counter with a per-cpu list of locks held by the cpu. This allows us to print the actual locks held in case we hit the (in)famous message about opal_pollers being run with a lock held. It also allows us to warn (and drop them) if locks are still held when returning to the OS or completing a scheduled job. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> [stewart: fix unit tests] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-07-25core/backtrace: Serialise printing backtracesOliver O'Halloran1-0/+12
Add a lock so that only one thread can print a backtrace at a time. This should prevent multiple threads from garbaling each other's backtraces. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-12-22stack: Don't recurse into __stack_chk_failBenjamin Herrenschmidt1-2/+7
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-03-30core: Fix backtrace for gcc 6Joel Stanley1-2/+2
GCC 6 warns when we look at any stack frame other than our own, ie any argument to __builtin_frame_address other than zero. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-03-04Fix early backtracesRyan Grimm1-1/+6
If we fail an assert() before we add a mem region, such as missing chip-id in a dt xscom node, we don't get a backtrace: [836883,0] Assert fail: core/device.c:870:id != 0xffffffff [848859,0] Aborting! CPU 0000 Backtrace: This patch adjusts the top_of_ram value compared to the fp stack frame to assume one stack early on so we get a backtrace: [440546,0] Assert fail: core/device.c:822:id != 0xffffffff [452522,0] Aborting! CPU 0000 Backtrace: S: 0000000031c03b70 R: 00000000300135d0 .backtrace+0x24 S: 0000000031c03bf0 R: 0000000030017f38 ._abort+0x4c S: 0000000031c03c70 R: 0000000030017fb4 .assert_fail+0x34 S: 0000000031c03cf0 R: 0000000030021830 .dt_get_chip_id+0x24 S: 0000000031c03d60 R: 00000000300143cc .init_chips+0x23c S: 0000000031c03e30 R: 0000000030013ab8 .main_cpu_entry+0x110 S: 0000000031c03f00 R: 000000003000254c boot_entry+0x19c Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-11Don't try to print symbol when we didn't find oneStewart Smith1-1/+3
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-18Add symbolic backtraces and expose skiboot map to LinuxBenjamin Herrenschmidt1-23/+28
We use a double link technique, doing a first pass with a .o containing a dummy symbol map, then re-linking with a new .o Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-18Fix backtracesBenjamin Herrenschmidt1-15/+18
__builtin_frame_address really wants constants Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-18Capture backtraces when measuring stack depthBenjamin Herrenschmidt1-13/+24
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-11-18Rename backtrace.c to stack.c and move stack related bitsBenjamin Herrenschmidt1-0/+184
... from util.c to stack.c Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>