aboutsummaryrefslogtreecommitdiff
path: root/core/utils.c
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2019-09-25 11:01:34 +1000
committerOliver O'Halloran <oohall@gmail.com>2019-10-03 09:55:58 +1000
commit9ddc1a6bfaef8669efd00b36fa1b699c04f6488d (patch)
tree1e3b1585813e5db510f0b7e31914afed040e45b9 /core/utils.c
parentb70e8afdb09f56e3c7db643862cd3d2fd15a4544 (diff)
downloadskiboot-9ddc1a6bfaef8669efd00b36fa1b699c04f6488d.zip
skiboot-9ddc1a6bfaef8669efd00b36fa1b699c04f6488d.tar.gz
skiboot-9ddc1a6bfaef8669efd00b36fa1b699c04f6488d.tar.bz2
core/util: trap based assertions
Using traps for assertions like Linux does gives a few advantages: - The asm code leading to the failure condition is nicer. - The interrupt gives a clean snapshot of machine state to dump. The difficulty with using traps for this in OPAL is that the runtime component will not deal well with the OS taking the 0x700 interrupt caused by a trap in OPAL. The long term goal is to improve the ability of the OS to inspect and debug OPAL at runtime. For now though, the traps are patched out before passing control to the OS, and the assert falls through to in-line failure handling. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> [oliver: commit prefix, added and renamed the FWTS label, fix tests] Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Diffstat (limited to 'core/utils.c')
-rw-r--r--core/utils.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/core/utils.c b/core/utils.c
index 728cea4..8fd63fc 100644
--- a/core/utils.c
+++ b/core/utils.c
@@ -13,28 +13,24 @@
#include <cpu.h>
#include <stack.h>
-void __noreturn assert_fail(const char *msg)
-{
- /**
- * @fwts-label FailedAssert
- * @fwts-advice OPAL hit an assert(). During normal usage (even
- * testing) we should never hit an assert. There are other code
- * paths for controlled shutdown/panic in the event of catastrophic
- * errors.
- */
- prlog(PR_EMERG, "Assert fail: %s\n", msg);
- _abort(msg);
-}
-
-void __noreturn _abort(const char *msg)
+void __noreturn assert_fail(const char *msg, const char *file,
+ unsigned int line, const char *function)
{
static bool in_abort = false;
+ (void)function;
if (in_abort)
for (;;) ;
in_abort = true;
- prlog(PR_EMERG, "Aborting!\n");
+ /**
+ * @fwts-label FailedAssert2
+ * @fwts-advice OPAL hit an assert(). During normal usage (even
+ * testing) we should never hit an assert. There are other code
+ * paths for controlled shutdown/panic in the event of catastrophic
+ * errors.
+ */
+ prlog(PR_EMERG, "assert failed at %s:%u: %s\n", file, line, msg);
backtrace();
if (platform.terminate)