summaryrefslogtreecommitdiffstats
path: root/core/opal.c
Commit message (Collapse)AuthorAgeFilesLines
* core/opal: Allow poller re-entry if OPAL was re-enteredNicholas Piggin2018-04-181-4/+8
| | | | | | | | | | | | | | | If an NMI interrupts the middle of running pollers and the OS invokes pollers again (e.g., for console output), the poller re-entrancy check will prevent it from running and spam the console. That check was designed to catch a poller calling opal_run_pollers, OPAL re-entrancy is something different and is detected elsewhere. Avoid the poller recursion check if OPAL has been re-entered. This is a best-effort attempt to cope with errors. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* asm/head: implement quiescing without stack or clobbering regsNicholas Piggin2018-04-181-27/+14
| | | | | | | | | | | | | | | | | | | | | | | | Quiescing currently is implmeented in C in opal_entry before the opal call handler is called. This works well enough for simple cases like fast reset when one CPU wants all others out of the way. Linux would like to use it to prevent an sreset IPI from interrupting firmware, which could lead to deadlocks when crash dumping or entering the debugger. Linux interrupts do not recover well when returning back to general OPAL code, due to r13 not being restored. OPAL also can't be re-entered, which may happen e.g., from the debugger. So move the quiesce hold/reject to entry code, beore the stack or r1 or r13 registers are switched. OPAL can be interrupted and returned to or re-entered during this period. This does not completely solve all such problems. OPAL will be interrupted with sreset if the quiesce times out, and it can be interrupted by MCEs as well. These still have the issues above. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
* core/fast-reboot: disable fast reboot upon fundamental entry/exit/locking errorsNicholas Piggin2018-03-221-0/+2
| | | | | | | | This disables fast reboot in several more cases where serious errors like lock corruption or call re-entrancy are detected. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/opal: allow some re-entrant callsNicholas Piggin2018-03-221-3/+16
| | | | | | | | | | | | | | | This allows a small number of OPAL calls to succeed despite re-entering the firmware, and rejects others rather than aborting. This allows a system reset interrupt that interrupts OPAL to do something useful. Sreset other CPUs, use the console, which allows xmon to work or stack traces to be printed, reboot the system. Use OPAL_INTERNAL_ERROR when rejecting, rather than OPAL_BUSY, which is used for many other things that does not mean a serious permanent error. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/opal: abort in case of re-entrant OPAL callNicholas Piggin2018-03-221-1/+1
| | | | | | | | The stack is already destroyed by the time we get here, so there is not much point continuing. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* gcov: Add gcov data struct to sysfsMatt Brown2018-03-081-0/+4
| | | | | | | | | | | | Extracting the skiboot gcov data is currently a tedious process which involves taking a mem dump of skiboot and searching for the gcov_info struct. This patch adds the gcov struct to sysfs under /opal/exports. Allowing the data to be copied directly into userspace and processed. Signed-off-by: Matt Brown <matthew.brown.dev@gmail.com> [stewart: refactor to dump out whole skiboot area, as gcov data is all over] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core: Avoid possible uninitialized pointer read (CID 209502)Cyril Bur2018-01-301-1/+1
| | | | | | | | | A likely copy and paste oversight. Fixes: 0d84ea6b (core: Add support for quiescing OPAL) Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* SLW: Delay cpuidle device-tree creationAkshay Adiga2018-01-141-1/+0
| | | | | | | | | Create cpuidle device-tree after slw_init(), so that we can stop the deeper states from being added , when wakeup engine is not present or failed. Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* lock: Add additional lock auditing codeBenjamin Herrenschmidt2017-12-201-1/+7
| | | | | | | | | | | | | | | | | 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>
* Fix booting & OPAL call return values with DEBUG=1Stewart Smith2017-12-061-2/+3
| | | | | | | | | | | | | | | | | | On a debug build, _mcount would trash r3 and opal_exit_check would not restore it, leaving OPAL calls returning garbage. this fix simply preserves the return value and doesn't let the compiler get fancy on us. We effectively just get an extra `mr` instruction to restore r3. Fixes: 9c565ee6bca4b665d9d1120bfff5e88ee80615bc Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Suggested-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Tested-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core: Add support for quiescing OPALNicholas Piggin2017-12-031-3/+167
| | | | | | | | | | | | | | | | Quiescing is ensuring all host controlled CPUs (except the current one) are out of OPAL and prevented from entering. This can be use in debug and shutdown paths, particularly with system reset sequences. This patch adds per-CPU entry and exit tracking for OPAL calls, and adds logic to "hold" or "reject" at entry time, if OPAL is quiesced. An OPAL call is added, to expose the functionality to Linux, where it can be used for shutdown, kexec, and before generating sreset IPIs for debugging (so the debug code does not recurse into OPAL). Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/opal: always verify cpu->pir on entryNicholas Piggin2017-12-031-5/+7
| | | | | Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* asm/head: move opal entry token check into CNicholas Piggin2017-12-031-1/+6
| | | | | | | Move opal_check_token from asm to C. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* asm/head: add entry/exit callsNicholas Piggin2017-12-031-4/+23
| | | | | | | | | Add entry and exit C functions that can do some more complex checks before the opal proper call. This requires saving off volatile registers that have arguments in them. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Big log level reduction...Benjamin Herrenschmidt2017-06-261-2/+2
| | | | | | | | | | | | | 90% of what we print isn't useful to a normal user. This dramatically reduces the amount of messages printed by OPAL in normal circumstances. We still need to add a way to bump the log level at boot based on a BMC scratch register or some HDAT property. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* FSP: Notify FSP of Platform Log ID after Host Initiated Reset ReloadStewart Smith2017-05-101-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trigging a Host Initiated Reset (when the host detects the FSP has gone out to lunch and should be rebooted), would cause "Unknown Command" messages to appear in the OPAL log. This patch implements those messages How to trigger FSP RR(HIR): $ putmemproc 300000f8 0x00000000deadbeef s1 k0:n0:s0:p00 ecmd_ppc putmemproc 300000f8 0x00000000deadbeef Log showing unknown command: / # cat /sys/firmware/opal/msglog | grep -i ,3 [ 110.232114723,3] FSP: fsp_trigger_reset() entry [ 188.431793837,3] FSP #0: Link down, starting R&R [ 464.109239162,3] FSP #0: Got XUP with no pending message ! [ 466.340598554,3] FSP-DPO: Unknown command 0xce0900 [ 466.340600126,3] FSP: Unhandled message ce0900 The message we need to handle is "Get PLID after host initiated FipS reset/reload". When the FSP comes back from HIR, it asks "hey, so, which error log explains why you rebooted me?". So, we tell it. Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/init: Use '_' as separator in names of "exports" propertiesMichael Ellerman2017-04-051-2/+7
| | | | | | | | | | | | | | | | The names of the properties under /ibm,opal/firmware/exports are used directly by Linux to create files in sysfs. To remain consistent with the existing naming of OPAL sysfs files, use '_' as the separator. In particular for the symbol map which is already exported separately, it's cleaner for the two files to have the same name, eg: /sys/firmware/opal/exports/symbol_map /sys/firmware/opal/symbol_map Fixes: 9ffbfe269ec6 ("core/init: Add hdat-map property to OPAL node") Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/init: Add hdat-map property to OPAL nodeMatt Brown2017-03-241-0/+29
| | | | | | | | | | Exports the HDAT heap to the OS. This allows the OS to view the HDAT heap directly. This allows us to view the HDAT area without having to use getmemproc. Signed-off-by: Matt Brown <matthew.brown.dev@gmail.com> Reviewed-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/opal: check ibm,opal existsOliver O'Halloran2017-02-171-5/+1
| | | | | | | | | | | The ibm,opal node is normally created by Skiboot either in the HDAT parser or after the input FDT has been unflattened. However, in order to supply the /ibm,opal/power-mgt/enabled-stop-states property FDT we to tolerate /ibm,opal/ existing in the input tree. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Initial support for the ELFv2 ABINicholas Piggin2017-02-061-5/+3
| | | | | | | | | | | | Provide an experimental option to compile using ELFv2 ABI even on big endian builds. ELFv2 + BE is not officially supported by the toolchain, but it works quite well. It may be useful as a small step toward a little-endian build. This saves about 200kB of text/data. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* tree-wide: use dt_add_property_u64s() where we canOliver O'Halloran2016-12-211-3/+1
| | | | | | | | | | | | A few places (mostly old code) were using: add_property_cells(hi32(number), lo32(number)); This patch converts them to use the helper rather than doing it manually. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Limit number of "Poller recursion detected" errors to displayStewart Smith2016-11-241-1/+5
| | | | | | | | | | | | In some error conditions, we could spiral out of control on this and spend all of our time printing the exact same backtrace. Limit it to 16 times, because 16 is a nice number. Cc: stable Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core: Create event node to enable irqchipSam Mendoza-Jonas2016-09-221-0/+7
| | | | | | | | | This allows devices such as IPMI and serial consoles to use dynamic irq numbers and have separate irq numbers in Linux. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Use additional checks in skiboot for pointersBalbir Singh2016-08-171-0/+4
| | | | | | | | | | | The checks validate pointers sent in using opal_addr_valid() in opal_call API's provided via the console, cpu, fdt, flash, i2c, interrupts, nvram, opal-msg, opal, opal-pci, xscom and cec modules Signed-off-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* device-tree: Only advertise ibm, opal-v3 (not v2) on POWER9 and aboveStewart Smith2016-07-201-2/+7
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* core/opal.c: Add FWTS annotations for pollers and missing OPAL_CHECK_TOKENStewart Smith2016-06-271-2/+30
| | | | | | | | | | | | | | | For the missing OPAL_CHECK_TOKEN call, it means we catch kernel bugs in the firmware test suite, which I guess is a valid thing to do, if slightly odd. Unfortunately, kernels for POWER8 systems shipped with this (totally harmless) bug, so it's possible that if FWTS is run on older POWER8 PowerNV kernels, this warning will be hit. On POWER9 and above though, this warning should never be hit. The annotations for pollers should also never be hit, although I'm not convinced we don't have a spot or two in OPAL where this could still be the case (specifically, under certain error conditions). Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add fwts annotations for critical errorsStewart Smith2016-06-201-0/+5
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Fix sparse warnings in opal_trace_entry()Stewart Smith2015-11-091-5/+6
| | | | | | | | | Need to flip things appropriately for endian annotations No actual functional changes since skiboot is still BE, but we're a bit more explicit about the fact the ABI is BE. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Fixup sparse endian annotations for opal events and masksStewart Smith2015-11-091-2/+2
| | | | | | This fixes many spurious sparse warnings Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* slw: Move add_cpu_idle_state_properties() to add_opal_node()Shilpasri G Bhat2015-10-301-0/+1
| | | | | | | | | | | | | 05f52a8dd7c7e402896e049fd24f83d56b70aff4 core: Setup the OPAL DT node before platform probe add_cpu_idle_state_properties() was made local to slw.c in the above commit which caused p7 systems to not populate the nap idle state in DT. So moving add_cpu_idle_state_properties() to add_opal_node to fix this bug. Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Remove FIXME for using atomics for opal_pending_eventsStewart Smith2015-09-101-1/+0
| | | | | | | The locking code is obviously correct and it's never shown up in a profile - so it's likely fine for a while yet. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* remove FIXME from opal_trace_entryStewart Smith2015-09-101-1/+0
| | | | | | | | We unlikely need this as ASM until somebody finds it to be a problem. So removing the FIXME so that it doesn't show up when grepping for FIXMEs. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* fix potential integer overflow for giant cpu_max_pirStewart Smith2015-07-081-1/+1
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* OPAL: Validate before creating opal device tree nodeVasant Hegde2015-05-071-1/+5
| | | | | | | | | | | | | | On FSP based machine, attention LED location code is passed to OPAL via HDAT. We want to populate this information in device tree under led node, so that LED driver can use this information. Presently we are creating '/ibm,opal' node after parsing hdata information. This patch validates '/ibm,opal' node before creating. So on FSP based machine we can create this node in hdata itself without breaking. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Remove redundant includes of opal-api.hMichael Ellerman2015-04-011-1/+0
| | | | | | | | Now that opal.h includes opal-api.h, there are a bunch of files that include both but don't need to. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* OPAL: Detect recursive poller entry from same CPUVasant Hegde2015-03-191-0/+11
| | | | | | | Detect recursive opal poller call from same CPU. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Limit number of warnings of pollers run with lock heldStewart Smith2015-02-181-1/+6
| | | | | | | | Otherwise we pretty much spin in printing backtraces on some machines. A limit of 64 per boot is likely to give us enough bugs to fix. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Warn when pollers are called with a lock heldBenjamin Herrenschmidt2015-02-181-0/+5
| | | | | | | So we can start fixing those cases Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Move skiboot internal things from opal.h to opal-api.hStewart Smith2015-02-061-0/+1
| | | | | | | | | | This is probably not the best collection of things in the world, but it means that opal.h is much closer to being directly usable by an OS. This triggers a bunch of #include fixes throughout the tree. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* opal: Don't put the symbol map whole into a propertyBenjamin Herrenschmidt2014-12-051-3/+5
| | | | | | | | | | The huge property trips a bug in some versions of kexec, and it generally makes looking at the device-tree more painful than it has to be. Instead, let's just pass the address & size and we'll add a debugfs file on the Linux side to recover them. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Merge remote-tracking branch 'ltcgit/master'Benjamin Herrenschmidt2014-11-221-1/+1
|\
| * Implement skiboot versioningStewart Smith2014-11-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We grab a version from git tags (or SKIBOOT_VERSION environment variable), optionally tack on EXTRA_VERSION (if from git) as well as add things to the git version number if we're ahead of the most recent tag or the tree is dirty. Also fix-up makefiles so that we don't have to rebuild version.c every time you run make. fsp attn area needed updating as we can have >40 character version strings. We also export the version string via device tree rather than just the gitid. For buildroot builds, setting SKIBOOT_VERSION environment variable to the tag you grab will do the correct thing. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* | Add symbolic backtraces and expose skiboot map to LinuxBenjamin Herrenschmidt2014-11-181-0/+2
| | | | | | | | | | | | | | 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>
* | Stack checking extensionsBenjamin Herrenschmidt2014-11-171-0/+3
|/ | | | | | | | | | | | This patch adds: - Normal builds are done with -fstack-protector (we want to investigate using -fstack-protector-strong on gcc4.9 but for now we just use that - Build with STACK_CHECK=1 will use -fstack-protector-all and -pg and will check the stack in mcount Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* timer: Only check "poll" timers on actual poll, not any interruptBenjamin Herrenschmidt2014-11-121-1/+1
| | | | | | | | Due to the lack of SLW timed interrupt support, we take the opportunity to check out timers on any incoming interrupt. However we really don't want to do that for the background pollers. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* timer: Add scheduled timer facilityBenjamin Herrenschmidt2014-11-071-0/+4
| | | | | | | For now running off the event pollers, that will improve once we get delayed interrupts from the SLW Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* opal: Add facility for dynamic event bitsJeremy Kerr2014-10-301-1/+39
| | | | | | | | We steal opal_update_pending_evt's lock for protecting the allocated dynamic event mask. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* irq/occ/opal: Add self-sent dummy interruptBenjamin Herrenschmidt2014-10-241-3/+18
| | | | | | | | | | | | | This makes OPAL use the OCC interrupt facility to send itself an interrupt whenever the OPAL event bit is set as a result of an OPAL call that wasn't itself opal_handle_interrupt() or opal_handle_hmi() (both of which we know the OS will already deal with appropriately). This ensures that OPAL event changes are notified to Linux via its interrupt path which is necessary for it to properly broadcast the state change to its various clients. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
* opal_del_caller shouldn't be called: up severity level, change message.Stewart Smith2014-10-151-1/+2
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Make assert(false) for calling attn be a PR_EMERG level errorStewart Smith2014-10-151-1/+1
| | | | | | | When we do something so severe we're asserting... we want that to be in the log! Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
OpenPOWER on IntegriCloud