summaryrefslogtreecommitdiff
path: root/common/panic_output.c
Commit message (Collapse)AuthorAgeFilesLines
* panic: Tidy up the #ifdefsSimon Glass2021-02-101-12/+11
| | | | | | | | | | | | | | | | Move the common code into a separate function. Add comments to the nesting. Use IS_ENABLED() where possible and drop the outer #ifdef around the C code, since the linker will throw it away automatically if it is not called. BUG=b:177604307 BRANCH=none TEST=verified no code-size change on volteer Change-Id: I61065d37fb6267097a2078493a4edfcdeea23819 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686248 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: Add support for panic outputJack Rosenthal2021-01-261-2/+31
| | | | | | | | | | | | | | | Add basic panic implementation for Zephyr. Not using any fancy shared or always-on memory for now ... need to resolve how that will be handled later. BUG=b:178011288 BRANCH=none TEST=run various crash commands on volteer, observe output Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia1ce386f738283a2a2b9b60ef7e0bf97f8317837 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2645687
* crash: fix unsigned div-by-zero crashEric Yilun Lin2021-01-111-1/+1
| | | | | | | | | | | | | The bug was introduced in chromium:1834603 BUG=chromium:984041 TEST=ensure crash udivzero is triggered BRANCH=none Change-Id: I83d7465d1bbe41976c78c7d298abdafd3670e8cd Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2620725 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* common/panic_output: Use newly introduced functions for panic info dumpPatryk Duda2020-10-011-9/+27
| | | | | | | | | | | | | | | | This patch adds use of function that provides pointer to the beginning of panic data in panic info host command. It also adds use of panic_get_data() in panicinfo command to get pointer that can be safely dereferenced. BUG=b:165773837, b:162254118 BRANCH=none TEST=make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I403300f796fc2add4fae06728d7da4e43616ef2d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379847 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Introduce functions that provide safe pointer to panic dataPatryk Duda2020-09-091-1/+111
| | | | | | | | | | | | | | | | | | | | | | panic_get_data() function should always return pointer to panic_data structure that can be safely interpreted. When structure layout left by previous EC is different than ours then panic_get_data() should return NULL. Difference in layout can occur when we are jumping from old RO, this happens in eve. Introduce two new functions: get_panic_data_start() - It can be used to obtain beginning of panic data, eg. when copying raw data or when determining where jump data is. get_panic_data_write() - It can be used to obtain pointer to panic_data structure that can be safely written. This function moves jump data and jump tags if necessary. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: If5f73c86e2176a0169b0be4b890e399c2c259740 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379845 Reviewed-by: Jett Rink <jettrink@chromium.org>
* servo: Adds logging of panic info to USB consoleBrian J. Nemec2020-01-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | There is a console command to log the panic info data to the UART console. This change modifies it so after printing data to UART, it will also pass it to the USB console so the data can be easily logged by servod. BUG=chromium:1018008 BRANCH=servo TEST=Manual testing on Sweetberry, ServoV4, and ServoMicro 1) Unplug device to clean panic info, plug device in to USB 2) Request 'panicinfo' from the console interface 3) Response 'No saved panic data available.' 4) Trigger crash using commands like 'sysjump 0x100' or 'crash assert' 5) Reconnect console 6) Request 'panicinfo'. Fault registers are returned over USB console and UART console. The values match the correct addresses which is easily verified in the sysjump case. Change-Id: I5b0bb102296f5fcc967519bb3a59af49644e6f4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1880579 Tested-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
* Remove uses of %lEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | This change removes uses of %l from the EC side of the EC codebase. This is done because the semantics of %l within printf have changed, and there are concerns that new calls to printf will be cherry-picked into old firmware branches without the printf changes. So, in preparation for disallowing %l in master, remove occurrences of %l. This change was done by manually fixing up anything found under the EC directory with the following regex: %[0-9*.-]*l[^l] Remember that anything on the host machine is fine as-is, since the host printf never changed. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I2a97433ddab5bfb8a6031ca4ff1d3905289444e2 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834603 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Fix formatting errorsEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | | | | | This change fixes the printf formatting errors found by the compile-time prinf format checker. The errors fall into a few categories: 1. Incorrect size specifier (missing or extra l). 2. Missing or extra arguments. 3. Bad line splitting. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I5618097a581210b9fcbfc81560dec050ae30b61c Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819653 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* minute-ia: ish software panicDenis Brockus2019-06-111-0/+26
| | | | | | | | | | | | | | | | | | | Adding functions for software panic to ISH. This includes panic_set_reason, panic_get_reason and software_panic. Added extra output when a software panic is detected. Had to touch nds32/panic.c in order to make panic_sw_reasons common. BUG=b:134502392 BRANCH=none TEST=Verified with crash assert, with CONFIG_DEBUG_ASSERT defined Change-Id: Iebfe62a7dcd59b4bbed82b450dfd44cc8eaed1da Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1648958 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* ish: preserve panic data across resetJack Rosenthal2019-05-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit stores panic data across reset by storing panic data in the last 256 bytes of AON memory (before AON ROM). > crash divzero ========== PANIC ========== Reason: Divide By Zero Error Code = 0xFF00B60C EIP = 0xFF010008 CS = 0x00010202 EFLAGS = 0x00103085 EAX = 0x00000001 EBX = 0xFF01B118 ECX = 0x00000000 EDX = 0x00000000 ESI = 0x00000000 EDI = 0xFF017E0E Resetting system... =========================== ... ISH reset ... > panicinfo Saved panic data: (NEW) Reason: Divide By Zero Error Code = 0xFF00B60C EIP = 0xFF010008 CS = 0x00010202 EFLAGS = 0x00103085 EAX = 0x00000001 EBX = 0xFF01B118 ECX = 0x00000000 EDX = 0x00000000 ESI = 0x00000000 EDI = 0xFF017E0E BUG=b:129425206 BRANCH=none TEST=see console output above (on arcada_ish) Change-Id: I5c9e458b53076eafe7fa50ba851f2c6e863f2247 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1593418 Reviewed-by: Jett Rink <jettrink@chromium.org>
* panic_output: undefined behaviour elicits abort() callsPatrick Georgi2018-07-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | Explicitly coding x/0 doesn't result in a div-by-zero fault, but in an abort() call, which breaks the build as abort doesn't exist. By marking zero as volatile, the compiler must not assume that the value is still the same, so can't do constant subexpression elimination and determine that this expression leads to UB. Hat tip to shawnn@ for this unexpectedly elegant approach (compared to all other approaches). BUG=none BRANCH=none TEST=buildall works with gcc8.1 Change-Id: Idd34e3b4119d0d6a5231576e768ee285c621d229 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/1126318 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* panic: Set EC_HOST_EVENT_PANIC on chipset resetFurquan Shaikh2017-11-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | Add a hook for CHIPSET_RESET to allow the EC to indicate if there is any new panic info present. This helps coreboot to log EC panic info in eventlog. Also, update the hook priority for CHIPSET_RESET and HOOK_INIT to HOOK_PRIO_LAST to allow the EC to first log any software panic before it is checked. BUG=b:65732924,b:69334392 BRANCH=None TEST=Verified following: 1. Force panic_set_reason in EC on CHIPSET_RESET 2. reboot on AP console 3. mosys eventlog list shows "EC Event | Panic Reset in previous boot" Change-Id: I77b49cd0b3bf05b10efc708e3d81af9ed0e3aa49 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/797911 Reviewed-by: Shawn N <shawnn@chromium.org>
* Cr50: The panicinfo command is not safeBill Richardson2016-10-011-3/+3
| | | | | | | | | | | | | It's possible the register values could be sensitive. BUG=chrome-os-partner:57408 BRANCH=none TEST=make buildall; try on Gru with and without CR50_DEV=1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Id3d4df3aaca116a638332f092d4727accd0cbbcd Reviewed-on: https://chromium-review.googlesource.com/391612 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* panic: Fix unaligned memory access panicKito Cheng2016-09-011-1/+2
| | | | | | | | | | | | | | | | Some target's gcc will detect the address is unaligned and then expand to byte load sequence, make the address to volatile can prevent gcc optimize it. BUG=none BRANCH=none TEST=make buildall; Verified that "crash unaligned" causes a panic on it83xx. Change-Id: Ieb4f5f8fc65854aefe307fa675fe87d7581452ed Signed-off-by: Kito Cheng <kito.cheng@gmail.com> Reviewed-on: https://chromium-review.googlesource.com/374281 Reviewed-by: Shawn N <shawnn@chromium.org>
* Cr50: Mark several console commands as safeBill Richardson2016-08-311-3/+3
| | | | | | | | | | | | | | | | | | | Even when CONFIG_RESTRICTED_CONSOLE_COMMANDS is enabled, there are many commands that can't do anything dangerous. This marks some of those commands as safe to use, even when restrictions are enforced. I'm only marking commands that are used by the Cr50, since that's the only board that has restrictions. BUG=chrome-os-partner:55322 BRANCH=none TEST=make buildall, test on Cr50 hardware Change-Id: I6289d332830175b6adcb6b20cb4c21d01d27a25e Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/376188 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since pretty much always, we've declared console commands to take a "longhelp" argument with detailed explanations of what the command does. But since almost as long, we've never actually used that argument for anything - we just silently throw it away in the macro. There's only one command (usbchargemode) that even thinks it defines that argument. We're never going to use this, let's just get rid of it. BUG=none BRANCH=none CQ-DEPEND=CL:*279060 CQ-DEPEND=CL:*279158 CQ-DEPEND=CL:*279037 TEST=make buildall; tested on Cr50 hardware Everything builds. Since we never used this arg anyway, there had better not be any difference in the result. Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374163 Reviewed-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add new "hang" option to crash commandBill Richardson2016-08-051-5/+15
| | | | | | | | | | | | | | | | | | | | | The crash command is used to intentionally invoke various failure modes in a running system. This adds one more (and cleans up the command slightly). The "crash hang" command does the same thing as "crash watchdog", except that it disables interrupts first. Some SoCs may require special handling to recover from that case. BUG=none BRANCH=none TEST=make buildall; run on Cr50 hardware Invoked all the options to the crash command, observed that the appropriate response occurred in each case (a stack trace if possible, followed by a reboot). Change-Id: I18897cfc04726e6aeda59f4c6e742d7a0037cf80 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/366127 Reviewed-by: Vadim Bendebury <vbendeb@google.com>
* Kunimitsu: remove console commands for code sizeKyoung Kim2016-04-141-1/+2
| | | | | | | | | | | | | | | | | | | | | Remove following EC console commands to reduce code size: - battfake - apthrottle And none of commands above are used in 'auto test'. This is a squash of - https://chromium-review.googlesource.com/337657 - https://chromium-review.googlesource.com/338018 BUG=none BRANCH=firmware-glados-7820.B TEST=make -j buildall Change-Id: I11d2c5514f2714f0a46416feec2b2c47666fb462 Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com> Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/338893 Reviewed-by: Shawn N <shawnn@chromium.org>
* stm32: add synchronous debug printfAlec Berg2015-10-191-0/+2
| | | | | | | | | | | | | | | | | | Allow use of a synchronous debug printf instead of using the full console task to save space. This can be turned on with CONFIG_DEBUG_PRINTF, and will provide essentially a one-way console for debugging. This is essentially expanding upon the debug_printf work done for zinger. BUG=chrome-os-partner:41959 BRANCH=none TEST=tested with following CLs on glados_pd by verifying we get a one-way console. Change-Id: If028b5d873261890de5b270bbc00e06bdcaa7431 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306782 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* panic: Fix unaligned memory access panicli feng2015-04-141-1/+1
| | | | | | | | | | | | | | | Unaligned memory access would not cause reboot on some processors. Additional condition was needed. BUG=none TEST=Verified that "crash unaligned" causes a panic on mec1322. BRANCH=none Change-Id: Icdc1b5e11634b14890755301346183e0dba723c9 Signed-off-by: li feng <li1.feng@intel.com> Signed-off-by: Divya Jyothi <divya.jyothi@intel.com> Reviewed-on: https://chromium-review.googlesource.com/263949 Reviewed-by: Shawn N <shawnn@chromium.org>
* panic: Send host event on panic detectShawn Nematbakhsh2015-02-241-0/+14
| | | | | | | | | | | | | | | If a panic caused us to reboot, send a host event to notify the AP. BUG=chrome-os-partner:36985 TEST=Manual on Samus. Trigger EC panic, verify that "Panic Reset in previous boot" is seen in /var/log/eventlog. BRANCH=Samus Change-Id: Icf0d00a8cfc7aa788f3ceadd65fe3139f40df503 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/252410 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* panic: fix logging of watchdog in panic dataAlec Berg2015-02-201-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix bug with the new CONFIG_SOFTWARE_PANIC where a watchdog panic will write panic data after jump_data pointer is calculated. Since jump data uses the same RAM location as panic data (the end of RAM), we rely on panic data being written BEFORE jump data pointer is calculated so that we don't use the same RAM space. BUG=chrome-os-partner:36871 BRANCH=samus TEST=without this CL, can reproduce problem where jump data is corrupted using samus with following steps: 1) hibernate 1 (this will clear panicinfo) 2) waitms 3000 (this will cause a watchdog reset) 3) let system boot to S0 4) sysjump rw On sysjump to RW, the jump data will be corrupt because while we were in RO panic data was added where there wasn't any before. This means the jump_data pointer in RW will differ from the jump_data pointer that was used in RO and we will fail to find the magic jump data. Most visible consequence of this is that the USB ports will be disabled after these steps because we use jump data to store last state of USB port enables. With this CL, following the steps above, the USB ports are restored to the pre-sysjump state, which is enabled. Change-Id: Ia129419db7400eddb54bcf57b4d4aed63d5c52ef Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/251110 Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cortex-m*: Save panicinfo on non-exception panicsShawn Nematbakhsh2015-02-181-8/+58
| | | | | | | | | | | | | | | | | | Make non-exception "software" panics such as stack overflow and assert failure save a panic log. Log the panic type in r4, and misc. panic data in r5 so that panic reasons can be distinguished. BUG=chrome-os-partner:36744 TEST=Manual on samus_pd. Run 'crash divzero' then 'panicinfo' after reboot. Verify that panic info is printed with "r4 :dead6660". Trigger stack overflow, verify that panic info is printed with "r4 :dead6661". BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I5f7a8eb0a5c2ac5799d29bb241deb24fabf38f68 Reviewed-on: https://chromium-review.googlesource.com/249912 Tested-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* ryu: Use brief assertion failure messageVic Yang2014-10-011-0/+9
| | | | | | | | | | | | | | | | | | | | | Currently, when an assertion fails, the error message is like: ASSERTION FAILURE '1 + 1 == 3' in command_apreset() at common/chipset.c:24 To save flash space, let's add an option to remove the failed expression and function name. The error message becomes: ASSERTION FAILURE at common/chipset.c:24 BUG=chrome-os-partner:32203 TEST=make buildall TEST=Add an assertion and triggers it. Check error message. BRANCH=None Change-Id: Ie323d5b43cbff2cd8f6cd5bb46c1f34ecd16bd5e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219670 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* extract common core codeVincent Palatin2013-12-051-0/+169
Move the non-core dependent code out of core/$(CORE) directory to common/ directory. Put all panic printing code in common/panic_output.c Put timer management code in common/timer.c Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:23574 TEST=./util/make_all.sh use "crash divzero" and "panicinfo" on Link. Change-Id: Ia4e1ebc74cd53da55fe24f69e96f39f512b9336d Reviewed-on: https://chromium-review.googlesource.com/178871 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Jeremy Thorpe <jeremyt@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>