summaryrefslogtreecommitdiff
path: root/include/common/debug.h
Commit message (Collapse)AuthorAgeFilesLines
* refactor(bl31): use elx_panic for sysreg_handler64Govindraj Raja2023-02-221-2/+2
| | | | | | | | | | | | When we reach sysreg_handler64 from any trap handling we are entering this path from lower EL and thus we should be calling lower_el_panic reporting mechanism to print panic report. Make report_elx_panic available through assembly func elx_panic which could be used for reporting any lower_el_panic. Change-Id: Ieb260cf20ea327a59db84198b2c6a6bfc9ca9537 Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
* refactor(aarch64): rename do_panic and el3_panicGovindraj Raja2023-02-211-2/+2
| | | | | | | | | | | Current panic call invokes do_panic which calls el3_panic, but now panic handles only panic from EL3 anid clear separation to use lower_el_panic() which handles panic from lower ELs. So now we can remove do_panic and just call el3_panic for all panics. Change-Id: I739c69271b9fb15c1176050877a9b0c0394dc739 Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
* refactor(aarch64): refactor usage of elx_panicGovindraj Raja2023-02-211-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we call el3_panic for panics from EL3 and elx_panic for panics from lower ELs. When we boot into a rich OS environment and interact with BL31 using SMC/ABI calls and we can also decide to handle any lower EL panics in EL3. Panic can occur in lower EL from rich OS or during SMC/ABI calls after context switch to EL3. But after booting into any rich OS we may land in panic either from rich OS or while servicing any SMC call, here the logic to use el3_panic or elx_panic is flawed as spsr_el3[3:0] is always EL3h and end up in elx_panic even if panic occurred from EL3 during SMC handling. We try to decouple the elx_panic usage for its intended purpose, introduce lower_el_panic which would call elx_panic, currently lower_el_panic is called from default platform_ea_handle which would be called due to panic from any of the lower ELs. Also remove the weak linkage for elx_panic and rename it to report_elx_panic which could be used with lower_el_panic. Change-Id: I268bca89c01c60520d127ef6c7ba851460edc747 Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
* fix(debug): decouple "get_el_str()" from backtraceManish Pandey2022-11-081-1/+2
| | | | | | | | | | | | | get_el_str() was implemented under ENABLE_BACKTRACE macro but being used at generic places too, this causes multiple definition of this function. Remove duplicate definition of this function and move it out of backtrace scope. Also, this patch fixes a small bug where in default case S-EL1 is returned which ideally should be EL1, as there is no notion of security state in EL string. Signed-off-by: Manish Pandey <manish.pandey2@arm.com> Change-Id: Ib186ea03b776e2478eff556065449ebd478c3538
* feat(common/debug): add new macro ERROR_NL() to print just a newlinePali Rohár2021-07-211-0/+3
| | | | | | | | | | | | | | | | | Existing macro ERROR() prints string "ERROR" followed by string specified by caller. Therefore via this existing macro it is not possible to end incomplete / existing line by a newline character. This change adds a new macro ERROR_NL() which prints just a newline character without any prefix. Implementation of this macro is done via a new function tf_log_newline() which based on supplied log level either return or print newline character. If needed in future based on this tf_log_newline() function can be defined also macros for other log levels. Signed-off-by: Pali Rohár <pali@kernel.org> Change-Id: I05414ca177f94cdc0f6077394d9c4af4a4382306
* Don't return error information from console_flushJimmy Brisson2020-10-091-1/+1
| | | | | | | | | | | | | And from crash_console_flush. We ignore the error information return by console_flush in _every_ place where we call it, and casting the return type to void does not work around the MISRA violation that this causes. Instead, we collect the error information from the driver (to avoid changing that API), and don't return it to the caller. Change-Id: I1e35afe01764d5c8f0efd04f8949d333ffb688c1 Signed-off-by: Jimmy Brisson <jimmy.brisson@arm.com>
* Fix crash dump for lower ELAlexei Fedorov2020-03-061-1/+2
| | | | | | | | | This patch provides a fix for incorrect crash dump data for lower EL when TF-A is built with HANDLE_EA_EL3_FIRST=1 option which enables routing of External Aborts and SErrors to EL3. Change-Id: I9d5e6775e6aad21db5b78362da6c3a3d897df977 Signed-off-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* Replace __ASSEMBLY__ with compiler-builtin __ASSEMBLER__Julius Werner2019-08-011-2/+2
| | | | | | | | | | | | | | NOTE: __ASSEMBLY__ macro is now deprecated in favor of __ASSEMBLER__. All common C compilers predefine a macro called __ASSEMBLER__ when preprocessing a .S file. There is no reason for TF-A to define it's own __ASSEMBLY__ macro for this purpose instead. To unify code with the export headers (which use __ASSEMBLER__ to avoid one extra dependency), let's deprecate __ASSEMBLY__ and switch the code base over to the predefined standard. Change-Id: Id7d0ec8cf330195da80499c68562b65cb5ab7417 Signed-off-by: Julius Werner <jwerner@chromium.org>
* Sanitise includes across codebaseAntonio Nino Diaz2019-01-041-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enforce full include path for includes. Deprecate old paths. The following folders inside include/lib have been left unchanged: - include/lib/cpus/${ARCH} - include/lib/el3_runtime/${ARCH} The reason for this change is that having a global namespace for includes isn't a good idea. It defeats one of the advantages of having folders and it introduces problems that are sometimes subtle (because you may not know the header you are actually including if there are two of them). For example, this patch had to be created because two headers were called the same way: e0ea0928d5b7 ("Fix gpio includes of mt8173 platform to avoid collision."). More recently, this patch has had similar problems: 46f9b2c3a282 ("drivers: add tzc380 support"). This problem was introduced in commit 4ecca33988b9 ("Move include and source files to logical locations"). At that time, there weren't too many headers so it wasn't a real issue. However, time has shown that this creates problems. Platforms that want to preserve the way they include headers may add the removed paths to PLAT_INCLUDES, but this is discouraged. Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* Reorder log level macro definitions for clarityJohn Tsichritzis2018-10-101-6/+6
| | | | | | | | The definitions of the logging macros are reordered to be consistent with the definitions of the log levels. Change-Id: I6ff07b93eb64786ff147d39014d1c8e15db28444 Signed-off-by: John Tsichritzis <john.tsichritzis@arm.com>
* Fix MISRA defects in log helpersAntonio Nino Diaz2018-08-301-8/+10
| | | | | | | No functional changes. Change-Id: I850f08718abb69d5d58856b0e3de036266d8c2f4 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* backtrace: Print backtrace in assert() and panic()Antonio Nino Diaz2018-08-301-1/+9
| | | | | | | | When any of these functions is called the backtrace will be printed to the console. Change-Id: Id60842df824b320c485a9323ed6b80600f4ebe35 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* backtrace: Introduce backtrace functionDouglas Raillard2018-08-301-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function diplays the backtrace, the current EL and security state to allow a post-processing tool to choose the right binary to interpret the dump. The output can be fed to GNU addr2line to resolve function names given an ELF binary compiled with debug information. The "-i" flag is recommended to improve display in case of inlined functions. The *.dump files generated during the build process can also be used. The function works in AArch64 and AArch32. In AArch32 it only works in A32 mode (without T32 interworking), which is enforced in the Makefile. Sample output of a backtrace at EL3: BACKTRACE: START: function_name 0: EL3: 0x798 1: EL3: 0x538 2: EL3: 0x550 3: EL3: 0x55c 4: EL3: 0x568 5: EL3: 0x5a8 6: EL3: 0xf4 BACKTRACE: END: function_name In order to enable it the new option ENABLE_BACKTRACE must be set to 1. This option is set to 1 by default only in AArch64 debug builds. As usual, it can be overridden by the platform makefile and in the build command line. Change-Id: Icaff39b0e5188329728be2f3c72b868b2368e794 Co-authored-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com> Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
* libc: Move tf_printf and tf_snprintf to libcAntonio Nino Diaz2018-08-221-7/+3
| | | | | | | | | Change their names to printf and snprintf. They are much smaller than the previous versions we had, which makes them better suited for the Trusted Firmware. Change-Id: Ia872af91b7b967c47fce012eccecede7873a3daf Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* tf_printf: Return number of printed charactersAntonio Nino Diaz2018-08-221-3/+3
| | | | | | | | The C standard says that printf() has to return the number of characters it has printed. Change-Id: I0ef50b1d6766d140724ac0a2fa2c5d023431f984 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* libc: Fix all includes in codebaseAntonio Nino Diaz2018-08-221-0/+1
| | | | | | | | | The codebase was using non-standard headers. It is needed to replace them by the correct ones so that we can use the new libc headers. Change-Id: I530f71d9510cb036e69fe79823c8230afe890b9d Acked-by: Sumit Garg <sumit.garg@linaro.org> Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* Run compiler on debug macros for type checkingSandrine Bailleux2018-07-131-7/+21
| | | | | | | | | | | | | | Even if the log output is too low for a message to be printed out on the console by the debug macros, it should still be evaluated by the compiler to get some type checking and validation of the format specifiers. To do so, introduce the no_tf_log() macro that encloses the call to tf_log() in an always-false condition. This avoids the problem of discovering build issues only when we build the firmware with the right LOG_LEVEL value. Change-Id: Ic0fd252ab691d0187fd925756a4837aca1cbfd7b Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
* Implement log frameworkSoby Mathew2017-09-111-6/+18
| | | | | | | | | | | | | | | | | | | | This patch gives users control over logging messages printed from the C code using the LOG macros defined in debug.h Users now have the ability to reduce the log_level at run time using the tf_log_set_max_level() function. The default prefix string can be defined by platform by overriding the `plat_log_get_prefix()` platform API which is also introduced in this patch. The new log framework results in saving of some RO data. For example, when BL1 is built for FVP with LOG_LEVEL=LOG_LEVEL_VERBOSE, resulted in saving 384 bytes of RO data and increase of 8 bytes of RW data. The framework also adds about 108 bytes of code to the release build of FVP. Fixes ARM-software/tf-issues#462 Change-Id: I476013d9c3deedfdd4c8b0b0f125665ba6250554 Co-authored-by: Eleanor Bonnici <Eleanor.bonnici@arm.com> Signed-off-by: Soby Mathew <soby.mathew@arm.com>
* Introduce tf_vprintf() and tf_string_print()Soby Mathew2017-09-111-0/+3
| | | | | | | | | This patch introduces tf_vprintf() and tf_string_print() APIs which is needed by the logging framework introduced in a later patch. Change-Id: Ie4240443d0e04e070502b51e371e546dd469fd33 Signed-off-by: Soby Mathew <soby.mathew@arm.com>
* Introduce `tf_snprintf`Antonio Nino Diaz2017-05-241-0/+1
| | | | | | | | | | This is a reduced version of `snprintf` that only supports formats '%d', '%i' and '%u'. It can be used when the full `snprintf` is not needed in order to save memory. If it finds an unknown format specifier, it prints an error message and panics. Change-Id: I2cb06fcdf74cda2c43caf73ae0762a91499fc04e Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* Use SPDX license identifiersdp-arm2017-05-031-25/+1
| | | | | | | | | | | | To make software license auditing simpler, use SPDX[0] license identifiers instead of duplicating the license text in every file. NOTE: Files that have been imported by FreeBSD have not been modified. [0]: https://spdx.org/ Change-Id: I80a00e1f641b8cc075ca5a95b10607ed9ed8761a Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
* Add support for GCC stack protectionDouglas Raillard2017-03-311-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce new build option ENABLE_STACK_PROTECTOR. It enables compilation of all BL images with one of the GCC -fstack-protector-* options. A new platform function plat_get_stack_protector_canary() is introduced. It returns a value that is used to initialize the canary for stack corruption detection. Returning a random value will prevent an attacker from predicting the value and greatly increase the effectiveness of the protection. A message is printed at the ERROR level when a stack corruption is detected. To be effective, the global data must be stored at an address lower than the base of the stacks. Failure to do so would allow an attacker to overwrite the canary as part of an attack which would void the protection. FVP implementation of plat_get_stack_protector_canary is weak as there is no real source of entropy on the FVP. It therefore relies on a timer's value, which could be predictable. Change-Id: Icaaee96392733b721fa7c86a81d03660d3c1bc06 Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
* Make cpu operations warning a VERBOSE printSoby Mathew2016-03-221-3/+4
| | | | | | | | | | | | | | | | The assembler helper function `print_revision_warning` is used when a CPU specific operation is enabled in the debug build (e.g. an errata workaround) but doesn't apply to the executing CPU's revision/part number. However, in some cases the system integrator may want a single binary to support multiple platforms with different IP versions, only some of which contain a specific erratum. In this case, the warning can be emitted very frequently when CPUs are being powered on/off. This patch modifies this warning print behaviour so that it is emitted only when LOG_LEVEL >= LOG_LEVEL_VERBOSE. The `debug.h` header file now contains guard macros so that it can be included in assembly code. Change-Id: Ic6e7a07f128dcdb8498a5bfdae920a8feeea1345
* Enable type-checking of arguments passed to printf() et al.Sandrine Bailleux2015-03-061-1/+1
| | | | | | | | | | | | | | | | | | This patch modifies the declarations of the functions printf() et al. and adds the right GCC attribute to request the compiler to check the type of the arguments passed to these functions against the given format string. This will ensure that the compiler outputs warning messages like the following whenever it detects an inconsistency: file.c:42: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’ It also fixes the type mismatch inconsistencies that it revealed across the code base. NOTE: THIS PATCH MAY FORCE PLATFORM PORTS OR SP/SPDS THAT USE THE PRINTF FAMILY OF FUNCTIONS TO FIX ANY TYPE MISMATCH INCONSISTENCIES. Change-Id: If36bb54ec7d6dd2cb4791d89b02a24ac13fd2df6
* Add concept of console output log levelsDan Handley2014-08-121-14/+43
| | | | | | | | | | | | | | | | | | | | | | | | | Create new LOG_LEVEL build option, which controls the amount of console output compiled into the build. This should be one of the following: 0 (LOG_LEVEL_NONE) 10 (LOG_LEVEL_NOTICE) 20 (LOG_LEVEL_ERROR) 30 (LOG_LEVEL_WARNING) 40 (LOG_LEVEL_INFO) 50 (LOG_LEVEL_VERBOSE) All log output up to and including the log level is compiled into the build. The default value is 40 in debug builds and 20 in release builds. Complement the existing INFO, WARN and ERROR console output macros with NOTICE and VERBOSE macros, which are conditionally compiled in depending on the value of LOG_LEVEL. Fixes ARM-software/tf-issues#232 Change-Id: I951e2f333e7b90fc4b1060741d9a6db699d5aa72
* Rework the crash reporting in BL3-1 to use less stackSoby Mathew2014-07-281-13/+0
| | | | | | | | | | | | | | | | | This patch reworks the crash reporting mechanism to further optimise the stack and code size. The reporting makes use of assembly console functions to avoid calling C Runtime to report the CPU state. The crash buffer requirement is reduced to 64 bytes with this implementation. The crash buffer is now part of per-cpu data which makes retrieving the crash buffer trivial. Also now panic() will use crash reporting if invoked from BL3-1. Fixes ARM-software/tf-issues#199 Change-Id: I79d27a4524583d723483165dc40801f45e627da5
* Implement a leaner printf for Trusted FirmwareSoby Mathew2014-07-251-3/+5
| | | | | | | | | | This patch implements a "tf_printf" which supports only the commonly used format specifiers in Trusted Firmware, which uses a lot less stack space than the stdlib printf function. Fixes ARM-software/tf-issues#116 Change-Id: I7dfa1944f4c1e634b3e2d571f49afe02d109a351
* Remove extern keyword from function declarationsDan Handley2014-05-231-3/+3
| | | | | | | Function declarations implicitly have external linkage so do not need the extern keyword. Change-Id: Ia0549786796d8bf5956487e8996450a0b3d79f32
* Rework BL3-1 unhandled exception handling and reportingSoby Mathew2014-05-161-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements the register reporting when unhandled exceptions are taken in BL3-1. Unhandled exceptions will result in a dump of registers to the console, before halting execution by that CPU. The Crash Stack, previously called the Exception Stack, is used for this activity. This stack is used to preserve the CPU context and runtime stack contents for debugging and analysis. This also introduces the per_cpu_ptr_cache, referenced by tpidr_el3, to provide easy access to some of BL3-1 per-cpu data structures. Initially, this is used to provide a pointer to the Crash stack. panic() now prints the the error file and line number in Debug mode and prints the PC value in release mode. The Exception Stack is renamed to Crash Stack with this patch. The original intention of exception stack is no longer valid since we intend to support several valid exceptions like IRQ and FIQ in the trusted firmware context. This stack is now utilized for dumping and reporting the system state when a crash happens and hence the rename. Fixes ARM-software/tf-issues#79 Improve reporting of unhandled exception Change-Id: I260791dc05536b78547412d147193cdccae7811a
* Reduce deep nesting of header filesDan Handley2014-05-061-4/+0
| | | | | | | | | | | | | | Reduce the number of header files included from other header files as much as possible without splitting the files. Use forward declarations where possible. This allows removal of some unnecessary "#ifndef __ASSEMBLY__" statements. Also, review the .c and .S files for which header files really need including and reorder the #include statements alphabetically. Fixes ARM-software/tf-issues#31 Change-Id: Iec92fb976334c77453e010b60bcf56f3be72bd3e
* Move include and source files to logical locationsDan Handley2014-05-061-0/+70
Move almost all system include files to a logical sub-directory under ./include. The only remaining system include directories not under ./include are specific to the platform. Move the corresponding source files to match the include directory structure. Also remove pm.h as it is no longer used. Change-Id: Ie5ea6368ec5fad459f3e8a802ad129135527f0b3