1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 14:38:12 +00:00

Kernel: Shutdown on panic in self-test mode

Instead of doing a reset via triple-fault, let's just shutdown the QEMU
virtual machine because this is already a QEMU-specific handling code
for Self-Test CI mode.
This commit is contained in:
Liav A 2021-07-26 21:34:43 +03:00 committed by Ali Mohammad Pur
parent de9ff0af50
commit 713b18b7a6

View file

@ -7,19 +7,20 @@
#include <AK/Format.h> #include <AK/Format.h>
#include <Kernel/Arch/x86/Processor.h> #include <Kernel/Arch/x86/Processor.h>
#include <Kernel/CommandLine.h> #include <Kernel/CommandLine.h>
#include <Kernel/IO.h>
#include <Kernel/KSyms.h> #include <Kernel/KSyms.h>
#include <Kernel/Panic.h> #include <Kernel/Panic.h>
namespace Kernel { namespace Kernel {
[[noreturn]] static void __reset() [[noreturn]] static void __shutdown()
{ {
// FIXME: This works for i686/x86_64, but needs to be ported to any other arch when needed. // Note: This will invoke QEMU Shutdown, but for other platforms (or emulators),
asm( // this has no effect on the system, so we still need to halt afterwards.
"lidt 0\n" // We also try the Bochs/Old QEMU shutdown method, if the first didn't work.
"movl $0, 0\n"); IO::out16(0x604, 0x2000);
IO::out16(0xb004, 0x2000);
__builtin_unreachable(); Processor::halt();
} }
void __panic(const char* file, unsigned int line, const char* function) void __panic(const char* file, unsigned int line, const char* function)
@ -27,7 +28,7 @@ void __panic(const char* file, unsigned int line, const char* function)
critical_dmesgln("at {}:{} in {}", file, line, function); critical_dmesgln("at {}:{} in {}", file, line, function);
dump_backtrace(); dump_backtrace();
if (kernel_command_line().boot_mode() == BootMode::SelfTest) if (kernel_command_line().boot_mode() == BootMode::SelfTest)
__reset(); __shutdown();
else else
Processor::halt(); Processor::halt();
} }