summaryrefslogtreecommitdiffstats
path: root/core/stack.c
Commit message (Collapse)AuthorAgeFilesLines
* core/stack: Rename backtrace functions, get rid of wrappersAndrew Donnellan2019-03-281-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>
* core/stack: Convert stack check code to not use backtrace wrapperAndrew Donnellan2019-03-281-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>
* core/stack: Store PIR in ___backtrace()Andrew Donnellan2019-03-281-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>
* core/stack: Define a backtrace metadata structAndrew Donnellan2019-03-281-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>
* core/stack: Remove r1 argument from ___backtrace()Andrew Donnellan2019-03-281-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>
* skiboot.lds.S: move read-write data after the end of symbol mapNicholas Piggin2018-09-201-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>
* core/opal: Emergency stack for re-entryNicholas Piggin2018-04-181-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>
* core/stack: backtrace unwind basic OPAL call detailsNicholas Piggin2018-04-181-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>
* core/utils: add snprintf_symbolNicholas Piggin2018-02-081-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>
* lock: Add additional lock auditing codeBenjamin Herrenschmidt2017-12-201-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>
* core/backtrace: Serialise printing backtracesOliver O'Halloran2017-07-251-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>
* stack: Don't recurse into __stack_chk_failBenjamin Herrenschmidt2016-12-221-2/+7
| | | | | Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core: Fix backtrace for gcc 6Joel Stanley2016-03-301-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>
* Fix early backtracesRyan Grimm2016-03-041-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>
* Don't try to print symbol when we didn't find oneStewart Smith2015-08-111-1/+3
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add symbolic backtraces and expose skiboot map to LinuxBenjamin Herrenschmidt2014-11-181-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>
* Fix backtracesBenjamin Herrenschmidt2014-11-181-15/+18
| | | | | | __builtin_frame_address really wants constants Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* Capture backtraces when measuring stack depthBenjamin Herrenschmidt2014-11-181-13/+24
| | | | Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* Rename backtrace.c to stack.c and move stack related bitsBenjamin Herrenschmidt2014-11-181-0/+184
... from util.c to stack.c Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
OpenPOWER on IntegriCloud