1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 03:58:12 +00:00

Kernel: Use PANIC() in a bunch of places :^)

This commit is contained in:
Andreas Kling 2021-02-14 09:30:31 +01:00
parent c598a95b1c
commit b712345c92
8 changed files with 26 additions and 42 deletions

View file

@ -43,6 +43,7 @@
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Interrupts/UnhandledInterruptHandler.h>
#include <Kernel/KSyms.h>
#include <Kernel/Panic.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
#include <Kernel/SpinLock.h>
@ -163,8 +164,7 @@ void handle_crash(RegisterState& regs, const char* description, int signal, bool
{
auto process = Process::current();
if (!process) {
dmesgln("{} with !current", description);
Processor::halt();
PANIC("{} with !current", description);
}
// If a process crashed while inspecting another process,
@ -175,9 +175,7 @@ void handle_crash(RegisterState& regs, const char* description, int signal, bool
dump(regs);
if (!(regs.cs & 3)) {
dmesgln("Crash in ring 0 :(");
dump_backtrace();
Processor::halt();
PANIC("Crash in ring 0");
}
cli();
@ -330,9 +328,7 @@ void debug_handler(TrapFrame* trap)
auto current_thread = Thread::current();
auto& process = current_thread->process();
if ((regs.cs & 3) == 0) {
dmesgln("Debug exception in ring 0");
Processor::halt();
return;
PANIC("Debug exception in ring 0");
}
constexpr u8 REASON_SINGLESTEP = 14;
bool is_reason_singlestep = (read_dr6() & (1 << REASON_SINGLESTEP));
@ -353,9 +349,7 @@ void breakpoint_handler(TrapFrame* trap)
auto current_thread = Thread::current();
auto& process = current_thread->process();
if ((regs.cs & 3) == 0) {
dmesgln("Breakpoint trap in ring 0");
Processor::halt();
return;
PANIC("Breakpoint trap in ring 0");
}
if (auto tracer = process.tracer()) {
tracer->set_regs(regs);
@ -376,8 +370,7 @@ void breakpoint_handler(TrapFrame* trap)
: "=a"(cr3)); \
asm("movl %%cr4, %%eax" \
: "=a"(cr4)); \
dbgln("cr0={:08x} cr2={:08x} cr3={:08x} cr4={:08x}", cr0, cr2, cr3, cr4); \
Processor::halt(); \
PANIC("cr0={:08x} cr2={:08x} cr3={:08x} cr4={:08x}", cr0, cr2, cr3, cr4); \
}
EH(2, "Unknown error")
@ -398,8 +391,7 @@ const DescriptorTablePointer& get_idtr()
static void unimp_trap()
{
dmesgln("Unhandled IRQ");
Processor::Processor::halt();
PANIC("Unhandled IRQ");
}
GenericInterruptHandler& get_interrupt_handler(u8 interrupt_number)

View file

@ -38,6 +38,7 @@
#include <Kernel/Heap/Heap.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/KSyms.h>
#include <Kernel/Panic.h>
#include <Kernel/Process.h>
#include <Kernel/Scheduler.h>
#include <Kernel/SpinLock.h>
@ -247,9 +248,7 @@ void* kmalloc_impl(size_t size)
void* ptr = g_kmalloc_global->m_heap.allocate(size);
if (!ptr) {
klog() << "kmalloc(): PANIC! Out of memory (no suitable block for size " << size << ")";
Kernel::dump_backtrace();
Processor::halt();
PANIC("kmalloc: Out of memory (requested size: {})");
}
return ptr;

View file

@ -36,6 +36,7 @@
#include <Kernel/IO.h>
#include <Kernel/Interrupts/APIC.h>
#include <Kernel/Interrupts/SpuriousInterruptHandler.h>
#include <Kernel/Panic.h>
#include <Kernel/Thread.h>
#include <Kernel/Time/APICTimer.h>
#include <Kernel/VM/MemoryManager.h>
@ -424,8 +425,7 @@ void APIC::enable(u32 cpu)
{
if (cpu >= 8) {
// TODO: x2apic support?
klog() << "SMP support is currently limited to 8 CPUs!";
Processor::halt();
PANIC("SMP support is currently limited to 8 CPUs!");
}
// Use the CPU# as logical apic id

View file

@ -25,6 +25,7 @@
*/
#include <Kernel/Interrupts/UnhandledInterruptHandler.h>
#include <Kernel/Panic.h>
namespace Kernel {
UnhandledInterruptHandler::UnhandledInterruptHandler(u8 interrupt_vector)
@ -34,14 +35,12 @@ UnhandledInterruptHandler::UnhandledInterruptHandler(u8 interrupt_vector)
void UnhandledInterruptHandler::handle_interrupt(const RegisterState&)
{
dbgln("Interrupt: Unhandled vector {} was invoked for handle_interrupt(RegisterState&).", interrupt_number());
Processor::halt();
PANIC("Interrupt: Unhandled vector {} was invoked for handle_interrupt(RegisterState&).", interrupt_number());
}
[[noreturn]] bool UnhandledInterruptHandler::eoi()
{
dbgln("Interrupt: Unhandled vector {} was invoked for eoi().", interrupt_number());
Processor::halt();
PANIC("Interrupt: Unhandled vector {} was invoked for eoi().", interrupt_number());
}
UnhandledInterruptHandler::~UnhandledInterruptHandler()

View file

@ -27,11 +27,10 @@
#include <Kernel/ACPI/Parser.h>
#include <Kernel/CommandLine.h>
#include <Kernel/IO.h>
#include <Kernel/Net/E1000NetworkAdapter.h>
#include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <Kernel/PCI/IOAccess.h>
#include <Kernel/PCI/Initializer.h>
#include <Kernel/PCI/MMIOAccess.h>
#include <Kernel/Panic.h>
namespace Kernel {
namespace PCI {
@ -46,8 +45,7 @@ static Access::Type detect_optimal_access_type(bool mmio_allowed)
if (test_pci_io())
return Access::Type::IO;
klog() << "No PCI bus access method detected!";
Processor::halt();
PANIC("No PCI bus access method detected!");
}
void initialize()

View file

@ -29,6 +29,7 @@
#include <AK/TemporaryChange.h>
#include <AK/Time.h>
#include <Kernel/Debug.h>
#include <Kernel/Panic.h>
#include <Kernel/PerformanceEventBuffer.h>
#include <Kernel/Process.h>
#include <Kernel/RTC.h>
@ -418,8 +419,7 @@ bool Scheduler::context_switch(Thread* thread)
if (thread->process().is_user_process()) {
auto iopl = get_iopl_from_eflags(Thread::current()->get_register_dump_from_stack().eflags);
if (iopl != 0) {
dbgln("PANIC: Switched to thread {} with non-zero IOPL={}", Thread::current()->tid().value(), iopl);
Processor::halt();
PANIC("Switched to thread {} with non-zero IOPL={}", Thread::current()->tid().value(), iopl);
}
}
#endif

View file

@ -29,6 +29,7 @@
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/FileSystem/Ext2FileSystem.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/Panic.h>
#include <Kernel/Storage/IDEController.h>
#include <Kernel/Storage/Partition/EBRPartitionTable.h>
#include <Kernel/Storage/Partition/GUIDPartitionTable.h>
@ -146,8 +147,7 @@ void StorageManagement::determine_boot_device()
}
if (m_boot_block_device.is_null()) {
klog() << "init_stage2: boot device " << m_boot_argument << " not found";
Processor::halt();
PANIC("StorageManagement: boot device {} not found", m_boot_argument);
}
}
@ -159,8 +159,7 @@ void StorageManagement::determine_boot_device_with_partition_uuid()
auto partition_uuid = UUID(m_boot_argument.substring_view(strlen("PARTUUID=")));
if (partition_uuid.to_string().length() != 36) {
klog() << "init_stage2: specified partition UUID is not valid";
Processor::halt();
PANIC("StorageManagement: Specified partition UUID is not valid");
}
for (auto& partition : m_disk_partitions) {
@ -182,13 +181,11 @@ NonnullRefPtr<FS> StorageManagement::root_filesystem() const
{
auto boot_device_description = boot_block_device();
if (!boot_device_description) {
klog() << "init_stage2: couldn't find a suitable device to boot from";
Processor::halt();
PANIC("StorageManagement: Couldn't find a suitable device to boot from");
}
auto e2fs = Ext2FS::create(FileDescription::create(boot_device_description.release_nonnull()).value());
if (!e2fs->initialize()) {
klog() << "init_stage2: couldn't open root filesystem";
Processor::halt();
PANIC("StorageManagement: Couldn't open root filesystem");
}
return e2fs;
}

View file

@ -60,6 +60,7 @@
#include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/PCI/Initializer.h>
#include <Kernel/Panic.h>
#include <Kernel/Process.h>
#include <Kernel/RTC.h>
#include <Kernel/Random.h>
@ -288,8 +289,7 @@ void init_stage2(void*)
StorageManagement::initialize(root, force_pio);
if (!VFS::the().mount_root(StorageManagement::the().root_filesystem())) {
klog() << "VFS::mount_root failed";
Processor::halt();
PANIC("VFS::mount_root failed");
}
Process::current()->set_root_directory(VFS::the().root_custody());
@ -307,8 +307,7 @@ void init_stage2(void*)
init_args.prepend(userspace_init);
Process::create_user_process(thread, userspace_init, (uid_t)0, (gid_t)0, ProcessID(0), error, move(init_args), {}, tty0);
if (error != 0) {
klog() << "init_stage2: error spawning SystemServer: " << error;
Processor::halt();
PANIC("init_stage2: Error spawning SystemServer: {}", error);
}
thread->set_priority(THREAD_PRIORITY_HIGH);