summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2023-03-10 09:12:05 +0100
committerJan Janssen <medhefgo@web.de>2023-03-17 10:35:29 +0100
commita05f03225ed5c27436d1c8689957687937a493bc (patch)
tree18d060d4b03aad0ddc0cb8459fbce7671cb6c95c /src/boot
parent6742397921a846668f0e4f6da09075ac24a0f634 (diff)
downloadsystemd-a05f03225ed5c27436d1c8689957687937a493bc.tar.gz
boot: Detect nested assertions
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/log.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/boot/efi/log.c b/src/boot/efi/log.c
index 9cbbb3a933..b805f5d084 100644
--- a/src/boot/efi/log.c
+++ b/src/boot/efi/log.c
@@ -10,8 +10,23 @@ _noreturn_ static void freeze(void) {
BS->Stall(60 * 1000 * 1000);
}
+_noreturn_ static void panic(const char16_t *message) {
+ if (ST->ConOut->Mode->CursorColumn > 0)
+ ST->ConOut->OutputString(ST->ConOut, (char16_t *) u"\r\n");
+ ST->ConOut->SetAttribute(ST->ConOut, EFI_TEXT_ATTR(EFI_LIGHTRED, EFI_BLACK));
+ ST->ConOut->OutputString(ST->ConOut, (char16_t *) message);
+ freeze();
+}
+
void efi_assert(const char *expr, const char *file, unsigned line, const char *function) {
- log_error("systemd-boot assertion '%s' failed at %s:%u@%s. Halting.", expr, file, line, function);
+ static bool asserting = false;
+
+ /* Let's be paranoid. */
+ if (asserting)
+ panic(u"systemd-boot: Nested assertion failure, halting.");
+
+ asserting = true;
+ log_error("systemd-boot: Assertion '%s' failed at %s:%u@%s, halting.", expr, file, line, function);
freeze();
}
@@ -48,12 +63,10 @@ void log_wait(void) {
/* These override the (weak) div0 handlers from libgcc as they would otherwise call raise() instead. */
_used_ _noreturn_ int __aeabi_idiv0(int return_value) {
- log_error("Division by zero.");
- freeze();
+ panic(u"systemd-boot: Division by zero, halting.");
}
_used_ _noreturn_ long long __aeabi_ldiv0(long long return_value) {
- log_error("Division by zero.");
- freeze();
+ panic(u"systemd-boot: Division by zero, halting.");
}
#endif