summaryrefslogtreecommitdiff
path: root/Kernel/Arch/i386
diff options
context:
space:
mode:
authorGunnar Beutner <gunnar@beutner.name>2021-04-18 08:43:10 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-18 11:11:15 +0200
commitf033416893b097e9f148711c161537db328d02cd (patch)
tree947bfc71b0fb8c48663a2e625e1a922b87e534b7 /Kernel/Arch/i386
parent33a9b2a3c325e8875e75bd58d64de3463bf7f5d3 (diff)
downloadserenity-f033416893b097e9f148711c161537db328d02cd.zip
Kernel+LibC: Clean up how assertions work in the kernel and LibC
This also brings LibC's abort() function closer to the spec.
Diffstat (limited to 'Kernel/Arch/i386')
-rw-r--r--Kernel/Arch/i386/CPU.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index 7217caba51..93c22c1988 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -33,6 +33,7 @@
#include <Kernel/Arch/x86/ISRStubs.h>
#include <Kernel/Arch/x86/ProcessorInfo.h>
#include <Kernel/Arch/x86/SafeMem.h>
+#include <Kernel/Assertions.h>
#include <Kernel/Debug.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/APIC.h>
@@ -2419,6 +2420,13 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
dmesgln("ASSERTION FAILED: {}", msg);
dmesgln("{}:{} in {}", file, line, func);
+ abort();
+}
+#endif
+
+[[noreturn]] void abort()
+{
+#ifdef DEBUG
// Switch back to the current process's page tables if there are any.
// Otherwise stack walking will be a disaster.
auto process = Process::current();
@@ -2427,9 +2435,17 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
Kernel::dump_backtrace();
Processor::halt();
-}
#endif
+ abort();
+}
+
+[[noreturn]] void _abort()
+{
+ asm volatile("ud2");
+ __builtin_unreachable();
+}
+
NonMaskableInterruptDisabler::NonMaskableInterruptDisabler()
{
IO::out8(0x70, IO::in8(0x70) | 0x80);