Compare commits

...

2 Commits

Author SHA1 Message Date
59d69f684f
x86_64: Add general protection fault handler
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-24 11:49:47 +01:00
f71ccde833
Add an overload for aligned deletes which just calls the normal operator delete 2022-12-24 11:49:12 +01:00
3 changed files with 20 additions and 1 deletions

View File

@ -28,6 +28,8 @@ extern void setup_idt();
[[noreturn]] void handle_page_fault(Registers* regs)
{
CPU::disable_interrupts();
u64 cr2;
asm volatile("mov %%cr2, %0" : "=r"(cr2));
kerrorln("Page fault at RIP %lx while accessing %lx!", regs->rip, cr2);
@ -37,6 +39,17 @@ extern void setup_idt();
CPU::efficient_halt();
}
[[noreturn]] void handle_general_protection_fault(Registers* regs)
{
CPU::disable_interrupts();
kerrorln("General protection fault at RIP %lx, error code %lx!", regs->rip, regs->error);
CPU::print_stack_trace_at(regs);
CPU::efficient_halt();
}
extern "C" void handle_x86_exception(Registers* regs)
{
switch (regs->isr)
@ -52,7 +65,7 @@ extern "C" void handle_x86_exception(Registers* regs)
case 10: FIXME_UNHANDLED_INTERRUPT("Invalid TSS");
case 11: FIXME_UNHANDLED_INTERRUPT("Segment not present");
case 12: FIXME_UNHANDLED_INTERRUPT("Stack-segment fault");
case 13: FIXME_UNHANDLED_INTERRUPT("General protection fault");
case 13: handle_general_protection_fault(regs);
case 14: handle_page_fault(regs);
case 16: FIXME_UNHANDLED_INTERRUPT("x87 floating-point exception");
case 17: FIXME_UNHANDLED_INTERRUPT("Alignment check");

View File

@ -20,6 +20,7 @@ void raw_free(void*);
void* operator new(usize size, const std::nothrow_t&) noexcept;
void* operator new[](usize size, const std::nothrow_t&) noexcept;
void operator delete(void* ptr, usize size, std::align_val_t alignment) noexcept;
template <typename T, class... Args> [[nodiscard]] Result<T*> make(Args... args)
{

View File

@ -23,3 +23,8 @@ void raw_free(void* ptr)
return free(ptr);
#endif
}
void operator delete(void* ptr, usize size, std::align_val_t) noexcept
{
operator delete(ptr, size);
}